<?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.2</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>Fri, 20 Jan 2012 11:09:34 GMT</pubDate>

    <image>
        <url>http://www.postgresonline.com/journal/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Postgres OnLine Journal - 9.2 - 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>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>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>Improving speed of GIST indexes in PostgreSQL 9.2</title>
    <link>http://www.postgresonline.com/journal/archives/225-Improving-speed-of-GIST-indexes-in-PostgreSQL-9.2.html</link>
            <category>9.2</category>
            <category>editor note</category>
            <category>gis</category>
            <category>hstore</category>
            <category>intermediate</category>
            <category>ltree</category>
            <category>pgtrgm</category>
            <category>postgis</category>
            <category>postgresql versions</category>
            <category>tsearch</category>
    
    <comments>http://www.postgresonline.com/journal/archives/225-Improving-speed-of-GIST-indexes-in-PostgreSQL-9.2.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=225</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;This is about improvements to GIST indexes that I hope to see in PostgreSQL 9.2.  One is a patch for possible inclusion in PostgreSQL 9.2 called &lt;b&gt;&lt;a href=&quot;https://commitfest.postgresql.org/action/patch_view?id=631&quot; target=&quot;_blank&quot;&gt;SP-GiST, Space-Partitioned GiST&lt;/a&gt;&lt;/b&gt; created by 
&lt;a href=&quot;http://www.sigaev.ru/&quot; target=&quot;_blank&quot;&gt;Teodor Sigaev&lt;/a&gt; and &lt;a href=&quot;http://www.sai.msu.su/~megera/&quot; target=&quot;_blank&quot;&gt;Oleg Bartunov&lt;/a&gt; whose basic technique is described in &lt;a href=&quot;http://www.cs.purdue.edu/spgist/papers/W87R36P214137510.pdf&quot; target=&quot;_blank&quot;&gt;SP-GiST: An Extensible Database Index for Supporting Space Partitioning Trees&lt;/a&gt;. For those who don&#039;t know Teodor and Oleg,  they are the great fellows that brought us many other GiST and GIN goodnesses that many specialty PostgreSQL
extensions enjoy -- e.g. &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/&quot; target=&quot;_blank&quot;&gt;PostGIS&lt;/a&gt;, &lt;a href=&quot;http://developer.postgresql.org/pgdocs/postgres/pgtrgm.html&quot; target=&quot;_blank&quot;&gt;trigrams&lt;/a&gt;, &lt;a href=&quot;http://developer.postgresql.org/pgdocs/postgres/ltree.html&quot; target=&quot;_blank&quot;&gt;ltree&lt;/a&gt;, &lt;a href=&quot;http://pgsphere.projects.postgresql.org/&quot; target=&quot;_blank&quot;&gt;pgsphere&lt;/a&gt;, &lt;a href=&quot;http://developer.postgresql.org/pgdocs/postgres/hstore.html&quot; target=&quot;_blank&quot;&gt;hstore&lt;/a&gt;, &lt;a href=&quot;http://developer.postgresql.org/pgdocs/postgres/textsearch-intro.html&quot; target=&quot;_blank&quot;&gt;full-text search&lt;/a&gt; to name a few.&lt;/p&gt;
&lt;p&gt;Another is a recent one just committed by Alexander Korotkov which I just recently found out about on &lt;a href=&quot;http://www.postgis.org/pipermail/postgis-devel/2011-October/015561.html&quot; target=&quot;_blank&quot;&gt;New node splitting algorithm for GIST&lt;/a&gt; and admit I don&#039;t know enough about to judge. I have to admit to being very clueless when it comes to the innards of index implementations so don&#039;t ask me any technical details.  It&#039;s one of those short-comings among the trillion others I have that I have learned to accept will probably never change.&lt;/p&gt;
&lt;p&gt;What the SP-GIST patch will provide in terms of performance and speed was outlined in 
&lt;a href=&quot;http://www.pgcon.org/2011/schedule/events/309.en.html&quot; target=&quot;_blank&quot;&gt;PGCon 2011: SP-GiST - a new indexing infrastructure for PostgreSQL
Space-Partitioning trees in PostgreSQL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What it provides specifically for PostGIS is summarized in Paul&#039;s call for action noted below.  As a passionate user of PostGIS
,ltree, tsearch, and hstore, I&#039;m pretty excited about these patches and other GIST and general index enhancements and there potential use in GIST dependent extensions. I&#039;m hoping to see
these spring to life in PostgreSQL 9.2 and think it will help to further push the envelope of where PostgreSQL can go as a defacto platform 
for cutting-edge technology and scientific research.  I think one of PostgreSQL&#039;s greatest strength is its extensible index API.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.postgis.org/pipermail/postgis-users/2011-October/031078.html&quot; target=&quot;_blank&quot;&gt;Paul&#039;s PostGIS newsgroup note about seeking funding for faster GIST indexes&lt;/a&gt; , work done so far on SP-GIST and call for further action is rebroadcast in it&#039;s entirety here.
&lt;pre&gt;Thanks to the sponsorship of &lt;a href=&quot;http://www.mtu.edu&quot; target=&quot;_blank&quot;&gt;Michigan Technological University&lt;/a&gt;, we now
have 50% of the work complete. There is a working patch at the
commitfest &lt;a href=&quot;https://commitfest.postgresql.org/action/patch_view?id=631&quot; target=&quot;_blank&quot;&gt;https://commitfest.postgresql.org/action/patch_view?id=631&lt;/a&gt;
which provides quad-tree and kd-tree indexes.

However, there is a problem: unless the patch is reviewed and goes
through more QA/QC, it&#039;ll never get into PostgreSQL proper. In case
you think I am kidding: we had a patch for KNN searching ready for the
9.0 release, but it wasn&#039;t reviewed in time, so we had to wait all the
way through the 9.1 cycle to get it.

I am looking for sponsors in the $5K to $10K range to complete this
work. If you use PostgreSQL in your business, this is a chance to add
a basic capability that may help you in all kinds of ways you don&#039;t
expect. We&#039;re talking about faster geospatial indexes here, but this
facility will also radically speed any partitioned space. (For
example, the suffix-tree, which can search through URLs incredibly
fast. Another example, you can use a suffix tree to very efficiently
index geohash strings. Interesting.)

If you think there&#039;s a possibility, please contact me and I will send
you a prospectus you can take to your manager. Let&#039;s make this happen
folks!

Paul
&lt;/pre&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/225-Improving-speed-of-GIST-indexes-in-PostgreSQL-9.2.html#extended&quot;&gt;Continue reading &quot;Improving speed of GIST indexes in PostgreSQL 9.2&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 12 Oct 2011 18:24:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/225-guid.html</guid>
    <category>gist</category>
<category>index</category>
<category>postgis</category>
<category>postgresql 9.2</category>
<category>sp-gist</category>

</item>

</channel>
</rss>
