<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Postgres OnLine Journal - 9.0</title>
    <link>http://www.postgresonline.com/journal/</link>
    <description>an In depth look at the PostgreSQL open source database</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.4.1 - http://www.s9y.org/</generator>
    <pubDate>Sun, 17 Mar 2013 13:21:36 GMT</pubDate>

    <image>
        <url>http://www.postgresonline.com/journal/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Postgres OnLine Journal - 9.0 - an In depth look at the PostgreSQL open source database</title>
        <link>http://www.postgresonline.com/journal/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>PostGIS 2.0.3 for Windows x32 and x64 installers</title>
    <link>http://www.postgresonline.com/journal/archives/296-PostGIS-2.0.3-for-Windows-x32-and-x64-installers.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>9.3</category>
            <category>editor note</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/296-PostGIS-2.0.3-for-Windows-x32-and-x64-installers.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=296</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=296</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;We have all the setup executables for PostgreSQL 8.4-9.2 32-bit and
PostgreSQL 9.1-9.2 x64-bit for PostGIS 2.0.3.  We&#039;ll have the 9.0x64-bit
ones up shortly but do have the binaries.&lt;/p&gt;

&lt;p&gt;We are planning to release these to stackbuilder sometime next week, but
would like some feedback first with any issues people run into.&lt;/p&gt;

&lt;p&gt;One person already reported a serious bug in our original packaging which we
fixed. If you already installed 2.0.3 the x64-bit version or any of the 9.2
versions (both x32 and x64) that was not marked as -2.zip, -2.exe, you&#039;ll
want to reinstall. The 8.4-9.1 32-bits were not affected so just have a -1.&lt;/p&gt;

&lt;p&gt;Packages can be downloaded from: &lt;br /&gt;
&lt;a href=&quot;http://download.osgeo.org/postgis/windows&quot; target=&quot;_blank&quot;&gt;http://download.osgeo.org/postgis/windows&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;General details on what is included:&lt;/p&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://postgis.net/windows_downloads&quot; target=&quot;_blank&quot;&gt;http://postgis.net/windows_downloads&lt;/a&gt;
&lt;br /&gt;
&lt;p&gt;As always if you are installing for PostgreSQL x64 make sure to pick a zip
or installer with 64 in the name.  The unmarked or marked with 32 are just
for PostgreSQL 32-bit.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sun, 17 Mar 2013 01:48:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/296-guid.html</guid>
    <category>postgis</category>

</item>
<item>
    <title>Finding contiguous primary keys</title>
    <link>http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>intermediate</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=255</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=255</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;I recently had the need to figure out which ranges of my keys were contiguously numbered.  The related exercise is finding gaps in data as well.
Reasons might be because you need to determine what data did not get copied or what records got deleted.  There are lots of ways of accomplishing this, but this is the 
first that came to mind.  This approach uses window aggregates &lt;code&gt;lead&lt;/code&gt; function and common table expressions, so requires PostgreSQL 8.4+&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/255-Finding-contiguous-primary-keys.html#extended&quot;&gt;Continue reading &quot;Finding contiguous primary keys&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 08 Jun 2012 16:29:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/255-guid.html</guid>
    <category>common table expressions</category>
<category>cte</category>
<category>except</category>
<category>window</category>
<category>window functions</category>

</item>
<item>
    <title>Table Inheritance and the tableoid</title>
    <link>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html</link>
            <category>8.2</category>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=240</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=240</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;If I could name a number one feature I love most about PostgreSQL, it&#039;s the table inheritance feature which we described in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/59-How-to-Inherit,-Unherit-and-Merge-Inherit.html&quot; target=&quot;_blank&quot;&gt;How to Inherit and Uninherit&lt;/a&gt;. A lot of people use it for table partitioning using &lt;a href=&quot;http://www.postgresonline.com/journal/archives/27-Reading-PgAdmin-Graphical-Explain-Plans.html&quot; target=&quot;_blank&quot;&gt;CONSTRAINT EXCLUSION&lt;/a&gt;.  Aside from that, in combination with PostgreSQL schema search_path (customizable by user and/or database) it makes for a very flexible abstraction tool.  For example, for many of our web apps that service many departments where each department/client wants to keep a high level of autonomy, we have a schema set aside for each 
that inherits from a master template schema.  Each department site uses a different set of accounts with the primary schema being that of the department/client so that they are hitting their own  tables. &lt;/p&gt;
&lt;p&gt;Inheritance allows us to keep data separate,do roll-up reports if we need to, use the same application front-end, and yet allows us the ability to add new columns in just one place (the master template schema).  It is more flexible than other approaches because for example we may have a city organization that need to share tables, like for example a system loaded list of funding source shared across the agency.  We can set aside these shared tables in a separate schema visible to all or have some have their own copy they can change if they don&#039;t want to use the shared one.&lt;/p&gt;

