<?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 - intermediate</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>Wed, 25 Jan 2012 21:01:44 GMT</pubDate>

    <image>
        <url>http://www.postgresonline.com/journal/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Postgres OnLine Journal - intermediate - 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>True or False every which way</title>
    <link>http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=241</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL has aggregate functions called &lt;b&gt;bool_and&lt;/b&gt; and &lt;b&gt;bool_or&lt;/b&gt; which it&#039;s had for as far back as I can remember.
What do they do? given rows of premises (things that resolve to booleans), &lt;em&gt;bool_and&lt;/em&gt; will return true if all of the premises are true.  Similarly &lt;b&gt;bool_or&lt;/b&gt;
will return true if any of the premises in the set of rows is true.  What if however your boolean expressions are not in rows, but instead passed in
as a sequence of arbitrary statements of questionable fact.  We want a function like bool_or or bool_and that takes an arbitrary number of boolean arguments.  Are there functions
that fit the bill.  Indeed there are, but they don&#039;t scream out and say &lt;em&gt;I work with booleans&lt;/em&gt; because they fit into a class of function we
discussed in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html&quot; target=&quot;_blank&quot;&gt;The wonders of Any Element&lt;/a&gt; and that also happen to be &lt;a href=&quot;http://www.postgresonline.com/journal/archives/211-Variadic-Functions-in-PostgreSQL.html&quot; target=&quot;_blank&quot;&gt;variadic&lt;/a&gt; functions.
These are none other than
&lt;b&gt;greatest&lt;/b&gt; and &lt;b&gt;least&lt;/b&gt; and they are old timer functions that you can find in most versions of PostgreSQL.  We&#039;ll demonstrate how to use
all 4 with booleans in this article. It must be said that greatest and least are much more useful when applied to other data types like dates
and numbers, but we were amused at the parallel with booleans.&lt;/p&gt;

&lt;div style=&#039;background-color:yellow&#039;&gt;&lt;b&gt;Side note:&lt;/b&gt; we&#039;ve started to write our book on PostgreSQL that will be published by O&#039;Reilly.  We hope to finish this book within the next 5-7 months but have preliminary e-Book drafts before then for early purchasers to scan.
The focus of the book will be PostgreSQL 9.1 with some highlights the upcoming PostgreSQL 9.2.  Of course oldie but goodie topics are  in the book too. It&#039;s a thrill to be writing again.&lt;/div&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/241-True-or-False-every-which-way.html#extended&quot;&gt;Continue reading &quot;True or False every which way&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 25 Jan 2012 15:55:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/241-guid.html</guid>
    <category>aggregates</category>
<category>anyelement</category>
<category>bool_and</category>
<category>bool_or</category>
<category>greatst</category>
<category>least</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>What objects are in a PostgreSQL installed extension</title>
    <link>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html</link>
            <category>9.1</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=231</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;As mentioned in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html&quot;&gt;Lessons Learned Packaging PostGIS extensions&lt;/a&gt;, I am working on PostGIS 2.0.0 extension packaging.  One of the things I wanted to know was what objects, types, functions etc were installed by my extension.  The new packaging system allows for cataloging this relatively easily, but I couldn&#039;t find a function or view for this  and didn&#039;t see one mentioned in the manual, so I created this query which seems to work pretty well as far as I can tell.  The basic idea being that any object that an extension depends on 
