<?xml version="1.0" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

<channel>
<title>Bruce Momjian: Postgres Blog</title>
<description>Bruce Momjian: Postgres Blog</description>
<link>http://momjian.us/main/blogs/pgblog.html</link>
<language>en-us</language>
<pubDate>Tue, 14 May 2013 10:30:01 EDT</pubDate>
<lastBuildDate>Tue, 14 May 2013 10:30:01 EDT</lastBuildDate>
<managingEditor>bruce@momjian.us (Bruce Momjian)</managingEditor>
<webMaster>bruce@momjian.us (Bruce Momjian)</webMaster>


<atom:link href="http://momjian.us/main/rss/pgblog.xml" rel="self" type="application/rss+xml" />

<item>
<title>
PgLife Averages Thirty Active Users
</title>
<pubDate>Mon, 13 May 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;A week after the &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#May_6_2013&quot;&gt;release&lt;/a&gt; of &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://pglife.momjian.us&quot;&gt;PgLife&lt;/a&gt;, the site
is averaging thirty active users.  (I define an active user as an IP address that has viewed the site for at least five minutes
during the past hour.)  I consider that a success.  Since the release of PgLife, I have increased the content update interval and added an
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://pglife.momjian.us/about.html&quot;&gt;&lt;em&gt;About&lt;/em&gt;&lt;/a&gt; page explaining the site's purpose, which also includes the active user count.
&lt;/p&gt;
&lt;p&gt;The site uses &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;https://en.wikipedia.org/wiki/Ajax_%28programming%29&quot;&gt;AJAX&lt;/a&gt;, &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.perl.org/&quot;&gt;Perl&lt;/a&gt;,
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.procmail.org/&quot;&gt;Procmail rules&lt;/a&gt;, and &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://httpd.apache.org/&quot;&gt;Apache&lt;/a&gt; to collect and deliver dynamic content.  Recent
improvements in the Postgres &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/list/&quot;&gt;mailing list archive&lt;/a&gt;
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/message-id/CABUevEwmR5+9fc1i1cFVpc1S8XShHwvKopcaKKfq-Txa+_mq_g@mail.gmail.com&quot;&gt;feature set&lt;/a&gt; have made
linking to emails much simpler.
&lt;/p&gt;
&lt;p&gt;PgLife was my first attempt at a dynamic website, and I learned a few things.  First, I learned the value of having an
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://pglife.momjian.us/data/alert.html&quot;&gt;alert&lt;/a&gt; file that can force a browser reload to push fixes and improvements to the browser. 
Second, I used the same file to allow pushing of news alerts to users, e.g. &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/about/news/1463/&quot;&gt;9.3 Beta1&lt;/a&gt;. 
Third, I learned the importance of controlling browser and server caching and revalidation when using dynamic content.
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#May_13_2013&quot;&gt;Continue Reading &amp;raquo;&lt;/a&gt;&lt;/p&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#May_13_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#May_13_2013</guid>
<category>news</category>
</item>

<item>
<title>
PgLife Is Now Live
</title>
<pubDate>Mon, 06 May 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;New Postgres users are often confused by the variety of activities in the Postgres community.  Even us old-timers can be overwhelmed in
monitoring the Postgres community.  To meet these two needs, I have created a website called &lt;a style=&quot;text-decoration: underline&quot; class=&quot;major&quot; href=&quot;http://pglife.momjian.us/&quot;&gt;PgLife&lt;/a&gt; which
dynamically displays the current activity in each of the community areas:  email, development, blogging, media, news, events, and
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://en.wikipedia.org/wiki/Internet_Relay_Chat&quot;&gt;IRC&lt;/a&gt; chat.  I am hopeful people will find this useful in understanding the
Postgres community, and in increasing their involvement.
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/May_6_2013#disqus_thread&quot;&gt;Post a Comment&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#May_6_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#May_6_2013</guid>
<category>news</category>
</item>

<item>
<title>
9.3 Release Notes Ready for Beta
</title>
<pubDate>Fri, 03 May 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;I have completed the &lt;a style=&quot;text-decoration: underline&quot; class=&quot;major&quot; href=&quot;http://www.postgresql.org/docs/devel/static/release-9-3.html&quot;&gt;9.3 release notes&lt;/a&gt; so they are ready for beta
release.  They will be regularly updated until 9.3 final.
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/May_3_2013#disqus_thread&quot;&gt;Post a Comment&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#May_3_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#May_3_2013</guid>
<category>news</category>
</item>