&lt;p&gt;Every once in a while, we find ourselves needing to query the whole hierarchy and needing to know which table the results of the query are coming from. To help
solve that issue, we employ the use of the system column &lt;b&gt;tableoid&lt;/b&gt; which all user tables have. The tableoid is the the object id of a table.  PostgreSQL has many system columns that you have to explicitly select
and can&#039;t be accessed with a SELECT * with the tableoid being one of them.  These are: tableoid, cmax,cmin, xmin,xmax,ctid which are all described in &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-system-columns.html&quot; target=&quot;_blank&quot;&gt;System Columns&lt;/a&gt;.  The &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-inherit.html&quot; target=&quot;_blank&quot;&gt;PostgreSQL docs on inheritance&lt;/a&gt; have examples of using it, but we thought it worthwile to repeat the exercise since it&#039;s not that common knowledge and is unique enough feature of PostgreSQL that others coming from other relational databases, may miss the treat.  I&#039;ve often demonstrated
it to non-PostgreSQL users who use for example SQL Server or MySQL, and they literally fall out of their chair when I show the feature to them and its endless possibilities.&lt;/p&gt;   &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#extended&quot;&gt;Continue reading &quot;Table Inheritance and the tableoid&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 16 Jan 2012 05:52:54 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/240-guid.html</guid>
    
</item>
<item>
    <title>The wonders of Any Element</title>
    <link>http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>pl programming</category>
            <category>sql functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=239</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=239</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL has this interesting placeholder called &lt;em&gt;anyelement&lt;/em&gt; which it has had for a long time and its complement &lt;em&gt;anyarray&lt;/em&gt;.  They are used when you want to define a function that can handle many types arguments or can output many types of outputs.  They are particularly useful for defining aggregates, which we demonstrated in
&lt;a href=&quot;http://www.postgresonline.com/journal/archives/68-More-Aggregate-Fun-Whos-on-First-and-Whos-on-Last.html&quot; target=&quot;_blank&quot;&gt;Who&#039;s on First and Who&#039;s on Last&lt;/a&gt; and several other aggregate articles.&lt;/p&gt;
&lt;p&gt;Anyelement / anyarray can be used just as conveniently in other functions. The main gotcha is that when you pass in the first anyelement/anyarray all subsequent anyelement / anyarray must match the same data type as the first anyelement / anyarray. &lt;/p&gt;
 &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html#extended&quot;&gt;Continue reading &quot;The wonders of Any Element&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 08 Jan 2012 13:30:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/239-guid.html</guid>
    <category>anyelement</category>

</item>
<item>
    <title>Mail Merging using Hstore</title>
    <link>http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html</link>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>contrib spotlight</category>
            <category>hstore</category>
            <category>intermediate</category>
            <category>postgresql versions</category>
            <category>window functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=238</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=238</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;For those who aren&#039;t familiar with &lt;b&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/hstore.html&quot; target=&quot;_blank&quot;&gt;hstore&lt;/a&gt;&lt;/b&gt;, it&#039;s a key/value
storage type that is packaged as an extension or contrib in PostgreSQL 8.2+. In PostgreSQL 9.0 it got a little extra loving in several ways one of which was the introduction
of the hstore(record) casting function that converts a record to an hstore.  In this article, I&#039;ll demonstrate how you can use this new casting function to do very sleek mail merges right in the database. The only caveat is that it seems to only correctly name the keys if it is fed a real table or view. Derived queries such as aggregates etc get keys named f1, f2, etc.&lt;/p&gt;
&lt;p&gt;If you are on PostgreSQL 9.1 or above installing -- hstore is just a &lt;code&gt;CREATE EXTENSION hstore;&lt;/code&gt; sql command away. If you are on a lower version of PostgreSQL,
you can usually find the hstore.sql in share/contribs.  &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html#extended&quot;&gt;Continue reading &quot;Mail Merging using Hstore&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 28 Dec 2011 00:25:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/238-guid.html</guid>
    <category>contrib</category>
<category>hstore</category>
<category>window functions</category>

</item>
<item>
    <title>XPathing XML data with PostgreSQL</title>
    <link>http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>basics</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=232</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=232</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of my favorite tools and I think that of many folks working with GIS and other kinds of Multimedia is the GDAL/OGR suite.