that is not an extension is part of the extension package.&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; c.relname &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_type, 
    &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-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proname,typ.typname, cd.relname, op.oprname, 
        &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CAST(&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; cs.typname &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;AS&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; ct.typname &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;, opcname, opfname&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_name,
    &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-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proisagg,false&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; is_agg, &lt;span class=&quot;syntax-FUNCTION&quot;&gt;oidvectortypes&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proargtypes&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; arg_types
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; pg_depend &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; d &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_extension &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; e
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; d.refobjid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; e.oid &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; c &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt;
        c.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.classid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_proc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; typ &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; typ.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; cd &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; cd.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_operator &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; op &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; op.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_cast &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ca &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; cs &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.castsource &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; cs.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ct &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.casttarget &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; ct.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opclass &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; oc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; oc.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opfamily &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; ofa &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ofa.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; d.deptype &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;e&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;and&lt;/span&gt; e.extname &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;postgis&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; item_type, item_name;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The output looks like: &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#extended&quot;&gt;Continue reading &quot;What objects are in a PostgreSQL installed extension&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 03 Nov 2011 16:55:13 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/231-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>PostgreSQL Array: The ANY and Contains trick</title>
    <link>http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=228</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the main features I love about PostgreSQL is its array support.  This is a 
feature you won&#039;t find in most relational databases, and even databases that support some variant
of it, don&#039;t allow you to use it as easily.  It is one of the features that makes building
aggregate functions wicked easy in PostgreSQL with no messy compiling required.  
Aside from building aggregate functions, it has some other common day uses.  
In this article, I&#039;ll cover two common ways we use them which I will refer to as the &lt;b&gt;ANY&lt;/b&gt;
and &lt;b&gt;Contains&lt;/b&gt; tricks.&lt;/p&gt;

&lt;p&gt;I like to think of this approach as &lt;a href=&quot;http://blog.gigaspaces.com/2010/07/15/yesql-an-overview-of-the-various-query-semantics-in-the-post-only-sql-world/&quot; target=&quot;_blank&quot;&gt;YeSQL programming style&lt;/a&gt;: how SQL can be augmented by more complex data types and index retrieval mechanisms.
 Arrays and many other data types (spatial types, keyvalue (hstore), ltree etc) are far from relational structures, yet we can query them easily with SQL and can even relate them.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/228-PostgreSQL-Array-The-ANY-and-Contains-trick.html#extended&quot;&gt;Continue reading &quot;PostgreSQL Array: The ANY and Contains trick&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 27 Oct 2011 01:09:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/228-guid.html</guid>
    <category>aggregates</category>
<category>all</category>
<category>array</category>
<category>string_agg</category>
<category>yesql</category>

</item>
<item>
    <title>Lessons learned Packaging PostGIS Extensions: Part 1</title>
    <link>http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=224</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In prior articles we talked about the new &lt;a href=&quot;http://www.postgresonline.com/journal/archives/216-PostgreSQL-9.1-Exploring-Extensions.html&quot; target=&quot;_blank&quot;&gt;PostgreSQL 9.1 extension model&lt;/a&gt;
and upcoming &lt;a href=&quot;http://www.postgresonline.com/journal/archives/220-FOSS4G-2011-PostGIS-the-new-stuf.html&quot; target=&quot;_blank&quot;&gt;PostGIS 2.0 extensions&lt;/a&gt; which we have experimental builds of so far.
In this article and other&#039;s to follow, we shall provide a documentary of our venture into this new extensions world.  We&#039;ll discuss some of the obstacles we had with building 
extensions, lessons learned, and foolishness exposed, with the hope that others can learn from our experience.&lt;/p&gt;
&lt;p&gt;First off, the upcoming PostGIS 2.0 extensions will be packaged as at least two extensions -- &lt;b&gt;postgis&lt;/b&gt; which will contain both PostGIS geometry/geography types, functions, meta views and tables as well as raster type and associated functions and tables.  Topology support, while a part of upcoming PostGIS 2.0, will be packaged as a separate extension called &lt;b&gt;postgis_topology&lt;/b&gt;.  The main reason for breaking topology out as a separate extension is that it is always stored in a schema called &lt;b&gt;topology&lt;/b&gt; and is not relocatable
to another schema.  The way the current extension model works, all the parts of your extension should live in the same schema. Later we plan to package tiger geocoder as an extension, but this one probably makes more sense to live on &lt;a href=&quot;http://pgxn.org/&quot; target=&quot;_blank&quot;&gt;http://pgxn.org/&lt;/a&gt; since it is only of interest to United States users,
, is purely plpgsql with dependency on PostGIS, and we had beefed it up as part of a consulting contract for a company running PostGIS 1.5. It&#039;s the only piece documented in PostGIS 2.0 that works on 1.5 as well (aside from the tiger toplogy loader which has dependency on toplogy), although it has always lived as an extra in the PostGIS code base.&lt;/p&gt;
&lt;p&gt;We&#039;ll probably package postgis_legacy_functions as an extension too for those people who badly need those 500 alias functions I chucked.&lt;/p&gt;
&lt;p&gt;We mentioned in our prior article that we ran into some issues with how our extension worked -- e.g. topology referencing the postgis extension.  Most of these turned out just to be ignorance on my part as to how the different pieces fit together and I&#039;ll elaborate on these. &lt;/p&gt;
&lt;p&gt;Much of what will be described here is also documented in &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/extend-extensions.html&quot; target=&quot;_blank&quot;&gt;Packaging Related Objects into an Extension&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the future I&#039;m hoping we&#039;ll also see plr and pgrouting packaged as extensions which are common favorites of PostGIS users.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html#extended&quot;&gt;Continue reading &quot;Lessons learned Packaging PostGIS Extensions: Part 1&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 06 Oct 2011 05:21:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/224-guid.html</guid>
    <category>extensions</category>
<category>postgis</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>
<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>PostgreSQL 9.1 Exploring Extensions</title>
    <link>http://www.postgresonline.com/journal/archives/216-PostgreSQL-9.1-Exploring-Extensions.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>first_last_agg</category>
            <category>intermediate</category>
            <category>kmean</category>
            <category>postgis</category>
            <category>temporal</category>
            <category>window functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/216-PostgreSQL-9.1-Exploring-Extensions.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=216</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the new features I&#039;m excited about in upcoming PostgreSQL 9.1 are extensions.  It is also my hope 
that for PostGIS 2.0, we&#039;ll be able to package &lt;a href=&quot;http://trac.osgeo.org/postgis/ticket/964&quot; target=&quot;_blank&quot;&gt;PostGIS 2.0 as an extension&lt;/a&gt;.  
Reinspired in my mission by David Wheeler&#039;s recent post and video on &lt;a href=&quot;http://blog.pgxn.org/post/8742312488/video-building-and-distributing-extensions-without-c&quot; target=&quot;_blank&quot;&gt;Building and Distributing Extensions without C&lt;/a&gt;, I decided to take some time to investigate how all the extension pieces fit together.&lt;/p&gt;

&lt;p&gt;The three things I like most about extensions
are: &lt;ul&gt;&lt;li&gt;It has a companion sql CREATE EXTENSION and catalog of what&#039;s installed and available right from the db, which makes installing/uninstalling relatively painless&lt;/li&gt;
&lt;li&gt;Installed functions don&#039;t get backed up with data, which is really a bit of a nightmare for PostGIS folks and relief be much welcome as you can tell in Paul&#039;s &lt;a href=&quot;http://blog.cleverelephant.ca/2010/09/postgis-back-up-restore.html&quot; target=&quot;_blank&quot;&gt;PostGIS backup and restore&lt;/a&gt;
which gets a bit more of an adventure in PostGIS 2.0 now that we have raster and topology and many more fun fun GEOS functions.&lt;/li&gt;
&lt;li&gt;The ease with which you can uninstall,migrate your extension to another schema, and upgrade (in theory).  There will be caveats here of course
with changes that require on disk format and involve data.&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;Of course the ease is all in the thoughtfulness of the packaging.  To get some ideas of how we would go about packaging 
PostGIS 2.0 as an extension (it could very well be 3 extensions if we decide to package the core postgis, raster, and topology (and even tiger geocoder) as separate extensions), I thought I would take a look at how others have packaged theirs, and how one goes about registering one of these packages
to make it available in CREATE EXTENSION.&lt;/p&gt;

&lt;h3&gt;Figuring out the extensions you have available ready to install&lt;/h3&gt;
&lt;p&gt;First I decided to start by doing a little snooping, by applying some lessons from our previous article &lt;a href=&quot;http://www.postgresonline.com/journal/archives/215-Querying-table,-view,-column-and-function-descriptions.html&quot; target=&quot;_blank&quot;&gt;Querying table, view, column and function descriptions&lt;/a&gt;
I wrote this query to figure out what useful functions are available to learn about extensions.&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; p.proname &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; funcname,  d.description
 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; pg_proc p
   &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_namespace n &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; n.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; p.pronamespace
   &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_description &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; d &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;d.objoid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; p.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
     &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; n.nspname &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;pg_catalog&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; 
        &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AND&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;d.description ILIKE &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;%extension%&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;or&lt;/span&gt; p.proname ILIKE &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;%extension%&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;ORDER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BY&lt;/span&gt; n.nspname, p.proname ;
&lt;/span&gt;&lt;/code&gt;
-- which output this --
            funcname             |                         description
---------------------------------+-----------------------------------------------------
 pg_available_extension_versions | list available extension versions
 pg_available_extensions         | list available extensions
 pg_extension_config_dump        | flag an extension&#039;s table contents to be emitted by pg_dump
 pg_extension_update_paths       | list an extension&#039;s version update paths&lt;/pre&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/216-PostgreSQL-9.1-Exploring-Extensions.html#extended&quot;&gt;Continue reading &quot;PostgreSQL 9.1 Exploring Extensions&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 14 Aug 2011 22:02:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/216-guid.html</guid>
    <category>postgis extensions kmean period temporal</category>
<category>postgresql 9.1</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>2</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>Variadic Functions in PostgreSQL</title>
    <link>http://www.postgresonline.com/journal/archives/211-Variadic-Functions-in-PostgreSQL.html</link>
            <category>8.4</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>mysql</category>
            <category>pl programming</category>
            <category>plpgsql</category>
            <category>postgis</category>
            <category>postgresql versions</category>
            <category>sql functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/211-Variadic-Functions-in-PostgreSQL.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=211</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL 8.4 introduced the ability to create user-defined &lt;a href=&quot;http://en.wikipedia.org/wiki/Variadic_function&quot; target=&quot;_blank&quot;&gt;variadic functions&lt;/a&gt;. These are basically 
functions that take as input an undefined number of arguments where the argument that is an undefined number are all of the same type and are the last input arguments. Depesz went over it two years ago in &lt;a href=&quot;http://www.depesz.com/index.php/2008/07/31/waiting-for-84-variadic-functions/&quot; target=&quot;_blank&quot;&gt;Waiting for 8.4 variadic functions&lt;/a&gt;,
so we are a bit late to the party. In a nutshell -- variadic functions are syntactic sugar for functions that would otherwise take arrays. In this article we&#039;ll provide some more demonstrations of them to supplement Depesz article.&lt;/p&gt;

&lt;p&gt;I was reminded that I had never explored this feature, when recently documenting one of the
new PostGIS 2.0 Raster functions - &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/RT_ST_Reclass.html&quot; target=&quot;_blank&quot;&gt;ST_Reclass&lt;/a&gt; which employs this feature. 
I think ST_Reclass is a superb function and one of my favorite raster functions thus far that I hope to put to good use soon.  Our new PostGIS family member,Bborie Park, is running thru our
PostGIS Raster milestones much faster than I had dreamed. He&#039;s already implemented a good chunk of stuff we discussed in &lt;a href=&quot;http://www.postgis.us/chapter_13&quot; target=&quot;_blank&quot;&gt;Chapter 13 - PostGIS Raster&lt;/a&gt; and had stated you probably won&#039;t see in PostGIS 2.0.  He&#039;s
going a bit faster than I can catalog them, so the documentation is already embarrassingly behind the fantastic functionality that is already present in PostGIS 2.0.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/211-Variadic-Functions-in-PostgreSQL.html#extended&quot;&gt;Continue reading &quot;Variadic Functions in PostgreSQL&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 03 Jun 2011 22:02:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/211-guid.html</guid>
    <category>mysql</category>
<category>postgis</category>
<category>postgresql 8.4</category>
<category>raster</category>
<category>string concatenation</category>

</item>
<item>
    <title>PostgreSQL 9.1 Trigrams teaching LIKE and ILIKE new tricks</title>
    <link>http://www.postgresonline.com/journal/archives/212-PostgreSQL-9.1-Trigrams-teaching-LIKE-and-ILIKE-new-tricks.html</link>
            <category>9.1</category>
            <category>basics</category>
            <category>contrib spotlight</category>
            <category>intermediate</category>
            <category>pgtrgm</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/212-PostgreSQL-9.1-Trigrams-teaching-LIKE-and-ILIKE-new-tricks.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=212</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;There once existed programmers who were asked to explain this snippet of code: &lt;code&gt;1 + 2&lt;/code&gt; &lt;/p&gt;
&lt;ul&gt;&lt;li&gt;The C programmer explained &amp;quot;It&#039;s a common mathematical expression.&amp;quot;&lt;/li&gt;
    &lt;li&gt;The C++, Java, C# and other impure object-oriented programmers said &amp;quot;We concur.  It&#039;s a common mathematical expression.&amp;quot;&lt;/li&gt;
    &lt;li&gt;The &lt;a href=&quot;http://en.wikipedia.org/wiki/Smalltalk&quot; target=&quot;_blank&quot;&gt;Smalltalk&lt;/a&gt; programmer explained &amp;quot;1 adds 2.&amp;quot;&lt;/li&gt;
    &lt;li&gt;The &lt;a href=&quot;http://en.wikipedia.org/wiki/Lisp_(programming_language)&quot; target=&quot;_blank&quot;&gt;Lisp&lt;/a&gt; programmer stood up, a bit in disgust, and said, &amp;quot;No no! You are doing it all wrong!&amp;quot;&lt;br /&gt; The Lisp Programmer then pulled out
        a &lt;a href=&quot;http://en.wikipedia.org/wiki/Polish_notation&quot; target=&quot;_blank&quot;&gt;Polish calculator&lt;/a&gt;, punched in &lt;code&gt;+ 1 2&lt;/code&gt;
        ,and with a very serious face, explained &lt;br /&gt; &amp;quot;+ should be pushing those other two around.&amp;quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I find this episode interesting because while the Lisp programmer I feel is more right, the Smalltalk programmer has managed to follow the rest of the crowd and still stick 
to her core principle. This brings us to what does this have to do with &lt;a href=&quot;http://www.postgresonline.com/journal/archives/169-Fuzzy-string-matching-with-Trigram-and-Trigraphs.html&quot; target=&quot;_blank&quot;&gt;trigrams&lt;/a&gt; 
in PostgreSQL 9.1.  Well just like &lt;code&gt;1 + 2&lt;/code&gt; being a common mathematical expression, &lt;code&gt;abc LIKE &#039;%b%&#039;&lt;/code&gt; is a common logical relational database expression that we have long taken for granted as not an indexable operation in most
databases (not any other database to I can think of) until PostgreSQL 9.1, which can utilize trigram indices (the Lisp programmer behind the curtain) to make it fast.&lt;/p&gt;


&lt;p&gt;There are 2 main enhancements happening with &lt;a href=&quot;http://www.postgresonline.com/journal/archives/169-Fuzzy-string-matching-with-Trigram-and-Trigraphs.html&quot; target=&quot;_blank&quot;&gt;trigrams&lt;/a&gt; in PostgreSQL 9.1
both of which depesz has already touched on in &lt;a href=&quot;http://www.depesz.com/index.php/2011/02/19/waiting-for-9-1-faster-likeilike/&quot; target=&quot;_blank&quot;&gt;FASTER LIKE/ILIKE&lt;/a&gt;
and &lt;a href=&quot;http://www.depesz.com/index.php/2010/12/11/waiting-for-9-1-knngist/&quot; target=&quot;_blank&quot;&gt;KNNGIST&lt;/a&gt;.  This means you can have an even faster trigram search than you ever
have had before and you can do it in such a fashion that doesn&#039;t require any PostgreSQL trigram specific syntactical expressions.  So while PostgreSQL 9.1 might be understanding LIKE much like all the other databases
you work with, if you have a trigram index in place, it will just be doing it a little faster and sometimes a lot faster using the more clever PostgreSQL 9.1 planner.   
This is one example of how you can use applications designed for many databases and still be able to utilize advanced features in
your database of choice. In this article we&#039;ll demonstrate.&lt;/p&gt;

&lt;p&gt;For this example we&#039;ll use a table of 490,000 someodd records consisting of Massachusetts street segments and their names excerpted from &lt;a href=&quot;http://www.census.gov/geo/www/tiger/tgrshp2010/tgrshp2010.html&quot; target=&quot;_blank&quot;&gt;TIGER 2010&lt;/a&gt; data. You can
download the trimmed data set from &lt;a href=&quot;/downloads/featnames_short.zip&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt; if you want to play along.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/212-PostgreSQL-9.1-Trigrams-teaching-LIKE-and-ILIKE-new-tricks.html#extended&quot;&gt;Continue reading &quot;PostgreSQL 9.1 Trigrams teaching LIKE and ILIKE new tricks&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 06 Jun 2011 01:23:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/212-guid.html</guid>
    <category>mysql</category>
<category>postgresql 9.1</category>
<category>sql server</category>
<category>trigram</category>
<category>trigraph</category>

</item>
<item>
    <title>Compiling PostGIS 1.5 and installing after Yum PostgreSQL Install</title>
    <link>http://www.postgresonline.com/journal/archives/147-Compiling-PostGIS-1.5-and-installing-after-Yum-PostgreSQL-Install.html</link>
            <category>basics</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>yum</category>
    
    <comments>http://www.postgresonline.com/journal/archives/147-Compiling-PostGIS-1.5-and-installing-after-Yum-PostgreSQL-Install.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=147</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;div style=&#039;background-color:yell&#039;&gt;&lt;b&gt;UPDATE:&lt;/b&gt; Since this article was written, Yum now comes packaged with PostGIS 1.5.  Please refer to &lt;a href=&quot;http://www.postgresonline.com/journal/archives/204-postgis15-install-yum.html&quot; target=&quot;_blank&quot;&gt;PostGIS Yum Install for PostgreSQL 9.0&lt;/a&gt; if you want to go with a faster more idiot proof install process&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;A couple of people have asked this, so thought we would address the common issues people run into
with compiling PostGIS.&lt;/p&gt;

&lt;p&gt;The first question, some will ask is &lt;b&gt;Why don&#039;t you just take the packaged PostGIS that comes with the PostgreSQL
Yum repository?&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;There are two reasons for not installing PostGIS under using Yum and our general reasons for not.
&lt;UL&gt;&lt;LI&gt;We like running a newer GEOS than what is generally packaged with Yum because certain PostGIS functionality 
is not enabled with older versions of GEOS.  For example GEOS 3.1 introduced a couple of new functions like ST_Covers and
ST_CoveredBy, ST_ContainedProperly
the &lt;a href=&quot;http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html&quot; target=&quot;_bank&quot;&gt;Cascaded Union&lt;/a&gt; and &lt;a href=&quot;http://blog.cleverelephant.ca/2008/10/postgis-performance-prepared-geometry.html&quot; target=&quot;_blank&quot;&gt;prepared geometry&lt;/a&gt; speed enhancements  require GEOS 3.1+.  GEOS 3.2 brought more robust support for dealing with topological
exceptions, &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/ST_Buffer.html&quot; target=&quot;_blank&quot;&gt;new buffering features like one-sided buffer&lt;/a&gt; (which the upcoming PostGIS 1.5 exposes if and only if you are running
GEOS 3.2+), faster buffering, and several memory leak cleanups. We highly recommend using GEOS 3.2.0.  It is just a more robust product than prior GEOS versions.&lt;/LI&gt;

&lt;LI&gt;We generally like to run newer versions of PostGIS than what Yum provides and also run multiple versions of PostGIS
on the same server.  This is a bit tricky to do with Yum since it only exposes one and generally an older one than what we 
care for. PostGIS 1.5 will be especially great since it will have the &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/ch04.html#PostGIS_Geography&quot; target=&quot;_blank&quot;&gt;geodetic support&lt;/a&gt; and cool functions like &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/ST_ClosestPoint.html&quot; target=&quot;_blank&quot;&gt;ST_ClosestPoint&lt;/a&gt;
	and &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/ch08.html#NewFunctions_1_5&quot; target=&quot;_blank&quot;&gt;other major goodies&lt;/a&gt;.&lt;/LI&gt;
&lt;/UL&gt;
&lt;p&gt;&lt;b&gt;NOTE: PostGIS 1.3, PostGIS 1.4, PostGIS 1.5 can coexist on the same PostgreSQL daemon service as long as they are installed in different databases. They will all share the same Proj and GEOS. So installing PostGIS 1.5 will not break your
PostGIS 1.4 or 1.3 installs. The newer GEOS 3.2.0 C-API is backward compatible with older GEOS C-API and the C-API is what PostGIS uses.&lt;/b&gt;&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/147-Compiling-PostGIS-1.5-and-installing-after-Yum-PostgreSQL-Install.html#extended&quot;&gt;Continue reading &quot;Compiling PostGIS 1.5 and installing after Yum PostgreSQL Install&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 01 Jan 2010 13:48:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/147-guid.html</guid>
    <category>yum postgis</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>Fuzzy string matching with Trigram and Trigraphs</title>
    <link>http://www.postgresonline.com/journal/archives/169-Fuzzy-string-matching-with-Trigram-and-Trigraphs.html</link>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>contrib spotlight</category>
            <category>fuzzystrmatch</category>
            <category>intermediate</category>
            <category>pgtrgm</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/169-Fuzzy-string-matching-with-Trigram-and-Trigraphs.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=169</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In an earlier article &lt;a href=&quot;http://www.postgresonline.com/journal/archives/158-Where-is-soundex-and-other-warm-and-fuzzy-string-things.html&quot; target=&quot;_blank&quot;&gt;Where is Soundex and other Fuzzy string things&lt;/a&gt; we covered the PostgreSQL contrib module fuzzstrmatch which contains the very popular function
soundex that is found in other popular relational databases. We also covered  the more powerful levenshtein distance, metaphone and 
dmetaphone functions included in fuzzstrmatch, but rarely found in other relational databases.&lt;/p&gt;

&lt;p&gt;As far as fuzzy string matching goes, PostgreSQL has other functions up its sleeves.  This time we will cover
the contrib module &lt;a href=&quot;http://www.postgresql.org/docs/8.4/interactive/pgtrgm.html&quot; target=&quot;_blank&quot;&gt;pg_trgm&lt;/a&gt; which was introduced in PostgreSQL 8.3.  pgtrgm uses a concept called trigrams  for doing string comparisons. The pg_trgm module has several functions and gist/gin operators.  
Like other contrib modules, you just need to run the &lt;b&gt;/share/contrib/pg_trgm.sql&lt;/b&gt; file packaged in your PostgreSQL install to enable it in your database. 
&lt;/p&gt;
&lt;p&gt;For this set of exercises, we&#039;ll use trigrams to compare words using the same set of data we tested 
with soundex and metaphones. For the next set of exercises, we will be using the places dataset we created in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/157-Import-fixed-width-data-into-PostgreSQL-with-just-PSQL.html&quot; target=&quot;_blank&quot;&gt;Importing Fixed width data into PostgreSQL with just PSQL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt; The most useful are the &lt;B&gt;similarity&lt;/B&gt; function and the
% operator.  The &lt;b&gt;%&lt;/b&gt; operator allows for using a GIST/GIN index and the similarity function allows for narrowing your filter similar to what
levenshtein did for us in fuzzstrmatch.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/169-Fuzzy-string-matching-with-Trigram-and-Trigraphs.html#extended&quot;&gt;Continue reading &quot;Fuzzy string matching with Trigram and Trigraphs&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 21 Jul 2010 18:20:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/169-guid.html</guid>
    <category>string matching</category>
<category>trigram</category>
<category>trigraph</category>

</item>
<item>
    <title>Using RETURNS TABLE vs. OUT parameters</title>
    <link>http://www.postgresonline.com/journal/archives/201-Using-RETURNS-TABLE-vs.-OUT-parameters.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>db2</category>
            <category>intermediate</category>
            <category>pl programming</category>
            <category>plpgsql</category>
            <category>postgresql versions</category>
            <category>sql functions</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/201-Using-RETURNS-TABLE-vs.-OUT-parameters.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=201</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In a prior article &lt;a href=&quot;http://www.postgresonline.com/journal/archives/129-Use-of-OUT-and-INOUT-Parameters.html&quot; target=&quot;_blank&quot;&gt;Use of Out and InOut Parameters&lt;/a&gt;
we demonstrated how to use OUT parameters and INOUT parameters to return a set of records from a PostgreSQL function.
There is another approach to doing this, and that is to use the ANSI Standard RETURNS TABLE construct.  
If you come from a SQL Server or IBM DB2 background, the RETURNS TABLE construct is probably most familiar, but still
how you use it and what is legal in it is a little different than it is in SQL Server or IBM DB2.  We&#039;ll save the
contrast compare as a topic for another article.  &lt;/p&gt;

&lt;p&gt;In terms of performance between using OUT vs. RETURNS TABLE, we haven&#039;t noticed much of a difference. The main thing that is 
nice about RETURNS TABLE is just that it&#039;s syntactically more pleasing in the sense that its clearer the structure of what you are returning.&lt;/p&gt;

&lt;p&gt;In these next examples, we&#039;ll demonstrate similar examples we showed in the aforementioned article except using the 
&lt;code&gt;RETURNS TABLE&lt;/code&gt;.  
Be warned that the &lt;code&gt;RETURNS TABLE&lt;/code&gt; construct is only available for PostgreSQL 8.4+, while the OUT approach
has existed since PostgreSQL 8.1. With that said, if you need your code to work on 8.3 or lower, you can&#039;t use RETURNS TABLE.
When in doubt about a feature and you are creating code that needs to support earlier versions of PostgreSQL
(as we have to in the PostGIS development group),
or you want to get stubborn users off old antiquated versions of PostgreSQL and need a bit of ammunition  
(as we have to (on PostGIS development including our own developers - and you know who you are :) ) )
check the
&lt;a href=&quot;http://www.postgresql.org/about/featurematrix&quot; target=&quot;_blank&quot;&gt;PostgreSQL feature matrix&lt;/a&gt;.  
It will save you a lot of grief.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/201-Using-RETURNS-TABLE-vs.-OUT-parameters.html#extended&quot;&gt;Continue reading &quot;Using RETURNS TABLE vs. OUT parameters&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 08 Apr 2011 02:32:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/201-guid.html</guid>
    <category>ibm db2</category>
