<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Postgresql on Evan Hoffman</title><link>https://evan.wtf/tags/postgresql/</link><description>Recent content in Postgresql on Evan Hoffman</description><generator>Hugo</generator><language>en-US</language><copyright>Evan Hoffman</copyright><lastBuildDate>Wed, 12 Feb 2014 11:06:07 +0000</lastBuildDate><atom:link href="https://evan.wtf/tags/postgresql/index.xml" rel="self" type="application/rss+xml"/><item><title>Setting user Postgres passwords via MD5</title><link>https://evan.wtf/2014/02/12/setting-user-postgres-passwords-via-md5/</link><pubDate>Wed, 12 Feb 2014 11:06:07 +0000</pubDate><guid>https://evan.wtf/2014/02/12/setting-user-postgres-passwords-via-md5/</guid><description>&lt;p&gt;Say you want to create a Postgres account for a user but you don&amp;rsquo;t want them to have to reset it after logging in, and you don&amp;rsquo;t want to do the &amp;ldquo;come type in a password on my computer&amp;rdquo; routine. Well, here&amp;rsquo;s one way around this.&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;Have the user generate an MD5 of their password on their local computer. Postgres uses the username as the salt for the hash, so the command to generate the md5 on a Mac would be (assuming a username of &amp;rsquo;ehoffman&amp;rsquo; and a password of &amp;lsquo;abcdefg&amp;rsquo;):&lt;/p&gt;</description></item><item><title>The not-so-secret secret to Postgres performance</title><link>https://evan.wtf/2013/10/07/the-not-so-secret-secret-to-postgres-performance/</link><pubDate>Mon, 07 Oct 2013 10:19:05 +0000</pubDate><guid>https://evan.wtf/2013/10/07/the-not-so-secret-secret-to-postgres-performance/</guid><description>&lt;p&gt;I manage a bunch of Postgres DBs and one of the things I almost always forget to do when setting up a new one is set the readahead up from the default of 256. I created this script and run it out of /etc/rc.local and sometimes cron it too. The 3 commands at the top are only really relevant on systems with &amp;ldquo;huge&amp;rdquo; memory - probably over 64 GB. We &lt;a href="https://evan.wtf/2012/09/25/problems-with-postgresql-9-0-on-centos-6-3-with-a-2-6-32-series-kernel/"&gt;ran into some memory problems&lt;/a&gt; with CentOS 6 on a box with 128 GB ram which we ended up working around by reinstalling CentOS 5, but the &lt;code&gt;/sys/kernel/mm/redhat_transparent_hugepage/&lt;/code&gt; options below should fix them in 6.x (though we haven&amp;rsquo;t actually tried it on that DB, we haven&amp;rsquo;t seen any problems in other large DBs).&lt;/p&gt;</description></item><item><title>Goodbye, pg_dump</title><link>https://evan.wtf/2013/09/26/goodbye-pg_dump/</link><pubDate>Thu, 26 Sep 2013 09:12:05 +0000</pubDate><guid>https://evan.wtf/2013/09/26/goodbye-pg_dump/</guid><description>&lt;p&gt;I&amp;rsquo;ve been a Postgres user and administrator for a while. Over the years, my views on backups have evolved.&lt;/p&gt;&#10;&lt;p&gt;Originally, like most people, I started out with good old pg_dump. With a reasonably small database (under 50 GB) dumping to a flat text file is a fine option. I&amp;rsquo;d generally do something like &lt;code&gt;pg_dump -Upostgres dbname | gzip &amp;gt; dbname.sql.gz&lt;/code&gt; to compress it on the fly and save space. For years this seemed perfect: dumping the entire database in a single transaction into a single file that can be restored anywhere.&lt;/p&gt;</description></item><item><title>Problems with PostgreSQL 9.0 on CentOS 6.3 with a 2.6.32-series kernel</title><link>https://evan.wtf/2012/09/25/problems-with-postgresql-9-0-on-centos-6-3-with-a-2-6-32-series-kernel/</link><pubDate>Tue, 25 Sep 2012 13:20:36 +0000</pubDate><guid>https://evan.wtf/2012/09/25/problems-with-postgresql-9-0-on-centos-6-3-with-a-2-6-32-series-kernel/</guid><description>&lt;p&gt;&lt;em&gt;Note: this is cross-posted from the &lt;a href="http://www.yodletechblog.com/post/problems-with-postgresql-9.0-on-centos-6.3-with-a-2.6.32-series-kernel/"&gt;Yodle Tech Blog&lt;/a&gt;&lt;/em&gt;.&#10;We recently migrated our Postgres database to a significantly more powerful machine. While our existing server was doing okay load-wise, we were approaching 90% full on its Postgres volume. We&amp;rsquo;d also recently acquired an awesome new PureStorage SSD-based SAN and were excited to move our database onto it. For comparison, here are the the specs for the two systems:&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Old server&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;New server&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Nickname&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;DB1&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;DB2&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;CPU&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2x 6-core &lt;a href="http://ark.intel.com/products/52576/Intel-Xeon-Processor-X5690-%2812M-Cache-3_46-GHz-6_40-GTs-Intel-QPI%29"&gt;Xeon X5690&lt;/a&gt; CPUs at 3.47GHz&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2x 8-core &lt;a href="http://ark.intel.com/products/64596/Intel-Xeon-Processor-E5-2690-%2820M-Cache-2_90-GHz-8_00-GTs-Intel-QPI%29"&gt;E5-2690&lt;/a&gt; CPUs at 2.90 GHz&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Memory&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;96 GB 1333 MHz&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;128 GB 1600 MHz&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Storage&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;- Dell PERC H800 SAS HBA - Dell MD1220 drive enclosure - 24x 15k RPM SAS drives configured in RAID 10&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;- QLogic QLE2562 dual-port 8 Gbit FC HBA - PureStorage SSD-based SAN&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;OS&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;CentOS 5.6 x86_64&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;CentOS 6.3 x86_64&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Kernel&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2.6.18-238.9.1.el5&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;2.6.32-279.2.1.el6.x86_64&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;As you can probably guess, moving from spinning disk onto SSD was the centerpiece of the upgrade. We&amp;rsquo;d tested the PureStorage system pretty extensively and used it in some secondary databases and seen some amazing improvements. We were excited to see how it would handle our production workload.&lt;/p&gt;</description></item><item><title>Graphing SSH dictionary attacks with HighCharts</title><link>https://evan.wtf/2011/11/18/graphing-ssh-dictionary-attacks-with-highcharts/</link><pubDate>Fri, 18 Nov 2011 14:06:03 +0000</pubDate><guid>https://evan.wtf/2011/11/18/graphing-ssh-dictionary-attacks-with-highcharts/</guid><description>&lt;p&gt;After my 10-year-old basement Linux server died this week from a power outage, I took the sad step of giving up on it. It&amp;rsquo;s died before and I&amp;rsquo;ve patched it back together with a new power supply here or an addon PCI SATA card there, but I finally decided to throw in the towel since I had a newer old computer that had been idle for several years. The one that died was an Athlon K7 750 MHz with 512 MB ram. The new one is an Athlon 2 GHz (3200+) with 1 gig. For my uses, specs don&amp;rsquo;t really matter that much, but it&amp;rsquo;s nice to have more power for free.&lt;/p&gt;</description></item><item><title>33 hours to restore a Postgres DB</title><link>https://evan.wtf/2011/07/26/33-hours-2/</link><pubDate>Tue, 26 Jul 2011 18:10:01 +0000</pubDate><guid>https://evan.wtf/2011/07/26/33-hours-2/</guid><description>Restoring a huge DB takes a long time.</description></item><item><title>Using WAL archiving &amp; Compellent snapshots for PostgreSQL backups</title><link>https://evan.wtf/2011/07/13/using-wal-archiving-compellent-snapshots-for-postgresql-backups/</link><pubDate>Wed, 13 Jul 2011 13:46:40 +0000</pubDate><guid>https://evan.wtf/2011/07/13/using-wal-archiving-compellent-snapshots-for-postgresql-backups/</guid><description>Changing my Postgres DB backup strategy from nightly &lt;code&gt;pg_dump&lt;/code&gt;s to WAL archiving with SAN snapshots.</description></item><item><title>Migrating a PostgreSQL DB to a new machine without doing a dump &amp; restore</title><link>https://evan.wtf/2011/07/11/migrating-a-postgresql-db-to-a-new-machine-without-doing-a-dump-restore/</link><pubDate>Mon, 11 Jul 2011 14:39:16 +0000</pubDate><guid>https://evan.wtf/2011/07/11/migrating-a-postgresql-db-to-a-new-machine-without-doing-a-dump-restore/</guid><description>rsync over NFS can be so fast.</description></item><item><title>PostgreSQL query to determine the largest tables in the database</title><link>https://evan.wtf/2011/05/17/postgresql-query-to-determine-the-largest-tables-in-the-database/</link><pubDate>Tue, 17 May 2011 10:25:32 +0000</pubDate><guid>https://evan.wtf/2011/05/17/postgresql-query-to-determine-the-largest-tables-in-the-database/</guid><description>A PostgreSQL query to see the largest tables on-disk in a given database and how large their indices are.</description></item><item><title>Do I still need swap space?</title><link>https://evan.wtf/2010/11/11/do-i-still-need-swap-space/</link><pubDate>Thu, 11 Nov 2010 14:36:49 +0000</pubDate><guid>https://evan.wtf/2010/11/11/do-i-still-need-swap-space/</guid><description>&lt;p&gt;About three years ago I replaced our primary database. For years we&amp;rsquo;d been plagued by awful performance in the database and we were never able to diagnose the problem. The original server was a real beast at the time: 8 Opterons (single core), 32 gigs ram, and a fibre channel RAID connected via a QLogic HBA. This was back in 2005, so those specs don&amp;rsquo;t probably sound that impressive today, but this was a crazy configuration (with a crazy price tag to match). On paper it looked like this server should be basically invincible but the performance was awful, slowing down every process within the company. We contacted a few different companies (including &lt;a href="http://commandprompt.com/"&gt;CommandPrompt&lt;/a&gt;, which employs several of the core Pg devs) to see if they could assist us in diagnosing the problems but tuning only helped to a point. There was just something wrong with the box, maybe having to do with the FC HBA itself (which nobody knew much about).&lt;/p&gt;</description></item><item><title>Migrating RT from mysql to postgresql.</title><link>https://evan.wtf/2009/08/06/migrating-rt-from-mysql-to-postgresql/</link><pubDate>Thu, 06 Aug 2009 17:21:42 +0000</pubDate><guid>https://evan.wtf/2009/08/06/migrating-rt-from-mysql-to-postgresql/</guid><description>&lt;p&gt;So I wanted to move our old RT 3.6 system to a new VM running a clean CentOS 5.3 x86 install and RT 3.8. I got RT installed but the 3.6 system was running on MySQL, which sucks (still), and I wanted to move it to Postgres, which rules (more and more each day). So Googling for &amp;ldquo;migrate rt from mysql to postgresql&amp;rdquo; brought me &lt;a href="http://himdel.blogspot.com/2009/04/migrating-request-tracker-from-rt-345.html"&gt;here&lt;/a&gt;. I tried the procedure listed there but it wasn&amp;rsquo;t quite working for me. my2pg.pl and mysql2postgresql.perl both caused segfaults when I tried to run them. I realized I was on my own, and it wasn&amp;rsquo;t really that bad.&lt;/p&gt;</description></item></channel></rss>