<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-777</id>
	<title>Nabble - PostgreSQL - sql</title>
	<updated>2009-12-11T02:20:47Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/PostgreSQL---sql-f777.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/PostgreSQL---sql-f777.html" />
	<subtitle type="html"></subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26741804</id>
	<title>Re: Re: constants in 2-column foreign keys or how to design a storage for text-groups ?</title>
	<published>2009-12-11T02:20:47Z</published>
	<updated>2009-12-11T02:20:47Z</updated>
	<author>
		<name>Andreas-3</name>
	</author>
	<content type="html">Jasen Betts schrieb:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On 2009-12-09, Andreas &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26741804&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;maps.on@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; ...
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; stupid example:
&lt;br&gt;&amp;gt;&amp;gt; ---------------
&lt;br&gt;&amp;gt;&amp;gt; color: &amp;nbsp; red, green, blue
&lt;br&gt;&amp;gt;&amp;gt; size: tiny, little, big, giant
&lt;br&gt;&amp;gt;&amp;gt; structure: &amp;nbsp;hard, soft, floppy
&lt;br&gt;&amp;gt;&amp;gt; How would I solve the rather common text storage issue?
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; have you considered using enumerated types instead?
&lt;/div&gt;Yes, but I need those texts in the GUI to show them as listboxes or 
&lt;br&gt;comboboxes.
&lt;br&gt;There might be changes too when I later need to add or drop an option of 
&lt;br&gt;a group.
&lt;br&gt;&lt;br&gt;E.g. there are questionnaires to model.
&lt;br&gt;Lets say 10 questions where each has a couple of predefined answers 
&lt;br&gt;where one should be selected.
&lt;br&gt;So I've got to store every group of possible answers to a question 
&lt;br&gt;either in a seperate table or in a kind of repository all within one big 
&lt;br&gt;table (row_id, questionnare_id, question_id, answer_nr, answer)
&lt;br&gt;The row_id so I just need to store 1 value per answer.
&lt;br&gt;&lt;br&gt;Now I've got to make sure that it is impossible that accidentally there 
&lt;br&gt;gets a question-17 answer connected to a question-42 and above all, that 
&lt;br&gt;the questions dont get mixed between the questionnaires.
&lt;br&gt;&lt;br&gt;I can do this with the frontend and enough hope that nothing bad will 
&lt;br&gt;happen.
&lt;br&gt;Still I'd rather hardwire the integrity into the table design.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26741804&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/constants-in-2-column-foreign-keys-or-how-to-design-a-storage-for-text-groups---tp26703236p26741804.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26740653</id>
	<title>Re: FIND_IN_SET</title>
	<published>2009-12-11T00:48:33Z</published>
	<updated>2009-12-11T00:48:33Z</updated>
	<author>
		<name>Pavel Stehule</name>
	</author>
	<content type="html">2009/12/11 Michael Eshom &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26740653&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;oldiesmann@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I am on the marketing team for a popular forum system, and am also the
&lt;br&gt;&amp;gt; primary PostgreSQL tester/bugfixer. Currently our forum system treats
&lt;br&gt;&amp;gt; MySQL's FIND_IN_SET() as a boolean (eg whether or not the specified value
&lt;br&gt;&amp;gt; was found in the given set), which is fine since MySQL will treat any
&lt;br&gt;&amp;gt; integer greater than 0 as boolean true and 0 as boolean false. I have
&lt;br&gt;&amp;gt; already managed to write a FIND_IN_SET() function for Postgres that behaves
&lt;br&gt;&amp;gt; as boolean. However, we would like to be able to use the true functionality
&lt;br&gt;&amp;gt; of this function (so it will return an integer instead of boolean).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This is where I've run into a problem. The mysqlcompat package has a
&lt;br&gt;&amp;gt; FIND_IN_SET() in it, but it requires plpgsql, and I'd rather not require
&lt;br&gt;&amp;gt; something that a regular user can't install themselves, regardless of how
&lt;br&gt;&amp;gt; simple it is for the host to add it.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I did find another version of FIND_IN_SET() on a blog with several other
&lt;br&gt;&amp;gt; MySQL-compatible functions, and while it uses regular SQL, it requires the
&lt;br&gt;&amp;gt; generate_subscripts() function which isn't available in Postgres 8.1 - the
&lt;br&gt;&amp;gt; latest version officially supported by CentOS.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is there a way to do this without requiring plpgsql or generate_subscripts?
&lt;/div&gt;&lt;br&gt;Hello
&lt;br&gt;&lt;br&gt;you can define own generate_subscripts function
&lt;br&gt;&lt;br&gt;CREATE OR REPLACE FUNCTION find_in_set(str text, strlist text)
&lt;br&gt;RETURNS int AS $$
&lt;br&gt;SELECT i
&lt;br&gt;&amp;nbsp; &amp;nbsp;FROM generate_series(string_to_array($2,','),1) g(i)
&lt;br&gt;&amp;nbsp; WHERE (string_to_array($2, ','))[i] = $1
&lt;br&gt;&amp;nbsp; UNION ALL
&lt;br&gt;&amp;nbsp; SELECT 0
&lt;br&gt;&amp;nbsp; LIMIT 1
&lt;br&gt;$$ LANGUAGE sql STRICT;
&lt;br&gt;&lt;br&gt;CREATE OR REPLACE generate_subscripts(anyarray, int)
&lt;br&gt;RETURNS SETOF int AS $$
&lt;br&gt;SELECT generate_series(array_lower($1,$2), array_upper($1,$2))
&lt;br&gt;$$ LANGUAGE sql;
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Pavel Stehule
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Michael &amp;quot;Oldiesmann&amp;quot; Eshom
&lt;br&gt;&amp;gt; Christian Oldies Fan
&lt;br&gt;&amp;gt; Cincinnati, Ohio
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26740653&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/FIND_IN_SET-tp26740038p26740653.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26740522</id>
	<title>Re: constants in 2-column foreign keys or how to design a storage for text-groups ?</title>
	<published>2009-12-11T00:39:47Z</published>
	<updated>2009-12-11T00:39:47Z</updated>
	<author>
		<name>Jasen Betts-5</name>
	</author>
	<content type="html">On 2009-12-09, Andreas &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26740522&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;maps.on@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&lt;br&gt;...
&lt;br&gt;&amp;gt; stupid example:
&lt;br&gt;&amp;gt; ---------------
&lt;br&gt;&amp;gt; color: &amp;nbsp; red, green, blue
&lt;br&gt;&amp;gt; size: tiny, little, big, giant
&lt;br&gt;&amp;gt; structure: &amp;nbsp;hard, soft, floppy
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt; How would I solve the rather common text storage issue?
&lt;br&gt;&lt;br&gt;have you considered using enumerated types instead?
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26740522&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/constants-in-2-column-foreign-keys-or-how-to-design-a-storage-for-text-groups---tp26703236p26740522.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26740038</id>
	<title>FIND_IN_SET</title>
	<published>2009-12-10T22:22:02Z</published>
	<updated>2009-12-10T22:22:02Z</updated>
	<author>
		<name>Michael Eshom</name>
	</author>
	<content type="html">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;

&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
&lt;/head&gt;
&lt;body bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot;&gt;
&lt;font size=&quot;-1&quot;&gt;&lt;font face=&quot;Arial&quot;&gt;I am on the marketing team for a
popular forum system, and am also the primary PostgreSQL
tester/bugfixer. Currently our forum system treats MySQL's
FIND_IN_SET() as a boolean (eg whether or not the specified value was
found in the given set), which is fine since MySQL will treat any
integer greater than 0 as boolean true and 0 as boolean false. I have
already managed to write a FIND_IN_SET() function for Postgres that
behaves as boolean. However, we would like to be able to use the true
functionality of this function (so it will return an integer instead of
boolean).&lt;br&gt;
&lt;br&gt;
This is where I've run into a problem. The mysqlcompat package has a
FIND_IN_SET() in it, but it requires plpgsql, and I'd rather not
require something that a regular user can't install themselves,
regardless of how simple it is for the host to add it.&lt;br&gt;
&lt;br&gt;
I did find another version of FIND_IN_SET() on a blog with several
other MySQL-compatible functions, and while it uses regular SQL, it
requires the generate_subscripts() function which isn't available in
Postgres 8.1 - the latest version officially supported by CentOS.&lt;br&gt;
&lt;br&gt;
Is there a way to do this without requiring plpgsql or
generate_subscripts?&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;
&lt;div class=&quot;moz-signature&quot;&gt;-- &lt;br&gt;
&lt;font style=&quot;color: blue; size: 12px;&quot; face=&quot;Comic Sans MS&quot;&gt;Michael
&quot;Oldiesmann&quot; Eshom&lt;br&gt;
Christian Oldies Fan&lt;br&gt;
Cincinnati, Ohio&lt;/font&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/FIND_IN_SET-tp26740038p26740038.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26736107</id>
	<title>Re: Window function trouble</title>
	<published>2009-12-10T15:08:07Z</published>
	<updated>2009-12-10T15:08:07Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">Harald Fuchs &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26736107&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hari.fuchs@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; That being said, I still think that PostgreSQL could do better - how