<category>postgresql 9.0</category>
<category>sql server</category>

</item>
<item>
    <title>PL/R Part 2: Functions that take arguments and the power of aggregation</title>
    <link>http://www.postgresonline.com/journal/archives/189-PLR-Part-2-Functions-that-take-arguments-and-the-power-of-aggregation.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>intermediate</category>
            <category>pl programming</category>
            <category>PLR</category>
    
    <comments>http://www.postgresonline.com/journal/archives/189-PLR-Part-2-Functions-that-take-arguments-and-the-power-of-aggregation.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=189</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In &lt;a href=&quot;http://www.postgresonline.com/journal/archives/188-plr_part1.html&quot; target=&quot;_blank&quot;&gt;Intro to PL/R and R&lt;/a&gt;, we covered how to enable PL/R language in the database and wrote some PL/R functions
that rendered plain text reports using the R environment.  What makes combining R and PostgreSQL in
PL/R most powerful is when you can start writing SQL summary queries that use R functions like any other SQL function. &lt;/p&gt;

&lt;p&gt;In this next example, we&#039;ll be using PostGIS test runs from tests we autogenerated from the &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/&quot; target=&quot;_blank&quot;&gt;Official PostGIS documentation&lt;/a&gt; (Documentation Driven Testing (DDT))
as described in the  &lt;a href=&quot;http://trac.osgeo.org/postgis/wiki/DevWikiGardenTest&quot; target=&quot;_blank&quot;&gt;Garden Test&lt;/a&gt; section of the PostGIS Developer wiki.  
We&#039;ve also updated some of our logging generator and test patterns so future results may not represent what we demonstrated in the last article. &lt;/p&gt;
&lt;p&gt;On a side note: Among the changes in the tests was to introduce more variants of the &lt;a href=&quot;http://www.postgis.org/pipermail/postgis-devel/2010-December/010776.html&quot; target=&quot;_balnk&quot;&gt;Empty Geometry now supported by PostGIS 2.0&lt;/a&gt;.  
Our beloved PostGIS 2.0 trunk is at the moment somewhat unstable when working with these new forms of emptiness and stuffing geometries in inappropriate places. At the moment it doesn&#039;t survive through  the mindless machine gun battery of tests we have mercilessly inflicted.
It&#039;s been great fun trying to build a better dummy while watching &lt;a href=&quot;http://blog.cleverelephant.ca/&quot; target=&quot;_blank&quot;&gt;Paul&lt;/a&gt; run around patching holes to make the software more dummy proof as the dummy stumbles across questionable but amusing PostGIS use cases not gracefully handled by his new serialization and empty logic. &lt;/p&gt;