Though I started using it to conquer GIS ETL activities, I found myself using it for problems that are inherently not GIS at all. I talked
about the GDAL OGR2OGR component a while ago in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/31-GDAL-OGR2OGR-for-Data-Loading.html&quot; target=&quot;_blank&quot;&gt;GDAL OGR2OGR for Data Loading&lt;/a&gt;
and this time I&#039;ll talk tangentially about its raster capabilities.  It is a fantastic tool for converting between various raster formats and applying various raster operations.
In PostGIS world the new 2.0 raster functionality puts an SQL wrapper around much of its power.  I&#039;m not going to talk about that though except as a fleeting comment to explore later (we&#039;ve got cool &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/RT_ST_MapAlgebraExpr2.html&quot; target=&quot;_blank&quot;&gt;2 band Map Algebra in PostGIS 2.0&lt;/a&gt; to flaunt its stuff).
So what does this have to do with XPathing XML data with PostgreSQL? Well that&#039;s what I&#039;m going to talk about what to do with machine generated data that comes at you in XML format.&lt;/p&gt;
&lt;p&gt;A lot of machine generated data is hitting us in an XML like form.  I talked about GPX data and navigating that in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/116-Loading-and-Processing-GPX-XML-files-using-PostgreSQL.html&quot; target=&quot;_blank&quot;&gt;Which by the way GDAL/OGR can load and export easily into/out of a PostGIS enabled database&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;GDAL exposes another kind of machine generated data in XML format which turns out to be very useful for all kinds of things.  This is &lt;a href=&quot;http://en.wikipedia.org/wiki/Exchangeable_image_file_format&quot; target=&quot;_blank&quot;&gt;Exchangeable image file format (EXIF) data&lt;/a&gt;. There are all kinds 
of random text information embedded in pictures and this varies depending on what camera is taking it.  Newer cameras like the ones you have built into your iphone or android 
embed location based information into them sometimes like where you were standing when you took the picture.  Most cameras these days embed the time the picture was taken.
This information is important because if you are taking electronic notes while you are snapping your pictures, it provides an easy way to match up your notes with the picture about the object.  So what does this EXIF info look like when you point GDAL at it? We&#039;ll see. &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html#extended&quot;&gt;Continue reading &quot;XPathing XML data with PostgreSQL&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 11 Nov 2011 03:57:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/232-guid.html</guid>
    <category>etl</category>
<category>raster</category>
<category>regex</category>
<category>regular expressions</category>
<category>unnest</category>
<category>xml</category>
<category>xpath</category>

</item>
<item>
    <title>How to create an n-column table really fast</title>
    <link>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=230</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=230</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Ever have the need to create a holding table say spreadsheet data with say 100 columns. You need to create a table to hold this stuff.   Or perhaps you were feeling in a sadist mood and wanted to abuse your PostgreSQL database to see how many columns you can create in a table of a specific data type. 
Here is a quick script to do it:&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;8.4+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_to_string&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;

&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;(string_agg&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;was&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;introduced&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0)&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Both variants will return output that looks like this: &lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;data_import&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;field1 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field2 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field3 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field4 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field5 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field6 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field7 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field8 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field9 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field10 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now if you want it to also execute because you are running it as part of an sql script, you could wrap it in an anonymous function.&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt; &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;-wrap&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;an&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;anonymous&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;run&lt;/span&gt;
 &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;requires&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;PostgreSQL&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;
DO language &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;plpgsql&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
$$
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;DECLARE&lt;/span&gt; var_sql &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; :&lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BEGIN&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;EXECUTE&lt;/span&gt; var_sql;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;END&lt;/span&gt;;
$$ ;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;
 
    </content:encoded>

    <pubDate>Tue, 01 Nov 2011 22:31:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/230-guid.html</guid>
    <category>aggregates</category>
<category>array</category>
<category>array_agg</category>
<category>string_agg</category>

</item>
<item>
    <title>Sweat the small stuff, it really matters</title>
    <link>http://www.postgresonline.com/journal/archives/223-Sweat-the-small-stuff,-it-really-matters.html</link>
            <category>8.2</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>basics</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/223-Sweat-the-small-stuff,-it-really-matters.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=223</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=223</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In most release notices, it&#039;s the big shiny sexy features that get all the glamor, but in reality on day to day use
it&#039;s the small usability enhancements that make the most difference.  I&#039;m reminded about this now that I&#039;m working
on upgrade scripts and extensions for PostGIS.  There are a couple of new features that make application upgrades easier that I
regret not having in older versions of PostgreSQL we support and additional ones I had in other databases that I find lacking in PostgreSQL. PostgreSQL 8.2 for example brought us &lt;code&gt;DROP IF EXISTS ...&lt;/code&gt;
and all I can say is thank goodness we dropped support of prior versions of PostgreSQL in PostGIS 1.4 otherwise developing upgrade scripts would have been more of a nightmare.
PostgreSQL 8.4 introduced the ability to add additional columns to a view using &lt;code&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.4/static/sql-createview.html&quot; target=&quot;_blank&quot;&gt;CREATE OR REPLACE VIEW&lt;/a&gt;&lt;/code&gt; as
long as those columns were at the end of the view which Gabrielle Roth demonstrates an example of in &lt;a href=&quot;http://www.baconandtech.com/2011/10/04/this-weeks-find-create-or-replace-view/&quot; target=&quot;_blank&quot;&gt;This week’s find: CREATE OR REPLACE VIEW&lt;/a&gt;
If you were a MySQL user or application developer not having such features would be one reason to frown on PostgreSQL
and MySQL users and other database converts still have reasons to frown for lack of usability features they had 
in their other database that they feel naked without in PostgreSQL.&lt;/p&gt;