&lt;br&gt;&amp;gt; about naming expression columns so that they are distinct from column
&lt;br&gt;&amp;gt; names?
&lt;br&gt;&lt;br&gt;Even though the rules we use are pretty arbitrary, I'm hesitant to make
&lt;br&gt;changes in them; it seems more likely to break existing applications
&lt;br&gt;than to do anyone any good.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26736107&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Window-function-trouble-tp26730836p26736107.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26734467</id>
	<title>Re: Window function trouble</title>
	<published>2009-12-10T13:02:00Z</published>
	<updated>2009-12-10T13:02:00Z</updated>
	<author>
		<name>Harald Fuchs-10</name>
	</author>
	<content type="html">In article &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26734467&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;25983.1260468559@...&lt;/a&gt;&amp;gt;,
&lt;br&gt;Tom Lane &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26734467&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tgl@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&lt;br&gt;&amp;gt; The SQL standard says the default name for any output column other
&lt;br&gt;&amp;gt; than a simple column reference is implementation-dependent. &amp;nbsp;I think
&lt;br&gt;&amp;gt; our implementation involves looking at the default value for a CASE.
&lt;br&gt;&lt;br&gt;Thanks for the clarification, Tom - so it's not a PostgreSQL bug, but
&lt;br&gt;a misfeature of the SQL standard.
&lt;br&gt;&lt;br&gt;That being said, I still think that PostgreSQL could do better - how
&lt;br&gt;about naming expression columns so that they are distinct from column
&lt;br&gt;names? &amp;nbsp;The current implementation throws an error e.g. for
&lt;br&gt;&lt;br&gt;&amp;nbsp; SELECT adr,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE lag(adr) OVER (ORDER BY adr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WHEN adr THEN NULL
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ELSE adr
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;END,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;usr, count(*)
&lt;br&gt;&amp;nbsp; FROM tbl
&lt;br&gt;&amp;nbsp; WHERE host = 'h1'
&lt;br&gt;&amp;nbsp; GROUP BY adr, usr
&lt;br&gt;&amp;nbsp; ORDER BY adr, usr
&lt;br&gt;&lt;br&gt;namely `ORDER BY &amp;quot;adr&amp;quot; is ambiguous' which I find somewhat confusing.
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26734467&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Window-function-trouble-tp26730836p26734467.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26731987</id>
	<title>Re: Window function trouble</title>
	<published>2009-12-10T10:09:19Z</published>
	<updated>2009-12-10T10:09:19Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">Harald Fuchs &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26731987&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hari.fuchs@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; Apparently the CASE expression is named &amp;quot;adr&amp;quot; unless named
&lt;br&gt;&amp;gt; otherwise, and the result set is sorted by this expression instead of
&lt;br&gt;&amp;gt; the column named &amp;quot;adr&amp;quot;. &amp;nbsp;Does anyone know what the SQL standard says
&lt;br&gt;&amp;gt; about that?
&lt;br&gt;&lt;br&gt;The SQL standard says the default name for any output column other
&lt;br&gt;than a simple column reference is implementation-dependent. &amp;nbsp;I think
&lt;br&gt;our implementation involves looking at the default value for a CASE.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26731987&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Window-function-trouble-tp26730836p26731987.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26731696</id>
	<title>Re: Window function trouble</title>
	<published>2009-12-10T09:49:57Z</published>
	<updated>2009-12-10T09:49:57Z</updated>
	<author>
		<name>Harald Fuchs-10</name>
	</author>
	<content type="html">In article &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26731696&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pud42mahnr.fsf@...&lt;/a&gt;&amp;gt;,
&lt;br&gt;Harald Fuchs &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26731696&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hari.fuchs@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&lt;br&gt;&amp;gt; The other users for one address are gone. &amp;nbsp;Does anyone know why?
&lt;br&gt;&lt;br&gt;Update: they are not gone, but they've moved to the end of the result
&lt;br&gt;set. Apparently the CASE expression is named &amp;quot;adr&amp;quot; unless named
&lt;br&gt;otherwise, and the result set is sorted by this expression instead of
&lt;br&gt;the column named &amp;quot;adr&amp;quot;. &amp;nbsp;Does anyone know what the SQL standard says
&lt;br&gt;about that?
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26731696&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Window-function-trouble-tp26730836p26731696.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26730836</id>
	<title>Window function trouble</title>
	<published>2009-12-10T09:00:08Z</published>
	<updated>2009-12-10T09:00:08Z</updated>
	<author>
		<name>Harald Fuchs-10</name>
	</author>
	<content type="html">I have a table like this:
&lt;br&gt;&lt;br&gt;&amp;nbsp; CREATE TABLE tbl (
&lt;br&gt;&amp;nbsp; &amp;nbsp; host text NOT NULL,
&lt;br&gt;&amp;nbsp; &amp;nbsp; adr ip4 NOT NULL,
&lt;br&gt;&amp;nbsp; &amp;nbsp; usr text NOT NULL
&lt;br&gt;&amp;nbsp; );
&lt;br&gt;&lt;br&gt;(ip4 is from the ip4r contrib module)
&lt;br&gt;and I want the number of entries per address and per user:
&lt;br&gt;&lt;br&gt;&amp;nbsp; SELECT adr, usr, count(*)
&lt;br&gt;&amp;nbsp; FROM tbl
&lt;br&gt;&amp;nbsp; WHERE host = ?
&lt;br&gt;&amp;nbsp; &amp;nbsp; AND adr &amp;lt;&amp;lt;= ?
&lt;br&gt;&amp;nbsp; GROUP BY adr, usr
&lt;br&gt;&amp;nbsp; ORDER BY adr, usr
&lt;br&gt;&lt;br&gt;That's pretty basic stuff and returns something like this:
&lt;br&gt;&lt;br&gt;&amp;nbsp; adr1 usr1_1 cnt1_1
&lt;br&gt;&amp;nbsp; adr1 usr1_2 cnt1_2
&lt;br&gt;&amp;nbsp; adr1 usr1_3 cnt1_3
&lt;br&gt;&amp;nbsp; adr2 usr2_1 cnt2_1
&lt;br&gt;&amp;nbsp; ...
&lt;br&gt;&lt;br&gt;But I want the address to be NULL if it's the same as the address of
&lt;br&gt;the previous row. I came up with this:
&lt;br&gt;&lt;br&gt;&amp;nbsp; SELECT CASE lag(adr) OVER (ORDER BY adr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;WHEN adr THEN NULL
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ELSE adr
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;END AS myaddr,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;usr, count(*)
&lt;br&gt;&amp;nbsp; FROM tbl
&lt;br&gt;&amp;nbsp; WHERE host = ?
&lt;br&gt;&amp;nbsp; &amp;nbsp; AND adr &amp;lt;&amp;lt;= ?
&lt;br&gt;&amp;nbsp; GROUP BY adr, usr
&lt;br&gt;&amp;nbsp; ORDER BY adr, usr
&lt;br&gt;&lt;br&gt;This returns something like
&lt;br&gt;&lt;br&gt;&amp;nbsp; adr1 usr1_1 cnt1_1
&lt;br&gt;&amp;nbsp; NULL usr1_2 cnt1_2
&lt;br&gt;&amp;nbsp; NULL usr1_3 cnt1_3
&lt;br&gt;&amp;nbsp; adr2 usr2_1 cnt2_1
&lt;br&gt;&amp;nbsp; ...
&lt;br&gt;&lt;br&gt;what's exactly what I want. &amp;nbsp;But when I don't name the CASE expression
&lt;br&gt;(i.e. I delete &amp;quot;AS myaddr&amp;quot;), I get the following:
&lt;br&gt;&lt;br&gt;&amp;nbsp; adr1 usr1_1 cnt1_1
&lt;br&gt;&amp;nbsp; adr2 usr2_1 cnt2_1
&lt;br&gt;&amp;nbsp; ...
&lt;br&gt;&lt;br&gt;The other users for one address are gone. &amp;nbsp;Does anyone know why?
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26730836&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Window-function-trouble-tp26730836p26730836.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26710419</id>
	<title>Re: SQL state 58P01 triggered by a database script execution</title>
	<published>2009-12-09T05:46:23Z</published>
	<updated>2009-12-09T05:46:23Z</updated>
	<author>
		<name>A. Kretschmer</name>
	</author>
	<content type="html">In response to aymen marouani :
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Thanks for the help,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In deed I found those lines in my script
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;quot;--
&lt;br&gt;&amp;gt; -- TOC entry 25 (class 1255 OID 16409)
&lt;br&gt;&amp;gt; -- Dependencies: 6
&lt;br&gt;&amp;gt; -- Name: bt_metap(text); Type: FUNCTION; Schema: public; Owner: postgres
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; CREATE FUNCTION bt_metap(relname text, OUT magic integer, OUT version integer,
&lt;br&gt;&amp;gt; OUT root integer, OUT level integer, OUT fastroot integer, OUT fastlevel
&lt;br&gt;&amp;gt; integer) RETURNS record
&lt;br&gt;&amp;gt;     AS '$libdir/pageinspect', 'bt_metap'
&lt;br&gt;&amp;gt;     LANGUAGE c STRICT;
&lt;br&gt;&amp;gt; &amp;quot;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Can I comment those lines to remove the error ?
&lt;/div&gt;&lt;br&gt;Sure. But that don't solve your problem if you call that function
&lt;br&gt;later...
&lt;br&gt;&lt;br&gt;Regards, Andreas
&lt;br&gt;-- 
&lt;br&gt;Andreas Kretschmer
&lt;br&gt;Kontakt: &amp;nbsp;Heynitz: 035242/47150, &amp;nbsp; D1: 0160/7141639 (mehr: -&amp;gt; Header)
&lt;br&gt;GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 &amp;nbsp;2EB0 389D 1DC2 3172 0C99
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26710419&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SQL-state-58P01-triggered-by-a-database-script-execution-tp26709914p26710419.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26710241</id>
	<title>Re: SQL state 58P01 triggered by a database script execution</title>
	<published>2009-12-09T05:33:47Z</published>
	<updated>2009-12-09T05:33:47Z</updated>
	<author>
		<name>Oceanys</name>
	</author>
	<content type="html">&lt;div dir=&quot;ltr&quot;&gt;Thanks for the help,&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;In deed I found those lines in my script&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;quot;--&lt;/div&gt;&lt;div&gt;-- TOC entry 25 (class 1255 OID 16409)&lt;/div&gt;&lt;div&gt;-- Dependencies: 6&lt;/div&gt;&lt;div&gt;-- Name: bt_metap(text); Type: FUNCTION; Schema: public; Owner: postgres&lt;/div&gt;
&lt;div&gt;--&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;CREATE FUNCTION bt_metap(relname text, OUT magic integer, OUT version integer, OUT root integer, OUT level integer, OUT fastroot integer, OUT fastlevel integer) RETURNS record&lt;/div&gt;&lt;div&gt;    AS &amp;#39;$libdir/pageinspect&amp;#39;, &amp;#39;bt_metap&amp;#39;&lt;/div&gt;
&lt;div&gt;    LANGUAGE c STRICT;&lt;/div&gt;&lt;div&gt;&amp;quot;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Can I comment those lines to remove the error ?&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/12/9 A. Kretschmer &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26710241&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;andreas.kretschmer@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;In response to aymen marouani :&lt;br&gt;
&lt;div class=&quot;im&quot;&gt;&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have a database under Postgres v8.3 and I generated its backups script using&lt;br&gt;
&amp;gt; PGAdmin III.&lt;br&gt;
&amp;gt; I executed the same script under Postgres v8.2 in order to create the same&lt;br&gt;
&amp;gt; database but I get the following error&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;quot; ERROR: could not access file &amp;quot;$libdir/pageinspect&amp;quot;: No such file or directory&lt;br&gt;
&amp;gt;   SQL state :58P01&amp;quot;&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;Pageinspect is a contrib-modul, so i think, you should install that. But&lt;br&gt;
i don&amp;#39;t know if this available for 8.2.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Andreas&lt;br&gt;
--&lt;br&gt;
Andreas Kretschmer&lt;br&gt;
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -&amp;gt; Header)&lt;br&gt;
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99&lt;br&gt;
&lt;font color=&quot;#888888&quot;&gt;&lt;br&gt;
--&lt;br&gt;
Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26710241&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)&lt;br&gt;
To make changes to your subscription:&lt;br&gt;
&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SQL-state-58P01-triggered-by-a-database-script-execution-tp26709914p26710241.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26710105</id>
	<title>Re: SQL state 58P01 triggered by a database script execution</title>
	<published>2009-12-09T05:24:54Z</published>
	<updated>2009-12-09T05:24:54Z</updated>
	<author>
		<name>A. Kretschmer</name>
	</author>
	<content type="html">In response to aymen marouani :
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I have a database under Postgres v8.3 and I generated its backups script using
&lt;br&gt;&amp;gt; PGAdmin III.
&lt;br&gt;&amp;gt; I executed the same script under Postgres v8.2 in order to create the same
&lt;br&gt;&amp;gt; database but I get the following error
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;quot; ERROR: could not access file &amp;quot;$libdir/pageinspect&amp;quot;: No such file or directory
&lt;br&gt;&amp;gt;   SQL state :58P01&amp;quot;
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;Pageinspect is a contrib-modul, so i think, you should install that. But
&lt;br&gt;i don't know if this available for 8.2.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Andreas
&lt;br&gt;-- 
&lt;br&gt;Andreas Kretschmer
&lt;br&gt;Kontakt: &amp;nbsp;Heynitz: 035242/47150, &amp;nbsp; D1: 0160/7141639 (mehr: -&amp;gt; Header)
&lt;br&gt;GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 &amp;nbsp;2EB0 389D 1DC2 3172 0C99
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26710105&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SQL-state-58P01-triggered-by-a-database-script-execution-tp26709914p26710105.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26709914</id>
	<title>SQL state 58P01 triggered by a database script execution</title>
	<published>2009-12-09T05:10:36Z</published>
	<updated>2009-12-09T05:10:36Z</updated>
	<author>
		<name>Oceanys</name>
	</author>
	<content type="html">&lt;div dir=&quot;ltr&quot;&gt;Hi,&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I have a database under Postgres v8.3 and I generated its backups script using PGAdmin III.&lt;/div&gt;&lt;div&gt;I executed the same script under Postgres v8.2 in order to create the same database but I get the following error&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&amp;quot; ERROR: could not access file &amp;quot;$libdir/pageinspect&amp;quot;: No such file or directory&lt;/div&gt;&lt;div&gt;  SQL state :58P01&amp;quot;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Is this error related to the difference of versions ?&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Thanks in advance.&lt;/div&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SQL-state-58P01-triggered-by-a-database-script-execution-tp26709914p26709914.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26708146</id>
	<title>Re: Stalled post to pgsql-sql</title>
	<published>2009-12-09T02:33:54Z</published>
	<updated>2009-12-09T02:33:54Z</updated>
	<author>
		<name>Pavel Stehule</name>
	</author>
	<content type="html">hello
&lt;br&gt;postgres=# create table foo(a timestamp(0));
&lt;br&gt;CREATE TABLE
&lt;br&gt;Time: 111,105 ms
&lt;br&gt;postgres=# insert into foo values(now());
&lt;br&gt;INSERT 0 1
&lt;br&gt;Time: 1,292 ms
&lt;br&gt;postgres=# select now(), a from foo;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; now &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a
&lt;br&gt;-------------------------------+---------------------
&lt;br&gt;&amp;nbsp;2009-12-09 11:33:22.746217+01 | 2009-12-09 11:33:12
&lt;br&gt;(1 row)
&lt;br&gt;&lt;br&gt;Time: 21,010 ms
&lt;br&gt;&lt;br&gt;regards
&lt;br&gt;Pavel Stehule
&lt;br&gt;&lt;br&gt;&lt;br&gt;2009/12/9 sergey kapustin &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26708146&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;kapustin.sergey@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt; I need a type that will store date and time, but without seconds and
&lt;br&gt;&amp;gt; microseconds (like timestamp does). At least without microseconds.
&lt;br&gt;&amp;gt; I also need all the operators to work.
&lt;br&gt;&amp;gt; Is this possible with one of existing date/time types or i need to create my
&lt;br&gt;&amp;gt; own?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thank you!
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26708146&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Re%3A-Stalled-post-to-pgsql-sql-tp26708116p26708146.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26708116</id>
	<title>Re: Stalled post to pgsql-sql</title>
	<published>2009-12-09T02:30:44Z</published>
	<updated>2009-12-09T02:30:44Z</updated>
	<author>
		<name>Sergey Kapustin-2</name>
	</author>
	<content type="html">Hello,&lt;br&gt;I need a type that will store date and time, but without
seconds and microseconds (like timestamp does). At least without
microseconds.&lt;br&gt;I also need all the operators to work.&lt;br&gt;Is this possible with one of existing date/time types or i need to create my own?&lt;br&gt;
&lt;br&gt;Thank you!&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Re%3A-Stalled-post-to-pgsql-sql-tp26708116p26708116.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26703236</id>
	<title>constants in 2-column foreign keys or how to design a storage for text-groups ?</title>
	<published>2009-12-08T16:20:26Z</published>
	<updated>2009-12-08T16:20:26Z</updated>
	<author>
		<name>Andreas-3</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;my frontend has a lot of combo- and listboxes where one can chose a 
&lt;br&gt;textsnippet that represents a key-number which is stored in several 
&lt;br&gt;tables as foreign-key attributes.
&lt;br&gt;Those textsnippets are usually semantically grouped in 2-10 strings that 
&lt;br&gt;belong together somehow.
&lt;br&gt;&lt;br&gt;stupid example:
&lt;br&gt;---------------
&lt;br&gt;color: &amp;nbsp; red, green, blue
&lt;br&gt;size: tiny, little, big, giant
&lt;br&gt;structure: &amp;nbsp;hard, soft, floppy
&lt;br&gt;&lt;br&gt;now I'd like to build tables like
&lt;br&gt;thing( color_fk foreign key to color, size_fk foreign key to size, 
&lt;br&gt;structure_fk foreign key to structure, sometext, atimestamp ...)
&lt;br&gt;so far no problems.
&lt;br&gt;&lt;br&gt;With time those little text-list-tables clutter up the database so I'm 
&lt;br&gt;thinking about one big text-storage that has the groups represented by a 
&lt;br&gt;number like:
&lt;br&gt;snippets (snippet_id, snippet_group_nr, snippet)
&lt;br&gt;(100, 1, red), (101, 1, green), (102, 1, blue), (200, 2, tiny), (201, 2, 
&lt;br&gt;little), ...
&lt;br&gt;&lt;br&gt;Simple foreign-keys still work nicely but they cant prohibit that I 
&lt;br&gt;store id-values from wrong groups.
&lt;br&gt;Here color_fk would only be correct if the id is out of group 1. The 
&lt;br&gt;foreign key doesnt catch it if I put a group-3-id into color_fk.
&lt;br&gt;&lt;br&gt;Id be cool to be able to have constants in 2-column foreign keys like
&lt;br&gt;color_fk integer not null default 0
&lt;br&gt;FOREIGN KEY (color_fk, &amp;nbsp;1 &amp;nbsp;) REFERENCES snippets (snippet_id, 
&lt;br&gt;snippet_group_nr)
&lt;br&gt;&lt;br&gt;This throws an error. So this approach might be not advisable.
&lt;br&gt;I could add an additional column for every foreign-key that stores 
&lt;br&gt;constant group-ids then I can have 2-column-fk but this looks bloated 
&lt;br&gt;since those extra columns would hold eternally the same number in every row.
&lt;br&gt;&lt;br&gt;How would I solve the rather common text storage issue?
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26703236&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/constants-in-2-column-foreign-keys-or-how-to-design-a-storage-for-text-groups---tp26703236p26703236.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26690070</id>
	<title>Re: Query Performance</title>
	<published>2009-12-07T23:55:09Z</published>
	<updated>2009-12-07T23:55:09Z</updated>
	<author>
		<name>Postgre Novice</name>
	</author>
	<content type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:12pt&quot;&gt;&lt;div&gt;Tomas: Thanks for your replay.&lt;br&gt;&lt;br&gt;I got it working within 3 minutes because of hash join&amp;nbsp; by rearranging the query. &lt;br&gt;&lt;br&gt;explain analyze select *, subs from (select user_name,A.user_id,
dnd_window_start, dnd_window_stop from users A ,subs_feed B where
A.user_id=B.user_id and b.feed_id=1413 and f_sms='t') as foo left outer
join user_subscriptions u on (foo.user_id=u.user_id);&lt;br&gt;
  &lt;br&gt;
Hash Left Join&amp;nbsp; (cost=1472105.16..2775728.42 rows=957624 width=75)
(actual time=86322.190..192125.402 rows=1340957 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp; Hash Cond: (a.user_id = u.user_id)&lt;br&gt;
&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Hash Join&amp;nbsp; (cost=1347862.70..2638877.52 rows=957624 width=26)
(actual time=79407.144..181327.848 rows=1340957 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hash Cond: (b.user_id = a.user_id)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Heap Scan on subs_feed b&amp;nbsp;
(cost=34518.45..1127550.37 rows=957624 width=4) (actual
time=8791.019..72889.040 rows=1340957 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Recheck Cond: (feed_id = 1413)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filter: f_sms&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Index Scan on feed_user_id&amp;nbsp;
(cost=0.00..34279.04 rows=1442930 width=0) (actual
time=8492.067..8492.067 rows=1352180 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Index Cond: (feed_id = 1413)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Hash&amp;nbsp; (cost=916273.00..916273.00 rows=19548100
width=26) (actual time=70605.366..70605.366 rows=19548560 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Seq Scan on users a&amp;nbsp; (cost=0.00..916273.00
rows=19548100 width=26) (actual time=10.405..55676.884 rows=19548560
loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Hash&amp;nbsp; (cost=77415.54..77415.54 rows=3746154 width=49) (actual
time=6909.632..6909.632 rows=3758304 loops=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Seq Scan on user_subscriptions u&amp;nbsp; (cost=0.00..77415.54
rows=3746154 width=49) (actual time=3.624..4265.114 rows=3758304
loops=1)&lt;br&gt;
&amp;nbsp;Total runtime: 192585.437 ms&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;font-family: times new roman,new york,times,serif; font-size: 12pt;&quot;&gt;&lt;br&gt;&lt;div style=&quot;font-family: arial,helvetica,sans-serif; font-size: 13px;&quot;&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;hr size=&quot;1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;From:&lt;/span&gt;&lt;/b&gt; &quot;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690070&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tv@...&lt;/a&gt;&quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690070&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tv@...&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;To:&lt;/span&gt;&lt;/b&gt; Postgre Novice &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690070&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;postgrenovice@...&lt;/a&gt;&amp;gt;&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Cc:&lt;/span&gt;&lt;/b&gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690070&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sent:&lt;/span&gt;&lt;/b&gt; Mon, December 7, 2009 7:23:19 PM&lt;br&gt;&lt;b&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Subject:&lt;/span&gt;&lt;/b&gt; Re: [SQL] Query Performance&lt;br&gt;&lt;/font&gt;&lt;br&gt;Yes, the problem is the nested loop scan - it's scanning users 609070&lt;br&gt;times, which is awful.&lt;br&gt;&lt;br&gt;Could you provide explain plan that executed fast? Was it executed with&lt;br&gt;the same parameter values or did the parameters change (maybe it's slow&lt;br&gt;for some
 parameters values only)?&lt;br&gt;&lt;br&gt;Have you tried to rewrite the subselect to a join? I.e. something like this&lt;br&gt;&lt;br&gt;select user_name,A.user_id, dnd_window_start, dnd_window_stop, B.subs as&lt;br&gt;subs, B.city_id as city_id, B.source_type as source_type from&lt;br&gt;users A left join user_subscriptions B on (A.user_id=B.user_id)&lt;br&gt;join subs_feed C ON (A.user_id = C.user_id)&lt;br&gt;where feed_id=1411 and f_sms='t'&lt;br&gt;&lt;br&gt;But I guess it won't solve the issue (it seems PostgreSQL did this rewrite&lt;br&gt;on it's own).&lt;br&gt;&lt;br&gt;Tomas&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello List,&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; I have a query which use to run very fast now has turn into show stopper .&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; PostgreSQL:8.2&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; explain analyze select user_name,A.user_id, dnd_window_start,&lt;br&gt;&amp;gt; dnd_window_stop, B.subs as subs, B.city_id as city_id, B.source_type as&lt;br&gt;&amp;gt; source_type from&lt;br&gt;&amp;gt; users A left join user_subscriptions B on (A.user_id=B.user_id)&lt;br&gt;&amp;gt; where A.user_id in (select user_id from
 subs_feed where feed_id=1411 and&lt;br&gt;&amp;gt; f_sms='t')&lt;br&gt;&amp;gt; ;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Nested Loop Left Join&amp;nbsp; (cost=986325.88..1094601.47 rows=11148&lt;br&gt;&amp;gt; width=55) (actual time=132635.994..1590487.280 rows=609070&lt;br&gt;&amp;gt; loops=1)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; Nested Loop&amp;nbsp; (cost=986325.88..1062280.53 rows=11148 width=26)&lt;br&gt;&amp;gt; (actual time=132630.057..1398299.117 rows=609070 loops=1)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; HashAggregate&amp;nbsp; (cost=986325.88..986437.36 rows=11148 width=4)&lt;br&gt;&amp;gt; (actual time=132591.648..133386.651 rows=609070 loops=1)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Heap Scan on subs_feed&lt;br&gt;&amp;gt; (cost=16316.71..985194.44 rows=452576 width=4) (actual&lt;br&gt;&amp;gt; time=20199.571..131566.494 rows=609070 loops=1)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Recheck Cond: (feed_id =
 1411)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Filter: f_sms&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Index Scan on feed_user_id&lt;br&gt;&amp;gt; (cost=0.00..16203.57 rows=681933 width=0) (actual&lt;br&gt;&amp;gt; time=19919.512..19919.512 rows=616900 loops=1)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Index Cond: (feed_id = 1411)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; Index Scan using users_pkey on users a&amp;nbsp; (cost=0.00..6.79&lt;br&gt;&amp;gt; rows=1 width=26) (actual time=2.073..2.074 rows=1 loops=609070)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Index Cond: (a.user_id = subs_feed.user_id)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; -&amp;gt;&amp;nbsp; Index Scan using user_subscriptions_user_id_pk on&lt;br&gt;&amp;gt; user_subscriptions b&amp;nbsp; (cost=0.00..2.89 rows=1 width=33) (actual&lt;br&gt;&amp;gt; time=0.312..0.313
 rows=1 loops=609070)&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Index Cond: (a.user_id = b.user_id)&lt;br&gt;&amp;gt;&amp;nbsp; Total runtime: 1590755.918 ms&lt;br&gt;&amp;gt; (13 rows)&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; This query runs almost half an hour. It is evident that nested loop is&lt;br&gt;&amp;gt; taking most of the time (approx 27 minutes).&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Any tips would be very useful.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Also these table have below count:&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; select relname,reltuples from pg_class where relname in&lt;br&gt;&amp;gt; ('users','user_subscriptions','subs_feed');&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;  relname&amp;nbsp; &amp;nbsp; &amp;nbsp;  |&amp;nbsp; reltuples&lt;br&gt;&amp;gt; --------------------+-------------&lt;br&gt;&amp;gt;&amp;nbsp; user_subscriptions |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3758304&lt;br&gt;&amp;gt;&amp;nbsp;  users&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 1.95481e+07&lt;br&gt;&amp;gt;&amp;nbsp; subs_feed&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2.96492e+07&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; select
 n_tup_ins,n_tup_upd,n_tup_del,last_vacuum,last_analyze from&lt;br&gt;&amp;gt; pg_stat_user_tables where relname='user_subscriptions';&lt;br&gt;&amp;gt;&amp;nbsp; n_tup_ins | n_tup_upd | n_tup_del |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  last_vacuum&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; last_analyze&lt;br&gt;&amp;gt; -----------+-----------+-----------+----------------------------------+----------------------------------&lt;br&gt;&amp;gt;&amp;nbsp;  86371397 |&amp;nbsp; 25865942 |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  0 | 2009-12-06 23:00:36.355251+05:30 |&lt;br&gt;&amp;gt; 2009-12-06 23:00:36.355251+05:30&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Thanks in advance for help ...&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- &lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690070&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)&lt;br&gt;To make changes to your subscription:&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
&lt;!-- cg27.c4.mail.gq1.yahoo.com compressed Mon Dec  7 03:54:00 PST 2009 --&gt;
&lt;/div&gt;&lt;br&gt;



      &lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Query-Performance-tp26676943p26690070.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26684647</id>
	<title>Re: problems with changing the case of turkish characters</title>
	<published>2009-12-07T13:28:03Z</published>
	<updated>2009-12-07T13:28:03Z</updated>
	<author>
		<name>the6campbells</name>
	</author>
	<content type="html">&lt;div&gt;to clarify. just trying to ensure I understand what PG 8.4 and 8.3 provide where you may have data from alternate languages where ideally you&amp;#39;d like them in the same table in the same database etc. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;create table T ( c1 char( ...), c2 char (...) ... ) where c1 may contain thai, c2 korean, c3 turkish etc names &lt;/div&gt;
&lt;div&gt;vs&lt;/div&gt;
&lt;div&gt;create table TKO (c1 char(...)), create table TTH (c1 char (...))&lt;/div&gt;
&lt;div&gt;vs &lt;/div&gt;
&lt;div&gt;different databases etc&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Mon, Dec 7, 2009 at 4:20 PM, the6campbells &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26684647&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;the6campbells@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid&quot;&gt;
&lt;div&gt;so where would I define something akin to what I can do in DB2 LUW where collate using system means to sort by the codeset. ie. without english, united states in LC_COLLATE. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;USING CODESET UTF-8 TERRITORY US COLLATE USING SYSTEM&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;h5&quot;&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Mon, Dec 7, 2009 at 12:28 PM, Tom Lane &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26684647&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tgl@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid&quot;&gt;
&lt;div&gt;the6campbells &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26684647&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;the6campbells@...&lt;/a&gt;&amp;gt; writes:&lt;br&gt;&amp;gt; Just want to clarify if there is something I&amp;#39;ve overlooked or if this is a&lt;br&gt;&amp;gt; known issue in PG 8.4 and 8.3&lt;br&gt;
&lt;br&gt;&amp;gt; CREATE DATABASE test&lt;br&gt;&amp;gt;   WITH OWNER = postgres&lt;br&gt;&amp;gt;        ENCODING = &amp;#39;UTF8&amp;#39;&lt;br&gt;&amp;gt;        LC_COLLATE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;br&gt;&amp;gt;        LC_CTYPE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;br&gt;
&lt;br&gt;&lt;/div&gt;Not sure why you&amp;#39;d be expecting an English locale to follow Turkish&lt;br&gt;case-changing rules.&lt;br&gt;&lt;br&gt;                       regards, tom lane&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problems-with-changing-the-case-of-turkish-characters-tp26680501p26684647.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26684375</id>
	<title>Re: problems with changing the case of turkish characters</title>
	<published>2009-12-07T13:20:26Z</published>
	<updated>2009-12-07T13:20:26Z</updated>
	<author>
		<name>the6campbells</name>
	</author>
	<content type="html">&lt;div&gt;so where would I define something akin to what I can do in DB2 LUW where collate using system means to sort by the codeset. ie. without english, united states in LC_COLLATE. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;USING CODESET UTF-8 TERRITORY US COLLATE USING SYSTEM&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Mon, Dec 7, 2009 at 12:28 PM, Tom Lane &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26684375&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tgl@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid&quot;&gt;
&lt;div class=&quot;im&quot;&gt;the6campbells &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26684375&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;the6campbells@...&lt;/a&gt;&amp;gt; writes:&lt;br&gt;&amp;gt; Just want to clarify if there is something I&amp;#39;ve overlooked or if this is a&lt;br&gt;&amp;gt; known issue in PG 8.4 and 8.3&lt;br&gt;
&lt;br&gt;&amp;gt; CREATE DATABASE test&lt;br&gt;&amp;gt;   WITH OWNER = postgres&lt;br&gt;&amp;gt;        ENCODING = &amp;#39;UTF8&amp;#39;&lt;br&gt;&amp;gt;        LC_COLLATE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;br&gt;&amp;gt;        LC_CTYPE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;br&gt;
&lt;br&gt;&lt;/div&gt;Not sure why you&amp;#39;d be expecting an English locale to follow Turkish&lt;br&gt;case-changing rules.&lt;br&gt;&lt;br&gt;                       regards, tom lane&lt;br&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problems-with-changing-the-case-of-turkish-characters-tp26680501p26684375.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26680735</id>
	<title>Re: problems with changing the case of turkish characters</title>
	<published>2009-12-07T09:28:08Z</published>
	<updated>2009-12-07T09:28:08Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">the6campbells &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26680735&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;the6campbells@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; Just want to clarify if there is something I've overlooked or if this is a
&lt;br&gt;&amp;gt; known issue in PG 8.4 and 8.3
&lt;br&gt;&lt;br&gt;&amp;gt; CREATE DATABASE test
&lt;br&gt;&amp;gt; &amp;nbsp; WITH OWNER = postgres
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ENCODING = 'UTF8'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LC_COLLATE = 'English, United States, UTF-8'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LC_CTYPE = 'English, United States, UTF-8'
&lt;br&gt;&lt;br&gt;Not sure why you'd be expecting an English locale to follow Turkish
&lt;br&gt;case-changing rules.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26680735&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problems-with-changing-the-case-of-turkish-characters-tp26680501p26680735.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26680501</id>
	<title>problems with changing the case of turkish characters</title>
	<published>2009-12-07T09:12:51Z</published>
	<updated>2009-12-07T09:12:51Z</updated>
	<author>
		<name>the6campbells</name>
	</author>
	<content type="html">&lt;div&gt;Just want to clarify if there is something I&amp;#39;ve overlooked or if this is a known issue in PG 8.4 and 8.3&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;CREATE DATABASE test&lt;br&gt;  WITH OWNER = postgres&lt;br&gt;       ENCODING = &amp;#39;UTF8&amp;#39;&lt;br&gt;       LC_COLLATE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;br&gt;       LC_CTYPE = &amp;#39;English, United States, UTF-8&amp;#39;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;select (&amp;#39;İsteği&amp;#39;) from tversion&lt;br&gt;&amp;quot;İsteği&amp;quot; was expecting &amp;quot;isteği&amp;quot;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;select upper(&amp;#39;iışğüçö&amp;#39;) from tversion&lt;/div&gt;
&lt;div&gt;&amp;quot;IıŞĞÜÇÖ&amp;quot;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;select lower (&amp;#39;İIŞĞÜÇÖ&amp;#39;) from tversion&lt;/div&gt;
&lt;div&gt;&amp;quot;İişğüçö&amp;quot;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problems-with-changing-the-case-of-turkish-characters-tp26680501p26680501.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26677658</id>
	<title>Re: Query Performance</title>
	<published>2009-12-07T05:53:19Z</published>
	<updated>2009-12-07T05:53:19Z</updated>
	<author>
		<name>tv-8</name>
	</author>
	<content type="html">Yes, the problem is the nested loop scan - it's scanning users 609070
&lt;br&gt;times, which is awful.
&lt;br&gt;&lt;br&gt;Could you provide explain plan that executed fast? Was it executed with
&lt;br&gt;the same parameter values or did the parameters change (maybe it's slow
&lt;br&gt;for some parameters values only)?
&lt;br&gt;&lt;br&gt;Have you tried to rewrite the subselect to a join? I.e. something like this
&lt;br&gt;&lt;br&gt;select user_name,A.user_id, dnd_window_start, dnd_window_stop, B.subs as
&lt;br&gt;subs, B.city_id as city_id, B.source_type as source_type from
&lt;br&gt;users A left join user_subscriptions B on (A.user_id=B.user_id)
&lt;br&gt;join subs_feed C ON (A.user_id = C.user_id)
&lt;br&gt;where feed_id=1411 and f_sms='t'
&lt;br&gt;&lt;br&gt;But I guess it won't solve the issue (it seems PostgreSQL did this rewrite
&lt;br&gt;on it's own).
&lt;br&gt;&lt;br&gt;Tomas
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello List,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a query which use to run very fast now has turn into show stopper .
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; PostgreSQL:8.2
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; explain analyze select user_name,A.user_id, dnd_window_start,
&lt;br&gt;&amp;gt; dnd_window_stop, B.subs as subs, B.city_id as city_id, B.source_type as
&lt;br&gt;&amp;gt; source_type from
&lt;br&gt;&amp;gt; users A left join user_subscriptions B on (A.user_id=B.user_id)
&lt;br&gt;&amp;gt; where A.user_id in (select user_id from subs_feed where feed_id=1411 and
&lt;br&gt;&amp;gt; f_sms='t')
&lt;br&gt;&amp;gt; ;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Nested Loop Left Join &amp;nbsp;(cost=986325.88..1094601.47 rows=11148
&lt;br&gt;&amp;gt; width=55) (actual time=132635.994..1590487.280 rows=609070
&lt;br&gt;&amp;gt; loops=1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;Nested Loop &amp;nbsp;(cost=986325.88..1062280.53 rows=11148 width=26)
&lt;br&gt;&amp;gt; (actual time=132630.057..1398299.117 rows=609070 loops=1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;HashAggregate &amp;nbsp;(cost=986325.88..986437.36 rows=11148 width=4)
&lt;br&gt;&amp;gt; (actual time=132591.648..133386.651 rows=609070 loops=1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;Bitmap Heap Scan on subs_feed
&lt;br&gt;&amp;gt; (cost=16316.71..985194.44 rows=452576 width=4) (actual
&lt;br&gt;&amp;gt; time=20199.571..131566.494 rows=609070 loops=1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Recheck Cond: (feed_id = 1411)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Filter: f_sms
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;Bitmap Index Scan on feed_user_id
&lt;br&gt;&amp;gt; (cost=0.00..16203.57 rows=681933 width=0) (actual
&lt;br&gt;&amp;gt; time=19919.512..19919.512 rows=616900 loops=1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Index Cond: (feed_id = 1411)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;Index Scan using users_pkey on users a &amp;nbsp;(cost=0.00..6.79
&lt;br&gt;&amp;gt; rows=1 width=26) (actual time=2.073..2.074 rows=1 loops=609070)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Index Cond: (a.user_id = subs_feed.user_id)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;-&amp;gt; &amp;nbsp;Index Scan using user_subscriptions_user_id_pk on
&lt;br&gt;&amp;gt; user_subscriptions b &amp;nbsp;(cost=0.00..2.89 rows=1 width=33) (actual
&lt;br&gt;&amp;gt; time=0.312..0.313 rows=1 loops=609070)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Index Cond: (a.user_id = b.user_id)
&lt;br&gt;&amp;gt; &amp;nbsp;Total runtime: 1590755.918 ms
&lt;br&gt;&amp;gt; (13 rows)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This query runs almost half an hour. It is evident that nested loop is
&lt;br&gt;&amp;gt; taking most of the time (approx 27 minutes).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any tips would be very useful.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Also these table have below count:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; select relname,reltuples from pg_class where relname in
&lt;br&gt;&amp;gt; ('users','user_subscriptions','subs_feed');
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; relname &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp;reltuples
&lt;br&gt;&amp;gt; --------------------+-------------
&lt;br&gt;&amp;gt; &amp;nbsp;user_subscriptions | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3758304
&lt;br&gt;&amp;gt; &amp;nbsp; users &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 1.95481e+07
&lt;br&gt;&amp;gt; &amp;nbsp;subs_feed &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2.96492e+07
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; select n_tup_ins,n_tup_upd,n_tup_del,last_vacuum,last_analyze from
&lt;br&gt;&amp;gt; pg_stat_user_tables where relname='user_subscriptions';
&lt;br&gt;&amp;gt; &amp;nbsp;n_tup_ins | n_tup_upd | n_tup_del | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; last_vacuum &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;last_analyze
&lt;br&gt;&amp;gt; -----------+-----------+-----------+----------------------------------+----------------------------------
&lt;br&gt;&amp;gt; &amp;nbsp; 86371397 | &amp;nbsp;25865942 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 | 2009-12-06 23:00:36.355251+05:30 |
&lt;br&gt;&amp;gt; 2009-12-06 23:00:36.355251+05:30
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance for help ...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26677658&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Query-Performance-tp26676943p26677658.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26676943</id>
	<title>Query Performance</title>
	<published>2009-12-07T05:00:58Z</published>
	<updated>2009-12-07T05:00:58Z</updated>
	<author>
		<name>Postgre Novice</name>
	</author>
	<content type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div style=&quot;font-family:times new roman,new york,times,serif;font-size:12pt&quot;&gt;&lt;div&gt;Hello List,&lt;br&gt;&lt;br&gt;I have a query which use to run very fast now has turn into show stopper .&lt;br&gt;&lt;br&gt;PostgreSQL:8.2&lt;br&gt;&lt;br&gt;explain analyze select user_name,A.user_id, dnd_window_start, dnd_window_stop, B.subs as subs, B.city_id as city_id, B.source_type as source_type
 from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;users A left join user_subscriptions B on
 (A.user_id=B.user_id)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;where A.user_id in (select user_id from subs_feed where feed_id=1411 and f_sms='t')&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
 &lt;br&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Nested Loop Left Join&amp;nbsp; (cost=986325.88..1094601.47
 rows=11148 width=55) (actual time=132635.994..1590487.280 rows=609070 loops=1)&lt;br&gt;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Nested Loop&amp;nbsp; (cost=986325.88..1062280.53 rows=11148 width=26) (actual time=132630.057..1398299.117 rows=609070 loops=1)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; HashAggregate&amp;nbsp; (cost=986325.88..986437.36 rows=11148 width=4) (actual time=132591.648..133386.651 rows=609070 loops=1)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Heap Scan on subs_feed&amp;nbsp; (cost=16316.71..985194.44 rows=452576 width=4) (actual time=20199.571..131566.494 rows=609070 loops=1)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Recheck Cond: (feed_id = 1411)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filter:
 f_sms&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Bitmap Index Scan on feed_user_id&amp;nbsp; (cost=0.00..16203.57 rows=681933 width=0) (actual time=19919.512..19919.512 rows=616900 loops=1)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Index Cond: (feed_id = 1411)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Index Scan using users_pkey on users a&amp;nbsp; (cost=0.00..6.79 rows=1 width=26) (actual time=2.073..2.074 rows=1 loops=609070)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Index Cond: (a.user_id = subs_feed.user_id)&lt;br&gt;&amp;nbsp;&amp;nbsp; -&amp;gt;&amp;nbsp; Index Scan using user_subscriptions_user_id_pk on user_subscriptions b&amp;nbsp; (cost=0.00..2.89 rows=1 width=33) (actual time=0.312..0.313 rows=1
 loops=609070)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Index Cond: (a.user_id = b.user_id)&lt;br&gt;&amp;nbsp;Total runtime: 1590755.918 ms&lt;br&gt;(13 rows)&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;This query runs almost half an hour. It is evident that nested loop is taking most of the time (approx 27 minutes).&lt;br&gt;&lt;br&gt;Any tips would be very useful.&lt;br&gt;&lt;br&gt;Also these table have below count:&lt;br&gt;&lt;br&gt;select relname,reltuples from pg_class where relname in ('users','user_subscriptions','subs_feed');&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; relname&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp; reltuples&lt;br&gt;--------------------+-------------&lt;br&gt;&amp;nbsp;user_subscriptions |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3758304&lt;br&gt;&amp;nbsp;
users&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 1.95481e+07&lt;br&gt;&amp;nbsp;subs_feed&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 2.96492e+07&lt;br&gt;&lt;br&gt;&lt;br&gt;select n_tup_ins,n_tup_upd,n_tup_del,last_vacuum,last_analyze from pg_stat_user_tables where relname='user_subscriptions';&lt;br&gt;&amp;nbsp;n_tup_ins | n_tup_upd | n_tup_del |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; last_vacuum&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; last_analyze&lt;br&gt;-----------+-----------+-----------+----------------------------------+----------------------------------&lt;br&gt;&amp;nbsp; 86371397 |&amp;nbsp; 25865942 |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 | 2009-12-06 23:00:36.355251+05:30 | 2009-12-06 23:00:36.355251+05:30&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks in advance for help ...&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&lt;/div&gt;
&lt;!-- cg27.c4.mail.gq1.yahoo.com compressed Mon Dec  7 03:54:00 PST 2009 --&gt;
&lt;/div&gt;&lt;br&gt;

      &lt;/body&gt;&lt;/html&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Query-Performance-tp26676943p26676943.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26663162</id>
	<title>Re: Getting more than one row in UNIQUE fields</title>
	<published>2009-12-06T00:55:43Z</published>
	<updated>2009-12-06T00:55:43Z</updated>
	<author>
		<name>Jasen Betts-5</name>
	</author>
	<content type="html">On 2009-12-04, Another Trad &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26663162&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;anothertrad@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; --001485f94df095921c0479ea62fd
&lt;br&gt;&amp;gt; Content-Type: text/plain; charset=ISO-8859-1
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; My table 'client' has the unique 'client_id'.
&lt;br&gt;&amp;gt; My test server, when I try:
&lt;br&gt;&amp;gt; select * from client where client_id = 12
&lt;br&gt;&amp;gt; My server returns 3 rows!!!!
&lt;br&gt;&lt;br&gt;I had similar with a client on friday, windows event log shouwed disk
&lt;br&gt;errors, chkdsk showed damaged database files.
&lt;br&gt;&lt;br&gt;I passed the problem back to their IT guy.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26663162&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Getting-more-than-one-row-in-UNIQUE-fields-tp26645999p26663162.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26647850</id>
	<title>Re: get sequence name from table name</title>
	<published>2009-12-04T11:24:34Z</published>
	<updated>2009-12-04T11:24:34Z</updated>
	<author>
		<name>Alvaro Herrera-7</name>
	</author>
	<content type="html">Uwe Maiwald wrote:
&lt;br&gt;&amp;gt; how to get the name of the sequence that is responsible for setting
&lt;br&gt;&amp;gt; the autoincrement value of a tables primary key column?
&lt;br&gt;&lt;br&gt;You can use the pg_get_serial_sequence() function. &amp;nbsp;You need the name of
&lt;br&gt;the column in addition to the table name though.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Alvaro Herrera &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://www.CommandPrompt.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.CommandPrompt.com/&lt;/a&gt;&lt;br&gt;The PostgreSQL Company - Command Prompt, Inc.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26647850&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/get-sequence-name-from-table-name-tp26645619p26647850.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26647152</id>
	<title>Re: get sequence name from table name</title>
	<published>2009-12-04T10:02:37Z</published>
	<updated>2009-12-04T10:02:37Z</updated>
	<author>
		<name>Gerardo Herzig</name>
	</author>
	<content type="html">Uwe Maiwald wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; how to get the name of the sequence that is responsible for setting the
&lt;br&gt;&amp;gt; autoincrement value of a tables primary key column?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; i only have the name of the table and need to have an appropiate sql
&lt;br&gt;&amp;gt; statement.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; i need this to write a program that loops through all tables of a
&lt;br&gt;&amp;gt; database and then ajusts the start values of the sequencees in case the
&lt;br&gt;&amp;gt; table has an automatic id value (serial/bigserial)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; thanks,
&lt;br&gt;&amp;gt; Uwe
&lt;br&gt;&amp;gt; 
&lt;/div&gt;The information schema provides what you need.
&lt;br&gt;&lt;br&gt;test=# create table testing (id serial);
&lt;br&gt;NOTICE: &amp;nbsp;CREATE TABLE will create implicit sequence &amp;quot;testing_id_seq&amp;quot; for
&lt;br&gt;serial column &amp;quot;testing.id&amp;quot;
&lt;br&gt;&lt;br&gt;test=# SELECT table_name, column_name, column_default from
&lt;br&gt;information_schema.columns where table_name='testing';
&lt;br&gt;&amp;nbsp;table_name | column_name | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; column_default
&lt;br&gt;------------+-------------+-------------------------------------
&lt;br&gt;&amp;nbsp;testing &amp;nbsp; &amp;nbsp;| id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| nextval('testing_id_seq'::regclass)
&lt;br&gt;(1 row)
&lt;br&gt;&lt;br&gt;You may need an extra work finding out which the primary keys are, look
&lt;br&gt;at the information schema docs [0]. Maybe you will also need the help of
&lt;br&gt;the system catalogs [1].
&lt;br&gt;&lt;br&gt;[0] &lt;a href=&quot;http://www.postgresql.org/docs/8.3/static/information-schema.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/docs/8.3/static/information-schema.html&lt;/a&gt;&lt;br&gt;[1] &lt;a href=&quot;http://www.postgresql.org/docs/8.3/static/catalogs.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/docs/8.3/static/catalogs.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;(as you can see, this docs are from the 8.3 version. Check yours)
&lt;br&gt;&lt;br&gt;HTH
&lt;br&gt;Gerardo
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26647152&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/get-sequence-name-from-table-name-tp26645619p26647152.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26646177</id>
	<title>Re: Getting more than one row in UNIQUE fields</title>
	<published>2009-12-04T09:36:54Z</published>
	<updated>2009-12-04T09:36:54Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">Another Trad &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26646177&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;anothertrad@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; My table 'client' has the unique 'client_id'.
&lt;br&gt;&amp;gt; My test server, when I try:
&lt;br&gt;&amp;gt; select * from client where client_id = 12
&lt;br&gt;&amp;gt; My server returns 3 rows!!!!
&lt;br&gt;&lt;br&gt;We've seen bugs of that sort in the past ... what PG version is this,
&lt;br&gt;and on what platform?
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26646177&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Getting-more-than-one-row-in-UNIQUE-fields-tp26645999p26646177.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26645999</id>
	<title>Getting more than one row in UNIQUE fields</title>
	<published>2009-12-04T09:24:49Z</published>
	<updated>2009-12-04T09:24:49Z</updated>
	<author>
		<name>Another Trad</name>
	</author>
	<content type="html">My table &amp;#39;client&amp;#39; has the unique &amp;#39;client_id&amp;#39;.&lt;br&gt;My test server, when I try:&lt;br&gt;&lt;span style=&quot;font-family: courier new,monospace;&quot;&gt;select * from client where client_id = 12&lt;/span&gt;&lt;br&gt;My server returns 3 rows!!!!&lt;br&gt;
When I try to update this client, his name for example,using my framework (SQLAlchemy), obviously returns the error:&lt;br&gt;&amp;quot;Updated rowcount 3 does not match number of objects updated 1&amp;quot;&lt;br&gt;But the field client_id is unique and has a sequence to auto increment.&lt;br&gt;
&lt;br&gt;Anyone ever pass to this?&lt;br&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Getting-more-than-one-row-in-UNIQUE-fields-tp26645999p26645999.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26645619</id>
	<title>get sequence name from table name</title>
	<published>2009-12-04T08:53:34Z</published>
	<updated>2009-12-04T08:53:34Z</updated>
	<author>
		<name>Uwe Maiwald</name>
	</author>
	<content type="html">how to get the name of the sequence that is responsible for setting the 
&lt;br&gt;autoincrement value of a tables primary key column?
&lt;br&gt;&lt;br&gt;i only have the name of the table and need to have an appropiate sql 
&lt;br&gt;statement.
&lt;br&gt;&lt;br&gt;&lt;br&gt;i need this to write a program that loops through all tables of a 
&lt;br&gt;database and then ajusts the start values of the sequencees in case the 
&lt;br&gt;table has an automatic id value (serial/bigserial)
&lt;br&gt;&lt;br&gt;&lt;br&gt;thanks,
&lt;br&gt;Uwe
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26645619&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/get-sequence-name-from-table-name-tp26645619p26645619.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26631882</id>
	<title>Re: create user xxx with md5 string?</title>
	<published>2009-12-03T11:38:55Z</published>
	<updated>2009-12-03T11:38:55Z</updated>
	<author>
		<name>Dmitriy Igrishin</name>
	</author>
	<content type="html">Sorry for my prev post. I mean md5(password || username).&lt;div&gt;&amp;#39;test10&amp;#39; is a username on which i checked. :) Sorry!&lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/12/3 Dmitriy Igrishin &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631882&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dmitigr@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;Hello all.&lt;div&gt;Tom right. Encrypted MD5 passwords computed as md5(password || test10). I checked.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;
&lt;div&gt;Regards, Dmitriy Igrishin. &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/12/3 Tom Lane &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631882&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tgl@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;h5&quot;&gt;&lt;br&gt;

&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex&quot;&gt;&lt;div&gt;Gerardo Herzig &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631882&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gherzig@...&lt;/a&gt;&amp;gt; writes:&lt;br&gt;
&amp;gt; Hi all. Im triyng, with no success, to create a user, and set the&lt;br&gt;
&amp;gt; password with a md5 string.&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;The correct method for computing the md5&amp;#39;d password includes the&lt;br&gt;
username.  I think it&amp;#39;s &amp;#39;md5&amp;#39; || md5sum(password || username)&lt;br&gt;
but look at the code or docs.&lt;br&gt;
&lt;br&gt;
                        regards, tom lane&lt;br&gt;
&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;
--&lt;br&gt;
Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631882&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)&lt;br&gt;
To make changes to your subscription:&lt;br&gt;
&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/create-user-xxx-with-md5-string--tp26631472p26631882.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26631860</id>
	<title>Re: create user xxx with md5 string?</title>
	<published>2009-12-03T11:36:58Z</published>
	<updated>2009-12-03T11:36:58Z</updated>
	<author>
		<name>Dmitriy Igrishin</name>
	</author>
	<content type="html">Hello all.&lt;div&gt;Tom right. Encrypted MD5 passwords computed as md5(password || test10). I checked.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Regards, Dmitriy Igrishin. &lt;br&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/12/3 Tom Lane &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631860&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tgl@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;&lt;div class=&quot;im&quot;&gt;Gerardo Herzig &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631860&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gherzig@...&lt;/a&gt;&amp;gt; writes:&lt;br&gt;
&amp;gt; Hi all. Im triyng, with no success, to create a user, and set the&lt;br&gt;
&amp;gt; password with a md5 string.&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;The correct method for computing the md5&amp;#39;d password includes the&lt;br&gt;
username.  I think it&amp;#39;s &amp;#39;md5&amp;#39; || md5sum(password || username)&lt;br&gt;
but look at the code or docs.&lt;br&gt;
&lt;br&gt;
                        regards, tom lane&lt;br&gt;
&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;h5&quot;&gt;&lt;br&gt;
--&lt;br&gt;
Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631860&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)&lt;br&gt;
To make changes to your subscription:&lt;br&gt;
&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/create-user-xxx-with-md5-string--tp26631472p26631860.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26631658</id>
	<title>Re: create user xxx with md5 string?</title>
	<published>2009-12-03T11:21:19Z</published>
	<updated>2009-12-03T11:21:19Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">Gerardo Herzig &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631658&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gherzig@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; Hi all. Im triyng, with no success, to create a user, and set the
&lt;br&gt;&amp;gt; password with a md5 string.
&lt;br&gt;&lt;br&gt;The correct method for computing the md5'd password includes the
&lt;br&gt;username. &amp;nbsp;I think it's 'md5' || md5sum(password || username)
&lt;br&gt;but look at the code or docs.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631658&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/create-user-xxx-with-md5-string--tp26631472p26631658.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26631889</id>
	<title>Re: create user xxx with md5 string?</title>
	<published>2009-12-03T11:02:58Z</published>
	<updated>2009-12-03T11:02:58Z</updated>
	<author>
		<name>Gerardo Herzig</name>
	</author>
	<content type="html">Tom Lane wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Gerardo Herzig &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631889&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;gherzig@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt;&amp;gt; Hi all. Im triyng, with no success, to create a user, and set the
&lt;br&gt;&amp;gt;&amp;gt; password with a md5 string.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The correct method for computing the md5'd password includes the
&lt;br&gt;&amp;gt; username. &amp;nbsp;I think it's 'md5' || md5sum(password || username)
&lt;br&gt;&amp;gt; but look at the code or docs.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 			regards, tom lane
&lt;br&gt;&amp;gt; 
&lt;/div&gt;Perfect! I could not find that in the docs.
&lt;br&gt;It works. Thanks!
&lt;br&gt;&lt;br&gt;Gerardo
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631889&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/create-user-xxx-with-md5-string--tp26631472p26631889.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26631472</id>
	<title>create user xxx with md5 string?</title>
	<published>2009-12-03T10:05:02Z</published>
	<updated>2009-12-03T10:05:02Z</updated>
	<author>
		<name>Gerardo Herzig</name>
	</author>
	<content type="html">Hi all. Im triyng, with no success, to create a user, and set the
&lt;br&gt;password with a md5 string.
&lt;br&gt;&lt;br&gt;I did this:
&lt;br&gt;&lt;br&gt;comechingon:~ # echo -n 123 | md5sum
&lt;br&gt;202cb962ac59075b964b07152d234b70 &amp;nbsp;-
&lt;br&gt;&lt;br&gt;&lt;br&gt;Ok, so then
&lt;br&gt;test=# CREATE USER foobar ENCRYPTED PASSWORD
&lt;br&gt;'md5202cb962ac59075b964b07152d234b70'; --I have to add 'md5' at the
&lt;br&gt;begging of the string
&lt;br&gt;CREATE ROLE
&lt;br&gt;&lt;br&gt;&lt;br&gt;test=# SELECT * from pg_shadow where usename='foobar';
&lt;br&gt;&amp;nbsp;usename | usesysid | usecreatedb | usesuper | usecatupd |
&lt;br&gt;&amp;nbsp;passwd &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| valuntil | useconfig
&lt;br&gt;---------+----------+-------------+----------+-----------+-------------------------------------+----------+-----------
&lt;br&gt;&amp;nbsp;foobar &amp;nbsp;| &amp;nbsp;3250592 | f &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | f &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| f &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |
&lt;br&gt;md5202cb962ac59075b964b07152d234b70 | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|
&lt;br&gt;(1 row)
&lt;br&gt;&lt;br&gt;test=# \c test foobar
&lt;br&gt;Password for user foobar: [123, off course]
&lt;br&gt;FATAL: &amp;nbsp;password authentication failed for user &amp;quot;foobar&amp;quot;
&lt;br&gt;Previous connection kept
&lt;br&gt;&lt;br&gt;test=# SHOW server_version;
&lt;br&gt;&amp;nbsp;server_version
&lt;br&gt;----------------
&lt;br&gt;&amp;nbsp;8.3.6
&lt;br&gt;&lt;br&gt;Im wondering which my mystake is:
&lt;br&gt;Using md5sum?
&lt;br&gt;&lt;br&gt;I do have 'md5' as validation mechanism in pg_hba.conf
&lt;br&gt;&lt;br&gt;Any hints?
&lt;br&gt;Thanks!
&lt;br&gt;&lt;br&gt;Gerardo
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26631472&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/create-user-xxx-with-md5-string--tp26631472p26631472.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26586286</id>
	<title>Re: pg_restore followed by immediate VACUUM ANALYZE</title>
	<published>2009-11-30T20:04:29Z</published>
	<updated>2009-11-30T20:04:29Z</updated>
	<author>
		<name>Tom Lane-2</name>
	</author>
	<content type="html">Bryce Nesbitt &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26586286&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;bryce2@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt;&amp;gt; Correct. &amp;nbsp;Autovacuum might fix them eventually, but usually it's
&lt;br&gt;&amp;gt;&amp;gt; worth forcing the issue once you've completed your data loading.
&lt;br&gt;&amp;gt;&amp;gt; (This might involve multiple steps, which is why pg_restore
&lt;br&gt;&amp;gt;&amp;gt; doesn't try to force it for you.)&amp;lt;/pre&amp;gt;
&lt;br&gt;&lt;br&gt;&amp;gt; Hmm.&amp;nbsp; It seems like pg_restore would already know 90% of what it needs
&lt;br&gt;&amp;gt; to in this case.&amp;lt;br&amp;gt;
&lt;br&gt;&lt;br&gt;But of course pg_restore doesn't know what else you might want to do.
&lt;br&gt;&lt;br&gt;&amp;gt; Of course I'm just trying to cut down on the 4+ hour VACUUM ANALYZE.&amp;nbsp;
&lt;br&gt;&lt;br&gt;You could try just ANALYZE without the VACUUM.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; regards, tom lane
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sent via pgsql-sql mailing list (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26586286&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pgsql-sql@...&lt;/a&gt;)
&lt;br&gt;To make changes to your subscription:
&lt;br&gt;&lt;a href=&quot;http://www.postgresql.org/mailpref/pgsql-sql&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.postgresql.org/mailpref/pgsql-sql&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/pg_restore-followed-by-immediate-VACUUM-ANALYZE-tp26586149p26586286.html" />
</entry>

</feed>