&lt;p&gt;On yet another side note, it&#039;s nice to 
see that others are doing similar wonderful things with documentation.  Check out &lt;a href=&quot;http://eulerto.blogspot.com/2010/11/comment-on-catalog-tables.html&quot; target=&quot;_blank&quot;&gt;Euler&#039;s comment on catalog tables&lt;/a&gt;
where he uses the PostgreSQL SGML documentation to autogenerate PostgreSQL catalog table comments using &lt;a href=&quot;http://openjade.sourceforge.net/doc/sx.htm&quot; target-&quot;_blank&quot;&gt;OpenJade&#039;s OSX to convert the SGML to XML&lt;/a&gt; and then XSL similar to what we did with PostGIS documentation to autogenerate PostGIS function/type comments and as a platform
for our test generator.  &lt;/p&gt;

&lt;p&gt;For our next exercises we&#039;ll be using the power of aggregation to push data into R instead of &lt;b&gt;pg.spi.execute&lt;/b&gt;. This will make our functions far more reusable and versatile.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/189-PLR-Part-2-Functions-that-take-arguments-and-the-power-of-aggregation.html#extended&quot;&gt;Continue reading &quot;PL/R Part 2: Functions that take arguments and the power of aggregation&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 10 Dec 2010 01:38:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/189-guid.html</guid>
    <category>plr</category>