&lt;p&gt;In 9.1 we got two new DDL commands not much talked about that I am very excited about.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/interactive/sql-createtable.html&quot; target=&quot;_blank&quot;&gt;CREATE TABLE .. IF NOT EXISTS&lt;/a&gt;&lt;/code&gt;.  I can&#039;t tell you how many times I&#039;ve heard MySQL users whine about the lack of this in PostgreSQL
and I felt their pain.  It would be really nice to have this feature for other things such as TYPES or even possibly a CREATE OR REPLACE TYPE which would allow
some alteration of types like adding attributes at the end.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/sql-altertype.html&quot; target=&quot;-blank&quot;&gt;ALTER TYPE ..[ADD ATTRIBUTE] [RENAME ATTRIBUTE] [ADD VALUE]&lt;/a&gt;.
The [ADD VALUE] is a clause specific to ENUM types which allows you to add new enum values before or after an existing.  The lack of that feature
in prior versions was the major reason I stayed away from enums.&lt;/li&gt;
&lt;li&gt;And of cause my favorite CREATE EXTENSTION  ALTER EXTENSION family which admittedly do get talked about a lot more often and which I&#039;ll discuss more in a later
article.&lt;/li&gt;&lt;/ul&gt;. 

&lt;p&gt;I know it sounds like I&#039;m complaining.  That&#039;s because I am.  Honestly though, I think the first step to caring about something is really taking notice of its
flaws and wanting to change them.  The strength of an open source project is the ease with which it allows its developers and users to have a great impact on its direction.  This is something I do think PostgreSQL excels much much better than most open source projects.  I find a ton of flaws in PostGIS I&#039;d like to change and have and I am greatful that PostGIS, like PostgreSQL is not resistant to change if the community wants it. If you are going to take notice of flaws in other products without admitting to your own or admitting that some things are easier in other products and learning from them, then you are a hypocrite or living in a closet.  Now getting back to my complaining.  Things I miss in PostgreSQL that I had in others which I&#039;m sure I&#039;m not alone.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Being able to change a table column type of a table column that is used in a VIEW and have PostgreSQL just correct the type in the view
or allow me the option to change it later.  This is something we had in SQL Server which Leo whines about often.  Actually Leo&#039;s whining is more annoying than
the actual problem itself. The notice is at least very descriptive which is more than I can say for other databases.&lt;/li&gt;
	&lt;li&gt;Being able to reorder columns in a table. Again something fairly trivial to do in SQL Server and MySQL but not possible in PostgreSQL.&lt;/li&gt;
&lt;/ul&gt; 
    </content:encoded>

    <pubDate>Wed, 05 Oct 2011 09:15:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/223-guid.html</guid>
    
</item>
<item>
    <title>Bulk Revoke of Permissions for Specific Group/User role</title>
    <link>http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>intermediate</category>
            <category>mysql</category>
            <category>q&amp;a</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=221</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=221</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;div style=&#039;background-color:yellow&#039;&gt;&lt;p&gt;&lt;b&gt;UPDATE&lt;/b&gt; Turns out there is a simpler way of getting rid of roles that have explicit permissions to objects as Tom Lane pointed out in the comments.
&lt;pre&gt;&lt;code&gt;DROP OWNED BY some_role;&lt;/code&gt;&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;Will drop the permissions to objects a user has rights to even if they don&#039;t own the objects.  Of course this needs to be applied with caution since it will drop tables
and other things you don&#039;t want necessarily dropped.  So it is best to first run a:
&lt;br /&gt;
&lt;code&gt;REASSIGN OWNED BY some_role TO new_role;&lt;/code&gt;
And then run the DROP OWNED BY.  &lt;br /&gt;
The &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/sql-reassign-owned.html&quot; target=&quot;_blank&quot;&gt;REASSIGN OWNED BY&lt;/a&gt; which is what we did originally is not sufficient since it doesn&#039;t drop the permissions or reassign
them as we assumed it would. This is noted in the docs.&lt;br /&gt;
And then you will be allowed to 
&lt;code&gt;DROP ROLE some_role&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;One of the things that is still tricky in PostgreSQL is permission management. Even though 9.0 brought us default privileges and the like, these permissions aren&#039;t
retroactive so still a pain to deal with if you already have objects defined in your database.&lt;/p&gt;