<item>
<title>
Starting on 9.3 Release Notes
</title>
<pubDate>Fri, 12 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;With our final 9.3 &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;https://commitfest.postgresql.org/action/commitfest_view?id=17&quot;&gt;commit-fest&lt;/a&gt; almost complete, and few
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;https://wiki.postgresql.org/wiki/PostgreSQL_9.3_Open_Items&quot;&gt;9.3 open items&lt;/a&gt;, I have been
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/message-id/3738.1365694054@sss.pgh.pa.us&quot;&gt;asked&lt;/a&gt; to start on the 9.3 release notes.  I have blogged about
this process in the past (&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2012.html#May_3_2012&quot;&gt;1&lt;/a&gt;,
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2012.html#May_10_2012&quot;&gt;2&lt;/a&gt;), so I will not bore you with the details.  I expect to be done in a
week.
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/April_12_2013#disqus_thread&quot;&gt;Post a Comment&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_12_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_12_2013</guid>
<category>news</category>
</item>

<item>
<title>
Matching Server and Client Constraints
</title>
<pubDate>Thu, 11 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;Postgres supports all the SQL-standard &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/ddl-constraints.html&quot;&gt;constraint types,&lt;/a&gt;
e.g. UNIQUE, CHECK.  These work fine at the server level:
&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;
&lt;/p&gt;&lt;pre class='quote_explicit'&gt;
CREATE TABLE ledger (id SERIAL, balance NUMERIC(10,2) &lt;strong&gt;CHECK (balance &gt; 0)&lt;/strong&gt;);
 
INSERT INTO ledger VALUES (DEFAULT, -2.00);
ERROR:  new row for relation &quot;ledger&quot; violates &lt;strong&gt;check constraint&lt;/strong&gt; &quot;ledger_balance_check&quot;
DETAIL:  Failing row contains (1, -2.00).
&lt;/pre&gt;
&lt;p&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_11_2013&quot;&gt;Continue Reading &amp;raquo;&lt;/a&gt;&lt;/p&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_11_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_11_2013</guid>
<category>tip</category>
</item>

<item>
<title>
Dynamic Columns
</title>
<pubDate>Wed, 10 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;SQL has never been good at handling dynamic columns &#8212; it can easily process tables with a fixed number of columns, but dynamic
column handling has always been a challenge.  (Dynamic columns are often used to implement user-defined fields.)  One approach has been to
define columns for every possible value that might be stored in a row;  this leads to sparse tables containing mostly NULL
values.  Because Postgres stores NULL values in a &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/storage-page-layout.html&quot;&gt;single
bit&lt;/a&gt;, there is little overhead to this approach.  However, it is hard to call these dynamic columns since every new column requires an
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/sql-altertable.html&quot;&gt;ALTER TABLE ... ADD COLUMN&lt;/a&gt; command.
&lt;/p&gt;
&lt;p&gt;Another approach is to use &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model&quot;&gt;entity/attribute/value&lt;/a&gt; layout,
where each value is stored in its own row.  This obviously increases storage requirements, has
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://stackoverflow.com/questions/5106335/how-to-design-a-database-for-user-defined-fields&quot;&gt;performance challenges&lt;/a&gt;, and adds
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://pratchev.blogspot.com/2010/07/refactoring-entity-attribute-value.html&quot;&gt;complexity&lt;/a&gt; to SQL queries.
&lt;/p&gt;
&lt;p&gt;Fortunately, Postgres has various options to efficiently handle dynamic columns.  The simplest solution is
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/arrays.html&quot;&gt;arrays&lt;/a&gt; which allow multiple values of the same data type to be stored in a
single field.  This assumes that the values are independent, or that their ordinal position in the array is sufficiently meaningful.
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_10_2013&quot;&gt;Continue Reading &amp;raquo;&lt;/a&gt;&lt;/p&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_10_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_10_2013</guid>
<category>tip</category>
</item>

<item>
<title>
Pg_Upgrade Now Handles Invalid Indexes
</title>
<pubDate>Tue, 09 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;In &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2012.html#December_14_2012&quot;&gt;December,&lt;/a&gt; I reported that a bug had been discovered in how
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/pgupgrade.html&quot;&gt;pg_upgrade&lt;/a&gt; handled invalid indexes, and that the next release of pg_upgrade
would throw an error if invalid indexes were found;  that release happened in
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/release-9-2-3.html&quot;&gt;February&lt;/a&gt;.  In an easily-overlooked development, last week's
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_8_2013_2&quot;&gt;security release&lt;/a&gt; changed
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/app-pgdump.html&quot;&gt;pg_dump&lt;/a&gt; so it now skips dumping invalid indexes.  This allows the most
recent version of pg_upgrade to upgrade clusters with invalid indexes, rather than throwing an error.
&lt;img src=&quot;http://momjian.us/main/img/blog/small_smile.png&quot;&gt;
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/April_9_2013#disqus_thread&quot;&gt;Post a Comment&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_9_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_9_2013</guid>
<category>pg upgrade</category>
</item>

<item>
<title>
Twenty-One Hours to Exploit
</title>
<pubDate>Mon, 08 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;You probably heard about the important Postgres &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/about/news/1456/&quot;&gt;security releases&lt;/a&gt;
(&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/support/security/faq/2013-04-04/&quot;&gt;FAQ&lt;/a&gt;) last week, but maybe you thought it was mostly a theoretical
threat.  Well, the &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;https://schemaverse.com/&quot;&gt;Schemaverse&lt;/a&gt; game author left a non-upgraded server open to the Internet to see how long
it would take to be infected &#8212; turns out it took a sobering
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://schemaverse.tumblr.com/post/47312545952/the-schemaverse-was-hacked&quot;&gt;21 hours&lt;/a&gt;.  Hopefully this gets everyone's attention on
the need to upgrade.
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/April_8_2013_2&quot;&gt;View or Post Comments&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_8_2013_2</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_8_2013_2</guid>
<category>news</category>
</item>

<item>
<title>
Partial Indexes
</title>
<pubDate>Mon, 08 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;Having covered &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_6_2013&quot;&gt;expression indexes&lt;/a&gt;, I want to cover another index feature
&#8212; &lt;a style=&quot;text-decoration: underline&quot; class=&quot;major&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/indexes-partial.html&quot;&gt;partial indexes&lt;/a&gt;.  Partial indexes allow you to create an index on
&lt;em&gt;part&lt;/em&gt; of a table.  Why would you want to do that?
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;index only frequently-accessed values, allowing smaller index files
  &lt;/li&gt;&lt;li&gt;avoid indexing common values, which are unlikely to be useful in an index
  &lt;/li&gt;&lt;li&gt;smaller index files allow faster index traversal and improve index caching
  &lt;/li&gt;&lt;li&gt;avoid &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2012.html#July_9_2012&quot;&gt;index insertion overhead&lt;/a&gt; for non-indexed values
  &lt;/li&gt;&lt;li&gt;constrain uniqueness to a subset of table rows
&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;People usually don't use expression or partial indexes initially, but there are certainly some use-cases that can only be solved with
these index features.
&lt;/p&gt;
&lt;a href=&quot;http://momjian.us/main/comment_item.html?/main/blogs/pgblog.html/April_8_2013&quot;&gt;View or Post Comments&lt;/a&gt;&lt;br /&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_8_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_8_2013</guid>
<category>tip</category>
</item>

<item>
<title>
Expression Indexes
</title>
<pubDate>Sat, 06 Apr 2013 12:00:00 -0400</pubDate>
<description>
&lt;p&gt;Having covered &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_1_2013&quot;&gt;virtual columns&lt;/a&gt; recently, I wanted to cover one additional
type of stored value, &lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://www.postgresql.org/docs/9.2/static/indexes-expressional.html&quot;&gt;expression indexes&lt;/a&gt;.  Unlike virtual
columns, which are computed on each access, expression indexes are stored in index files, allowing rapid access.  Let's look at some
examples, building on the &lt;em&gt;customer&lt;/em&gt; table and &lt;em&gt;fullname&lt;/em&gt; function created in my previous
&lt;a style=&quot;text-decoration: none&quot; class=&quot;txt2html&quot; href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_1_2013&quot;&gt;blog entry&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;&lt;blockquote&gt;
&lt;/p&gt;&lt;pre class='quote_explicit'&gt;
CREATE INDEX i_customer_lastname ON customer (&lt;strong&gt;lastname&lt;/strong&gt;);
 
CREATE INDEX i_customer_concat ON customer ((&lt;strong&gt;firstname || ' ' || lastname&lt;/strong&gt;));
 
CREATE INDEX i_customer_fullname ON customer (&lt;strong&gt;fullname(customer)&lt;/strong&gt;);
&lt;/pre&gt;
&lt;p&gt;&lt;/blockquote&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://momjian.us/main/blogs/pgblog/2013.html#April_6_2013&quot;&gt;Continue Reading &amp;raquo;&lt;/a&gt;&lt;/p&gt;
</description>
<link>http://momjian.us/main/blogs/pgblog/2013.html#April_6_2013</link>
<guid>http://momjian.us/main/blogs/pgblog/2013.html#April_6_2013</guid>
<category>tip</category>
</item>


</channel>

</rss>