<category>postgis</category>
<category>r</category>

</item>
<item>
    <title>PL/R Part 3: Sharing Functions across PL/R functions with plr_module</title>
    <link>http://www.postgresonline.com/journal/archives/190-PLR-Part-3-Sharing-Functions-across-PLR-functions-with-plr_module.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>intermediate</category>
            <category>pl programming</category>
            <category>PLR</category>
    
    <comments>http://www.postgresonline.com/journal/archives/190-PLR-Part-3-Sharing-Functions-across-PLR-functions-with-plr_module.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=190</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In &lt;a href=&quot;http://www.postgresonline.com/journal/archives/189-plr_part2.html&quot; target=&quot;_blank&quot;&gt;Part 2 of PL/R&lt;/a&gt; we covered how to build PL/R functions that take arrays and output textual outputs of generated R objects.  We then used this in an aggregate SQL query using array_agg. Often when you are building PL/R functions
you&#039;ll have R functions that you want to reuse many times either inside a single PL/R function or across various PL/R functions. &lt;/p&gt;

&lt;p&gt;Unfortunately, if you wanted to call a PL/R function from another PL/R function, this is not possible unless you are doing it from spi.execute call. 
There is another way to embed reusable R code in a PostgreSQL database.
In order to be able to share databases stored R code across various PL/R functions, PL/R has a feature called a plr_module.  In this tutorial
we&#039;ll learn how to create and register shareable R functions with plr_module. In the next part of this series we&#039;ll start to explore generating graphs with PL/R.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/190-PLR-Part-3-Sharing-Functions-across-PLR-functions-with-plr_module.html#extended&quot;&gt;Continue reading &quot;PL/R Part 3: Sharing Functions across PL/R functions with plr_module&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 20 Dec 2010 13:37:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/190-guid.html</guid>
    <category>plr</category>