&lt;p&gt;One of the annoyances we come across with is deleting roles.  Lets say you have a role and it has explicit permissions to an object.
PostgreSQL won&#039;t allow you to delete this role if it owns objects or has explicit permissions to objects.  In order to delete it seems you have 
to go in and clear out all those permissions.  To help with that -- we wrote a quickie script that will generate a script to revoke all permissions on objects
for a specific role.  It looks like this:&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/221-Bulk-Revoke-of-Permissions-for-Specific-GroupUser-role.html#extended&quot;&gt;Continue reading &quot;Bulk Revoke of Permissions for Specific Group/User role&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 26 Sep 2011 00:11:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/221-guid.html</guid>
    <category>postgresql 8.4</category>
<category>regex</category>
<category>regular expressions</category>

</item>
<item>
    <title>Using PgAdmin PLPgSQL Debugger</title>
    <link>http://www.postgresonline.com/journal/archives/214-Using-PgAdmin-PLPgSQL-Debugger.html</link>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>basics</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>pgadmin</category>
            <category>plpgsql</category>
    
    <comments>http://www.postgresonline.com/journal/archives/214-Using-PgAdmin-PLPgSQL-Debugger.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=214</wfw:comment>

    <slash:comments>9</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=214</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;I&#039;m one of those old-fashioned folks that debugs with print lines and raise notices.  They&#039;re nice.
They always work, you can put clock time stops in there and don&#039;t require any fancy configuration.  
At a certain point you do have to pull out a real debugger to see what is going on.  This often
happens when your one-liners are no longer good enough and now you have to write 20 liners of plpgsql code.&lt;/p&gt;

&lt;p&gt;Such is the case with geocoding and the &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/Extras.html#Tiger_Geocoder&quot; target=&quot;_blank&quot;&gt;PostGIS tiger geocoder&lt;/a&gt; specifically.  Lots of interest has revived
on that with people submitting bug reports and we&#039;ve got paying clients in need of a fairly easy and speedy drop-in geocoder
that can be molded to handle such things as road way locations, badly mis-spelled real estate data, or just simply
to get rid of their dependency on Google, Yahoo, MapQuest, ESRI and other online or pricey geocoding tools.
So I thought I&#039;d take this opportunity to supplement our old-fashioned debugging with plpgsqldebugger goodness.
In this article, we&#039;ll show you how to configure the plpgsql debugger integrated in PgAdmin and run with it.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/214-Using-PgAdmin-PLPgSQL-Debugger.html#extended&quot;&gt;Continue reading &quot;Using PgAdmin PLPgSQL Debugger&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 27 Jun 2011 01:49:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/214-guid.html</guid>
    <category>debugging</category>
<category>pgadmin</category>

</item>
<item>
    <title>State of PostGIS and PostGIS Windows binaries for 9.1 9.0 and 8.4</title>
    <link>http://www.postgresonline.com/journal/archives/213-State-of-PostGIS-and-PostGIS-Windows-binaries-for-9.1-9.0-and-8.4.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>new in postgresql</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/213-State-of-PostGIS-and-PostGIS-Windows-binaries-for-9.1-9.0-and-8.4.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=213</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=213</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostGIS 2.0.0 has inched a lot closer to completion.  This past week, &lt;a href=&quot;http://blog.cleverelephant.ca/&quot; target=&quot;_blank&quot;&gt;Paul&lt;/a&gt; enabled his gserialization work which changed the on disk-format of PostGIS and in return I think we&#039;ll have a much better platform to grow on.  With this change we now have the 3D index and bounding box bindings in place.  Say hello to the &lt;b&gt;&amp;&amp;&amp;amp;&lt;/b&gt; operator which is like &lt;b&gt;&amp;&amp;amp;&lt;/b&gt;, but is 3D aware and comes with its own companion 3D spatial indexes.  This will allow you to do true 3D bounding box searches with any of the new 2.5/3D geometries we have in place for PostGIS 2.0.0.  We are still noodling out the semantics of boxes.  Read Paul&#039;s call for action on the &lt;a href=&quot;http://www.postgis.org/pipermail/postgis-devel/2011-June/013654.html&quot; target=&quot;_blank&quot;&gt;The Box Plan?&lt;/a&gt;, if you are interested. PostgreSQL 8.4 is the lowest supported version for PostGIS 2.0.0. It took a bit of squabbling between PSC members to make that decision, but I put my foot down and I think in the end was for the best to allow us to use new features, less platforms to test,  and get rid of some unnecessary code. &lt;/p&gt;