<category>postgis</category>
<category>r</category>

</item>
<item>
    <title>Quick Intro to R and PL/R - Part 1</title>
    <link>http://www.postgresonline.com/journal/archives/188-Quick-Intro-to-R-and-PLR-Part-1.html</link>
            <category>9.0</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>pl programming</category>
            <category>PLR</category>
    
    <comments>http://www.postgresonline.com/journal/archives/188-Quick-Intro-to-R-and-PLR-Part-1.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=188</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In this article we&#039;ll provide a summary of what PL/R is and how to get running with it.  Since we don&#039;t like repeating ourselves,
we&#039;ll refer you to an article we wrote a while ago which is still fairly relevant today called &lt;a href=&quot;http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01&quot; target=&quot;_blank&quot;&gt;Up and Running with PL/R (PLR) in PostgreSQL: An almost Idiot&#039;s Guide&lt;/a&gt;
and just fill in the parts that have changed.  We should note that particular series was more geared toward the spatial database programmer (PostGIS in particular).  There is a lot of overlap between the PL/R, R, and PostGIS user-base which is comprised
of many environmental scientists and researchers in need of powerful charting and stats tools to analyse their data who are high on the smart but low on the money human spectrum. &lt;/p&gt;
&lt;p&gt;This series will be more of a general PL/R user perspective.  We&#039;ll follow more of the same style we did with &lt;a href=&quot;http://www.postgresonline.com/journal/archives/99-Quick-Intro-to-PLPython.html&quot; target=&quot;_blank&quot;&gt;Quick Intro to PL/Python&lt;/a&gt;. We&#039;ll end our series with a PL/R cheatsheet similar to what we had for PL/Python.&lt;/p&gt;
&lt;p&gt;As stated in our &lt;a href=&quot;http://www.postgresonline.com/journal/archives/187-postgis20_state_plr.html&quot; target=&quot;_blank&quot;&gt;State of PostGIS&lt;/a&gt; article, we&#039;ll be using log files we generated from our PostGIS stress tests.  These stress tests were auto-generated from the PostGIS official documentation.  
The raster tests are comprised of 2,095 query executions exercising all the pixel types supported.  The geometry/geograpy tests are comprised of 65,892 spatial SQL queries exercising every PostGIS geometry/geography supported in PostGIS 2.0 -- yes this includes TINS, Triangles,Polyhedral Surfaces, Curved geometries and all dimensions of them.
Most queries are unique. If you are curious to see what these log tables look like or want to follow along with these exercises, you can download the tables from &lt;a href=&quot;/demos/plr/postgis20gardentests.zip&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;What is R and PL/R and why should you care?&lt;/h4&gt;
&lt;p&gt;R is both a language and an environment for doing statistics and generating graphs and plots.  It is GNU-licensed and a common favorite of Universities and Research institutions. PL/R is a procedural language for PostgreSQL that allows you to write database stored functions
in R.  R is a set-based and domain specific language similar to SQL except unlike the way relational databases treat data, it thinks of data as matrices, lists and vectors.  I tend to think of it as a cross between LISP and SQL though more experienced Lisp and R users will probably disagree with me on that.  This makes it easier in many cases to tabulate data both across columns as well as across rows.
The examples we will show in these exercises, could be done in SQL, but they are much more succinct to write in R.  In addition to the language itself, there are a whole wealth of statistical and graphing functions available in R that you will not 
find in any relational database.  These functions are growing as more people contribute packages.  Its packaging system called Comprehensive R Archive (CRAN) is similar in concept to Perl&#039;s CPAN and the in the works &lt;a href=&quot;http://blog.pgxn.org/&quot; target=&quot;_blank&quot;&gt;PGXN for PostgreSQL&lt;/a&gt;.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/188-Quick-Intro-to-R-and-PLR-Part-1.html#extended&quot;&gt;Continue reading &quot;Quick Intro to R and PL/R - Part 1&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 28 Nov 2010 14:19:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/188-guid.html</guid>
    <category>plr</category>
<category>postgis</category>
<category>r</category>

</item>
<item>
    <title>Setting up PostgreSQL as a Linked Server in Microsoft SQL Server 64-bit</title>
    <link>http://www.postgresonline.com/journal/archives/46-Setting-up-PostgreSQL-as-a-Linked-Server-in-Microsoft-SQL-Server-64-bit.html</link>
            <category>intermediate</category>
            <category>q&amp;a</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/46-Setting-up-PostgreSQL-as-a-Linked-Server-in-Microsoft-SQL-Server-64-bit.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=46</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;P&gt;We would like to thank Jeff Crumbley of IILogistics for providing many of these steps 
and informing us that Microsoft has finally released a
64-bit OLEDB for ODBC driver.
&lt;/P&gt;

&lt;P&gt;For those who have not experienced the torture of this situation - let me start with a little background.  
First if you are running SQL Server 2005 32-bit and wished to create a linked server to a PostgreSQL server, everything is hunky dory.  If
however you had a SQL Server 2005 64-bit server, you ran into 2 very annoying obstacles.  

&lt;OL&gt;&lt;LI&gt;&lt;b&gt;Obstacle 1:&lt;/b&gt; There for a long-time was no 64-bit ODBC driver nor native driver for PostgreSQL.  This obstacle was somewhat alleviated
when Fuurin Kazanbai made experimental compiled 64-bit PostgreSQL ODBC drivers available which work for AMD and Intel based processors.&lt;/LI&gt;
&lt;LI&gt;&lt;b&gt;Obstacle 2:&lt;/b&gt; All looked good in the world until you tried this in SQL Server 2005 64-bit and low and behold - you needed a 64-bit OLEDB provider 
for ODBC to use it in SQL Server 2005 64-bit.  Yes we waited patiently for years for this piece to be available.  We still love you Microsoft.
Then as Jeff Crumbley pointed out - Microsoft released an OLEDB 64-bit provider for ODBC in early April 2008.&lt;/LI&gt;
&lt;/OL&gt;

&lt;/P&gt; 

&lt;div style=&quot;background-color:green;color:white&quot;&gt;UPDATE: Since we wrote this article, PostgreSQL now comes with a 64-bit ODBC driver you can download from
&lt;a href=&quot;http://www.postgresql.org/ftp/odbc/versions/msi/&quot; target=&quot;_blank&quot; style=&#039;color:white;font-weight:blod&#039;&gt;http://www.postgresql.org/ftp/odbc/versions/msi/&lt;/a&gt;.  To use these make sure to use MSDASQL.1 instead of MSDASQL.  In fact you should probably be using MSDASQL.1 anyway.  refer to our newer article &lt;a href=&quot;http://www.postgresonline.com/journal/archives/196-SQL-Server-64-bit-Linked-Server-woes.html&quot; target=&quot;_balnk&quot;&gt;SQL Server 64-bit Linked Server woes&lt;/a&gt;&lt;/div&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/46-Setting-up-PostgreSQL-as-a-Linked-Server-in-Microsoft-SQL-Server-64-bit.html#extended&quot;&gt;Continue reading &quot;Setting up PostgreSQL as a Linked Server in Microsoft SQL Server 64-bit&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 25 Apr 2008 01:28:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/46-guid.html</guid>
    
</item>
<item>
    <title>String Aggregation in PostgreSQL, SQL Server, and MySQL</title>
    <link>http://www.postgresonline.com/journal/archives/191-String-Aggregation-in-PostgreSQL,-SQL-Server,-and-MySQL.html</link>
            <category>8.2</category>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>cte</category>
            <category>db2</category>
            <category>intermediate</category>
            <category>mysql</category>
            <category>oracle</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/191-String-Aggregation-in-PostgreSQL,-SQL-Server,-and-MySQL.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=191</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;&lt;b&gt;Question:&lt;/b&gt; You have a table of people and a table that specifies the activities each person is involved