&lt;h4&gt;PostGIS Windows 32-bit Experimental builds fresh off the presses&lt;/h4&gt;
&lt;p&gt;With all these changes, if you are running an earlier alpha release of PostGIS 2.0.0, you&#039;ll need to do a dump restore since the on disk format is now changed.&lt;/p&gt;

&lt;p&gt;If you are on windows and want to give some of this all a test drive, you can download one of our &lt;a href=&quot;http://postgis.net/windows_downloads#PostGIS_2_0_0&quot; target=&quot;_blank&quot;&gt;PostGIS 2.0.0 Windows experimental builds&lt;/a&gt;. We still only have 32-bit builds.  We have builds
for PostgreSQL 8.4, PostgreSQL 9.0, and PostgreSQL 9.1 beta 2.  The problems we faced in PostgreSQL 9.1 beta 1 were resolved in beta 2 so that most regress tests past except some minor ones involving stupid things like difference in line number marking of errors.  Complement your PostgreSQL 9.1 beta 2 meal with a yummy large helping of PostGIS 2.0.0 goodness.&lt;/p&gt;
 &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/213-State-of-PostGIS-and-PostGIS-Windows-binaries-for-9.1-9.0-and-8.4.html#extended&quot;&gt;Continue reading &quot;State of PostGIS and PostGIS Windows binaries for 9.1 9.0 and 8.4&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 16 Jun 2011 12:34:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/213-guid.html</guid>
    <category>postgis</category>
<category>postgresql 9.1</category>

</item>
<item>
    <title>Manually setting table column statistics</title>
    <link>http://www.postgresonline.com/journal/archives/209-Manually-setting-table-column-statistics.html</link>
            <category>9.0</category>
            <category>9.1</category>
            <category>intermediate</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/209-Manually-setting-table-column-statistics.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=209</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=209</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;h5&gt;Question: How do you deal with bad stat counts?&lt;/h5&gt; 
&lt;p&gt;You have a large table and the default planner stats collector underestimates distinct counts of a critical query column thus resulting in much less than optimal query plans. 
How can you manually set this?&lt;/p&gt;
&lt;p&gt;PostgreSQL 9.0 introduced ability to set two settings on table columns: &lt;em&gt;n_distinct&lt;/em&gt; and &lt;em&gt;n_distinct_inherited&lt;/em&gt; which are described a bit in &lt;a href=&quot;http://www.postgresql.org/docs/current/static/sql-altertable.html&quot; target=&quot;_blank&quot;&gt;ALTER TABLE help&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;b&gt;n_distinct&lt;/b&gt; is the estimated number of distinct values for that column
with -1 or any negative number representing a percentage of estimated table count instead of a true count. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;n_distinct_inherited&lt;/b&gt; is a setting useful for parent tables that denotes the estimated distinct count sum of all a parent&#039;s child tables.&lt;/p&gt;
&lt;p&gt;By tweaking these settings when they are less than optimal, you can influence the query planner to produce better plans. Why this is necessary is mostly for large
tables where the stat collector will not query the whole table to determine stats.  The stats collector generally queries at most 10-30% of a table.&lt;/p&gt;


&lt;h5&gt;Determine If you need to set counts&lt;/h5&gt;
&lt;p&gt;It&#039;s always nice to have the stat collector do all these things for you especially if you have a table that is constantly updated and distinct counts can fluctuate a lot. 
For static tables you may just want to set them manually.
So how do you know whether you should bother or not.  Well you can check the current values
the stats collector has with this query:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;determine&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;your&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;stats&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;are&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;fine&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;estimates&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;what&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;you&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;know&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;they&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;are&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; tablename, schemaname, attname &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; colname, n_distinct,
&lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_to_string&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;most_common_vals, E&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; common_vals,
&lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_to_string&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;most_common_freqs, E&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; dist_freq
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; pg_stats
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; tablename &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;table_of_interest&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BY&lt;/span&gt; schemaname, tablename, attname;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You would then compare with your actuals &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;DISTINCT&lt;/span&gt; column_of_interest&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; table_of_interest;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will give you the current count.&lt;/p&gt;