in.  You want to return a result that has one record per person and a column that has a listing of activities for each person
separated by semicolons and alphabetically sorted by activity. You also want the whole set alphabetically sorted by person&#039;s name. &lt;/p&gt;

&lt;p&gt;This is a question we are always asked and since we mentor on various flavors of databases, 
we need to be able to switch gears and provide an answer that works on the client&#039;s database. Most
often the additional requirement is that you can&#039;t install new functions in the database. This means that
for PostgreSQL/SQL Server that both support defining custom aggregates, that is out as an option.&lt;/p&gt;

&lt;p&gt;Normally we try to come up with an answer that works in most databases, but sadly the only solution that works in 
most is to push the problem off to the client front end and throw up your hands and proclaim -- &amp;quot;This ain&#039;t something that should be 
done in the database and is a reporting problem.&amp;quot;  That is in fact what many database purists do, and all I can say to them is wake up and smell the coffee before you are out of a job.  
We feel that data 
transformation is an important function of a database, and if your database is incapable of massaging the data into a format
your various client apps can easily digest, WELL THAT&#039;s A PROBLEM.&lt;/p&gt;

&lt;p&gt;We shall now document this answer rather than trying to answer for the nteenth time. For starter&#039;s
PostgreSQL has a lot of answers to this question, probably more so than any other, though some are easier to execute than others
and many depend on the version of PostgreSQL you are using.  SQL Server has 2 classes of answers neither of which is terribly appealing,
but we&#039;ll go over the ones that don&#039;t require you to be able to install .NET stored functions in your database since we said that is often a requirement.  
MySQL has a fairly
simple, elegant and very portable way that it has had for a really long time.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/191-String-Aggregation-in-PostgreSQL,-SQL-Server,-and-MySQL.html#extended&quot;&gt;Continue reading &quot;String Aggregation in PostgreSQL, SQL Server, and MySQL&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 24 Dec 2010 11:24:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/191-guid.html</guid>
    <category>common table expressions</category>
<category>mysql</category>
<category>oracle</category>
<category>postgresql 9.0</category>
<category>sql server</category>
<category>string concatenation</category>
<category>window functions</category>

</item>
<item>
    <title>pgAdmin pgScript</title>
    <link>http://www.postgresonline.com/journal/archives/181-pgAdmin-pgScript.html</link>
            <category>basics</category>
            <category>intermediate</category>
            <category>pgadmin</category>
            <category>postgis</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/181-pgAdmin-pgScript.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=181</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;pgAdmin has this feature called a pgScript.  Its a very simple scripting language for running
tasks in a pgAdmin SQL window. The documentation is &lt;a href=&quot;http://www.pgadmin.org/docs/dev/pgscript.html&quot; target=&quot;_blank&quot;&gt;PgScript manual&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Why would you use it over say writing a plpgsql function?&lt;/h4&gt;
&lt;p&gt;One main reason we use it is to run quick ad-hoc batch jobs such as geocoding addresses and so forth.  The
benefit it has over running a stored function is that you don&#039;t have to run it as a single transaction.&lt;/p&gt;
&lt;p&gt;This is important for certain kinds of tasks where you just want to run something in a loop and have each loop commit
separately. To us the syntax with the @ resembles SQL Server Transact-SQL more than it does any PostgreSQL language. WhenI first
saw pgScript I thought &lt;em&gt;Wow PgAdmin talks Transact-SQL; now -- what will they think of next :)&lt;/em&gt;.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/181-pgAdmin-pgScript.html#extended&quot;&gt;Continue reading &quot;pgAdmin pgScript&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 29 Oct 2010 03:52:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/181-guid.html</guid>
    <category>geocoding</category>
<category>pgadmin</category>
<category>postgis</category>

</item>
<item>
    <title>Explain Plans PostgreSQL 9.0 - Part 2: JSON and JQuery Plan Viewer</title>
    <link>http://www.postgresonline.com/journal/archives/174-Explain-Plans-PostgreSQL-9.0-Part-2-JSON-and-JQuery-Plan-Viewer.html</link>
            <category>9.0</category>
            <category>application development</category>
            <category>intermediate</category>
            <category>jquery</category>
            <category>pgadmin</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/174-Explain-Plans-PostgreSQL-9.0-Part-2-JSON-and-JQuery-Plan-Viewer.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=174</wfw:comment>

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

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In &lt;a href=&quot;http://www.postgresonline.com/journal/archives/171-pgexplain90formats_part1.html&quot; target=&quot;_blank&quot;&gt;part 1 of this series&lt;/a&gt; on PostgreSQL 9.0 planner outputs, we demonstrated how to render explain plans in YAML, JSON, and XML using the new explain features in PostgreSQL 9.0. In this second part,
we&#039;ll demonstrate how to build a user interface that allows you input a JSON formatted explain plan and have it render into a printable, navigateable display using JQuery, javascript and a little bit of HTML coding.  
In part 3 we&#039;ll do something similar using XML and XSLT programming.
&lt;/p&gt;
&lt;p&gt;For those who aren&#039;t familiar with JQuery, it is an MIT licensed javascript library that is fairly light weight and allows you to inspect and change html elements with fairly intuitive syntax, has some nice ajax methods and tools for converting xml/json to native objects that can be manipulated. 
You can check it out at &lt;a href=&quot;http://jquery.com/&quot; target=&quot;_blank&quot;&gt;JQUERY&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We are not experts in JQuery, but from what we have used of it, we really like it and the fact the base package is MIT licensed, fairly light weight and lots of plugins available for it are real pluses.&lt;/p&gt;


&lt;p&gt;The most difficult thing I think most people find about reading explain plans is that they are upside down; it starts with a conclusion and backtracks how to arrive at it.  Humans by nature think about planning steps from start to finish.
In order to make an explain plan understandable to mere mortals, we generally display them upside down or having the child-nodes shown left most.  We shall follow that approach.&lt;/p&gt;
 &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/174-Explain-Plans-PostgreSQL-9.0-Part-2-JSON-and-JQuery-Plan-Viewer.html#extended&quot;&gt;Continue reading &quot;Explain Plans PostgreSQL 9.0 - Part 2: JSON and JQuery Plan Viewer&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 26 Aug 2010 04:13:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/174-guid.html</guid>
    <category>explain plan</category>
<category>imagemagick</category>
<category>jquery</category>
<category>json</category>
<category>pgadmin</category>
<category>postgresql 9.0</category>

</item>

</channel>
</rss>