&lt;h5&gt;Setting n_distinct and n_distinct_inherited&lt;/h5&gt;
You may want to bump this up or down when you set the value.  Next to set the column distinct count stats you would do something like below
replacing 50 with the count you computed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;stats&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;(non&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;tables&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;TABLE&lt;/span&gt; table_of_interest
   &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;COLUMN&lt;/span&gt; column_of_interest
   &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SET&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;n_distinct&lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;;
   
&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;stats&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;(parent&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;tables&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;an&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;inheritance&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;hierarchy&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;TABLE&lt;/span&gt; table_of_interest
   &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;COLUMN&lt;/span&gt; column_of_interest
   &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SET&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;n_distinct_inherited&lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Sun, 22 May 2011 10:06:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/209-guid.html</guid>
    
</item>
<item>
    <title>Difference Between CURRENT_TIMESTAMP and clock_timestamp() and how to exploit them</title>
    <link>http://www.postgresonline.com/journal/archives/207-Difference-Between-CURRENT_TIMESTAMP-and-clock_timestamp-and-how-to-exploit-them.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>cte</category>
            <category>db2</category>
            <category>firebird</category>
            <category>intermediate</category>
            <category>mysql</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
            <category>sql server</category>
            <category>window functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/207-Difference-Between-CURRENT_TIMESTAMP-and-clock_timestamp-and-how-to-exploit-them.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=207</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=207</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;b&gt;Question:&lt;/b&gt; &lt;p&gt;What is the difference between CURRENT_TIMESTAMP and clock_timestamp()&lt;/p&gt;

&lt;b&gt;Answer:&lt;/b&gt; &lt;p&gt;CURRENT_TIMESTAMP is an ANSI-SQL Standard variable you will find in many relational databases including PostgreSQL, SQL Server, Firebird, IBM DB2 and MySQL to name a few
that records the start of the transaction.  The important thing to keep in mind about it is there is only one entry per transaction so if you have a long running transaction,
you won&#039;t be seeing it changing as you go along.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;clock_timestamp()&lt;/b&gt; is a PostgreSQL function that always returns the current clock&#039;s timestamp.  I don&#039;t think I&#039;m alone in using it for doing simple benchmarking and other things
where for example I need to record the timings of each part of a function within the function using pedestrian RAISE NOTICE debug print statements.&lt;/p&gt;

&lt;p&gt;There is another cool way I like using it, and that is for a batch of records each with an expensive function call, benchmarking how long it takes to process each record.
One of the things I&#039;m working on is improving the speed of the &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/Extras.html#Tiger_Geocoder&quot; target=&quot;_blank&quot;&gt;tiger_geocoder&lt;/a&gt; packaged in PostGIS 2.0.  The first root of attack seemed to me would be the normalize_address function
which I was noticing was taking anywhere from 10% to 50% of my time in the geocode process. That&#039;s a ton of time if you are trying to batch geocode a ton of records. The thing is 
the function is very particular to how badly formed the address is so a whole batch could be held up by one bad apple and since the batch doesn&#039;t return until all are processed, it makes
the whole thing seem to take a while.&lt;/p&gt;

&lt;p&gt;So rather than looping thru each, I thought it would be cool if I could run the batch, but for each record have it tell me how long it took to process relative to the rest so I could get
a sense of what a problem address looks like. So I wrote this query:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WITH&lt;/span&gt; ctbenchmark
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt;  &lt;span class=&quot;syntax-OPERATOR&quot;&gt;*&lt;/span&gt;, 
        the_time &lt;span class=&quot;syntax-OPERATOR&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;COALESCE&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-FUNCTION&quot;&gt;lag&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;the_time&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;OVER&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BY&lt;/span&gt; the_time&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;, &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;CURRENT_TIMESTAMP&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; process_time, 
            the_time &lt;span class=&quot;syntax-OPERATOR&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;CURRENT_TIMESTAMP&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; diff_from_start
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; address_1, city, state, zip, 
    &lt;span class=&quot;syntax-FUNCTION&quot;&gt;pprint_addy&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-FUNCTION&quot;&gt;normalize_address&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD2&quot;&gt;coalesce&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;address_1,&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;coalesce&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;city &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;,&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; state &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; zip&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; pp_addr, 
        &lt;span class=&quot;syntax-FUNCTION&quot;&gt;clock_timestamp&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; the_time
       &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; testgeocode  LIMIT &lt;span class=&quot;syntax-DIGIT&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; foo &lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; ctbenchmark
       &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; process_time &lt;span class=&quot;syntax-OPERATOR&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;00:00:00.016&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;interval;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which returned an output something like this:

&lt;pre&gt;
        address_1 |    city    | state |  zip   |     pp_addr  |          the_time          | process_time | diff_from_start
------------------+------------+-------+------- +-------------------------------------------+--------------+------------------
 48 MAIN ST ..    | S..        | MA    | 021..  | 48 MAIN ..   | 2011-05-10 03:24:43.078-04 | 00:00:00.032 | 00:00:00.032
 15 ...           |            | MA    | 018... | 15 GREN...   | 2011-05-10 03:24:50.796-04 | 00:00:00.031 | 00:00:07.75&lt;/pre&gt;  
    </content:encoded>

    <pubDate>Tue, 10 May 2011 04:23:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/207-guid.html</guid>
    
</item>
<item>
    <title>An Almost Idiot's Guide to Installing  PostGIS 1.5 on PostgreSQL 9.0 via Yum</title>
    <link>http://www.postgresonline.com/journal/archives/204-An-Almost-Idiots-Guide-to-Installing-PostGIS-1.5-on-PostgreSQL-9.0-via-Yum.html</link>
            <category>9.0</category>
            <category>basics</category>
            <category>beginner</category>
            <category>postgis</category>
            <category>postgresql versions</category>
            <category>yum</category>
    
    <comments>http://www.postgresonline.com/journal/archives/204-An-Almost-Idiots-Guide-to-Installing-PostGIS-1.5-on-PostgreSQL-9.0-via-Yum.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=204</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=204</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In the past I have always chosen to compile my own PostGIS  because the GEOS library that came with the regular PostgreSQL yum install, was a bit antiquated. 
This has changed, so this time around I figured I&#039;d give it a go at using the Yum repository 1.5.2 release of PostGIS available via &lt;a href=&quot;http://www.pgrpms.org/news-packagelist.php&quot; target=&quot;_blank&quot;&gt;Yum Package List&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Before you can follow these directions, make sure you have your PostgreSQL 9.0 setup via our &lt;a href=&quot;http://www.postgresonline.com/journal/archives/203-postgresql90-yum.html&quot; target=&quot;_blank&quot;&gt;An almost idiot&#039;s guide to Install PostgreSQL 9.0 with Yum&lt;/a&gt;.&lt;/p&gt;

&lt;div style=&#039;background-color:yellow&#039;&gt;&lt;a href=&quot;http://www.amazon.com/PostGIS-Action-Regina-Obe/dp/1935182269?&amp;camp=213293&amp;linkCode=wey&amp;tag=postgisus-20&amp;creative=388373&quot; target=&quot;_blank&quot;&gt;PostGIS in Action&lt;/a&gt; has started shipping from Amazon and we already have 3 positive reviews.  We are hoping to write another book sometime soon, but haven&#039;t decided yet on the topic.  Will definitely have something to do with databases and probably a lot of PostgreSQL in it.&lt;/div&gt;
 &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/204-An-Almost-Idiots-Guide-to-Installing-PostGIS-1.5-on-PostgreSQL-9.0-via-Yum.html#extended&quot;&gt;Continue reading &quot;An Almost Idiot&#039;s Guide to Installing  PostGIS 1.5 on PostgreSQL 9.0 via Yum&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 21 Apr 2011 02:02:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/204-guid.html</guid>
    <category>postgis</category>
<category>postgresql 9.0</category>
<category>yum</category>

</item>
<item>
    <title>An almost idiot's guide to Install PostgreSQL 9.0 with Yum</title>
    <link>http://www.postgresonline.com/journal/archives/203-An-almost-idiots-guide-to-Install-PostgreSQL-9.0-with-Yum.html</link>
            <category>9.0</category>
            <category>basics</category>
            <category>beginner</category>
            <category>postgresql versions</category>
            <category>yum</category>
    
    <comments>http://www.postgresonline.com/journal/archives/203-An-almost-idiots-guide-to-Install-PostgreSQL-9.0-with-Yum.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=203</wfw:comment>

    <slash:comments>10</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=203</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In this exercise, we&#039;ll go thru installing PostgreSQL 9.0 on a Cent OS 5.5 32-bit box. This I&#039;m testing on a GoGrid Cloud server so I can do parallel benchmarks between my windows GoGrid
and Linux GoGrid server.&lt;/p&gt;

&lt;h4&gt;Upgrading from PostgreSQL 8.* to PostgreSQL 9.0&lt;/h4&gt;
&lt;p&gt;If you are upgrading from a PostgreSQL 8.4 to PostgreSQL 9.0, please refer to Devrim&#039;s article: 
&lt;a href=&quot;http://people.planetpostgresql.org/devrim/index.php?/archives/50-Upgrading-from-8.4-to-9.0-on-Fedora-Red-Hat-CentOS-using-RPMs.html&quot; target=&quot;_blank&quot;&gt;Upgrading from 8.4 to 9.0 on Fedora / Red Hat / CentOS using RPMs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For the rest of this article, we&#039;ll go over configuring your yum to use the PostgreSQL PGDG Yum repository managed by Devrim Gunduz, which has the latest and greatest of 
9.0 as well as the 9.1 latest development release. We&#039;ll also demonstrate how to have two instances of PostgreSQL running so you can experiment with the new features of
PostgreSQL 9.1 while reminiscing about the soon to be old-hat features of PostgreSQL 9.0.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/203-An-almost-idiots-guide-to-Install-PostgreSQL-9.0-with-Yum.html#extended&quot;&gt;Continue reading &quot;An almost idiot&#039;s guide to Install PostgreSQL 9.0 with Yum&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 18 Apr 2011 04:32:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/203-guid.html</guid>
    <category>yum cloud</category>

</item>

</channel>
</rss>