diff --git "a/pgsql-performance.200311" "b/pgsql-performance.200311" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200311" @@ -0,0 +1,25944 @@ +From pgsql-performance-owner@postgresql.org Thu Oct 30 12:44:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76963D1B949 + for ; + Thu, 30 Oct 2003 16:39:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88821-01 + for ; + Thu, 30 Oct 2003 12:38:56 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 2FEE8D1B58D + for ; + Thu, 30 Oct 2003 12:38:54 -0400 (AST) +Received: (qmail 23901 invoked from network); 30 Oct 2003 16:40:09 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 30 Oct 2003 16:40:09 -0000 +Message-ID: <3FA323C2.2060302@trade-india.com> +Date: Fri, 31 Oct 2003 22:08:50 -0500 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <20031029202920.GZ7337@pallas.fsck.com> + <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> + <200310301702.00275.mallah@trade-india.com> + + <13042.61.16.154.82.1067523120.squirrel@mail.trade-india.com> + +In-Reply-To: +Content-Type: multipart/alternative; + boundary="------------000303000106050002000202" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200310/761 +X-Sequence-Number: 4509 + +This is a multi-part message in MIME format. +--------------000303000106050002000202 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +Hi , + +Here are the Execution Plans , +Sorry for the delay . + +Regds +Mallah + + + +On PostgreSQL 7.3.4 + +rt3=# explain SELECT DISTINCT main.* FROM ((((Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance)) +JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3 +ON ( Principals_2.id = CachedGroupMembers_3.GroupId)) JOIN Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id)) +WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( ( ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com') +AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') ) ) +AND ( (main.Status = 'new')OR(main.Status = 'open') ) ) ORDER BY main.Priority DESC LIMIT 10; + + + +Limit (cost=2044.52..2044.58 rows=1 width=195) + -> Unique (cost=2044.52..2044.58 rows=1 width=195) + -> Sort (cost=2044.52..2044.52 rows=1 width=195) + Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled + -> Hash Join (cost=3.98..2044.51 rows=1 width=195) + Hash Cond: ("outer".memberid = "inner".id) + -> Nested Loop (cost=0.00..2040.51 rows=2 width=191) + -> Nested Loop (cost=0.00..1914.41 rows=1 width=183) + -> Nested Loop (cost=0.00..1909.67 rows=1 width=175) + Join Filter: (("outer".id)::text = ("inner".instance)::text) + -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=163) + Filter: ((effectiveid = id) AND ("type" = 'ticket'::character varying) AND ((status = 'new'::character varying) OR (status = 'open'::character varying))) + -> Index Scan using groups_domain on groups groups_1 (cost=0.00..1338.03 rows=7068 width=12) + Index Cond: ("domain" = 'RT::Ticket-Role'::character varying) + Filter: ("type" = 'Requestor'::character varying) + -> Index Scan using principals2 on principals principals_2 (cost=0.00..4.73 rows=1 width=8) + Index Cond: ("outer".id = principals_2.objectid) + Filter: (principaltype = 'Group'::character varying) + -> Index Scan using cachedgroupmembers3 on cachedgroupmembers cachedgroupmembers_3 (cost=0.00..125.54 rows=45 width=8) + Index Cond: ("outer".id = cachedgroupmembers_3.groupid) + -> Hash (cost=3.98..3.98 rows=1 width=4) + -> Index Scan using users4 on users users_4 (cost=0.00..3.98 rows=1 width=4) + Index Cond: (emailaddress = 'mallah_rajesh@yahoo.com'::character varying) +(23 rows) + + +On PostgreSQL 7.4 beta 5 + + +rt3=# explain SELECT DISTINCT main.* FROM ((((Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance)) +JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3 +ON ( Principals_2.id = CachedGroupMembers_3.GroupId)) JOIN Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id)) +WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( ( ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com') +AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') ) ) +AND ( (main.Status = 'new')OR(main.Status = 'open') ) ) ORDER BY main.Priority DESC LIMIT 10; + QUERY PLAN +--------------------------------------------------------------- + Limit (cost=582.27..582.34 rows=1 width=164) + -> Unique (cost=582.27..582.34 rows=1 width=164) + -> Sort (cost=582.27..582.28 rows=1 width=164) + Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled + -> Hash Join (cost=476.18..582.26 rows=1 width=164) + Hash Cond: ("outer".groupid = "inner".id) + -> Nested Loop (cost=0.00..105.97 rows=21 width=4) + -> Index Scan using users4 on users users_4 (cost=0.00..3.99 rows=2 width=4) + Index Cond: ((emailaddress)::text = 'mallah_rajesh@yahoo.com'::text) + -> Index Scan using cachedgroupmembers2 on cachedgroupmembers cachedgroupmembers_3 (cost=0.00..50.81 rows=14 width=8) + Index Cond: (cachedgroupmembers_3.memberid = "outer".id) + -> Hash (cost=476.17..476.17 rows=1 width=168) + -> Nested Loop (cost=0.00..476.17 rows=1 width=168) + -> Nested Loop (cost=0.00..471.54 rows=1 width=168) + -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=164) + Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text))) + -> Index Scan using groups1 on groups groups_1 (cost=0.00..5.90 rows=1 width=12) + Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text)) + -> Index Scan using principals2 on principals principals_2 (cost=0.00..4.62 rows=1 width=8) + Index Cond: ("outer".id = principals_2.objectid) + Filter: ((principaltype)::text = 'Group'::text) +(21 rows) + +rt3=# + + + +Christopher Browne wrote: + +>In the last exciting episode, mallah@trade-india.com wrote: +> +> +>>>mallah@trade-india.com (Rajesh Kumar Mallah) wrote: +>>> +>>> +>>>>Can you please have a Look at the below and suggest why it +>>>>apparently puts 7.3.4 on an infinite loop . the CPU utilisation of the backend running it +>>>>approches 99%. +>>>> +>>>> +>>>What would be useful, for this case, would be to provide the query plan, perhaps via +>>> +>>> EXPLAIN [Big Long Query]. +>>> +>>>The difference between that EXPLAIN and what you get on 7.4 might be quite interesting. +>>> +>>>I would think it quite unlikely that it is truly an "infinite" loop; it is rather more likely +>>>that the plan winds up being pretty bad and doing something [a bunch of nested loops, maybe?] +>>>that run longer than your patience will permit. +>>> +>>> +>>:-) ok i will leave it running and try to get it. +>> +>> +> +>No, if you just do EXPLAIN (and not EXPLAIN ANALYZE), that returns +>without executing the query. +> +>If the query runs for a really long time, then we _know_ that there is +>something troublesome. EXPLAIN (no ANALYZE) should provide some +>insight without having anything run for a long time. +> +>If EXPLAIN [big long query] turns into what you are terming an +>"infinite loop," then you have a quite different problem, and it would +>be very useful to know that. +> +> + + +--------------000303000106050002000202 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+Hi ,
+
+Here are the Execution Plans ,
+Sorry for the delay .
+
+Regds
+Mallah
+

+
+
+On PostgreSQL  7.3.4
+
+
rt3=# explain   SELECT DISTINCT main.* FROM ((((Tickets main  JOIN Groups as Groups_1  ON ( main.id = Groups_1.Instance))  
+JOIN Principals as Principals_2  ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3  
+ON ( Principals_2.id = CachedGroupMembers_3.GroupId))  JOIN Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id))   
+WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( (  ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com')
+AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') )  ) 
+AND ( (main.Status = 'new')OR(main.Status = 'open') ) )  ORDER BY main.Priority DESC LIMIT 10;
+
+
+

+Limit  (cost=2044.52..2044.58 rows=1 width=195)
+   ->  Unique  (cost=2044.52..2044.58 rows=1 width=195)
+         ->  Sort  (cost=2044.52..2044.52 rows=1 width=195)
+               Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled
+               ->  Hash Join  (cost=3.98..2044.51 rows=1 width=195)
+                     Hash Cond: ("outer".memberid = "inner".id)
+                     ->  Nested Loop  (cost=0.00..2040.51 rows=2 width=191)
+                           ->  Nested Loop  (cost=0.00..1914.41 rows=1 width=183)
+                                 ->  Nested Loop  (cost=0.00..1909.67 rows=1 width=175)
+                                       Join Filter: (("outer".id)::text = ("inner".instance)::text)
+                                       ->  Seq Scan on tickets main  (cost=0.00..465.62 rows=1 width=163)
+                                             Filter: ((effectiveid = id) AND ("type" = 'ticket'::character varying) AND ((status = 'new'::character varying) OR (status = 'open'::character varying)))
+                                       ->  Index Scan using groups_domain on groups groups_1  (cost=0.00..1338.03 rows=7068 width=12)
+                                             Index Cond: ("domain" = 'RT::Ticket-Role'::character varying)
+                                             Filter: ("type" = 'Requestor'::character varying)
+                                 ->  Index Scan using principals2 on principals principals_2  (cost=0.00..4.73 rows=1 width=8)
+                                       Index Cond: ("outer".id = principals_2.objectid)
+                                       Filter: (principaltype = 'Group'::character varying)
+                           ->  Index Scan using cachedgroupmembers3 on cachedgroupmembers cachedgroupmembers_3  (cost=0.00..125.54 rows=45 width=8)
+                                 Index Cond: ("outer".id = cachedgroupmembers_3.groupid)
+                     ->  Hash  (cost=3.98..3.98 rows=1 width=4)
+                           ->  Index Scan using users4 on users users_4  (cost=0.00..3.98 rows=1 width=4)
+                                 Index Cond: (emailaddress = 'mallah_rajesh@yahoo.com'::character varying)
+(23 rows)
+
+
+On PostgreSQL 7.4 beta 5
+

+rt3=# explain   SELECT DISTINCT main.* FROM ((((Tickets main  JOIN Groups as Groups_1  ON ( main.id = Groups_1.Instance))  
+JOIN Principals as Principals_2  ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3  
+ON ( Principals_2.id = CachedGroupMembers_3.GroupId))  JOIN Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id))   
+WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( (  ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com')
+AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') )  ) 
+AND ( (main.Status = 'new')OR(main.Status = 'open') ) )  ORDER BY main.Priority DESC LIMIT 10;
+                                                                                                                                                                                                       QUERY PLAN
+---------------------------------------------------------------
+ Limit  (cost=582.27..582.34 rows=1 width=164)
+   ->  Unique  (cost=582.27..582.34 rows=1 width=164)
+         ->  Sort  (cost=582.27..582.28 rows=1 width=164)
+               Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled
+               ->  Hash Join  (cost=476.18..582.26 rows=1 width=164)
+                     Hash Cond: ("outer".groupid = "inner".id)
+                     ->  Nested Loop  (cost=0.00..105.97 rows=21 width=4)
+                           ->  Index Scan using users4 on users users_4  (cost=0.00..3.99 rows=2 width=4)
+                                 Index Cond: ((emailaddress)::text = 'mallah_rajesh@yahoo.com'::text)
+                           ->  Index Scan using cachedgroupmembers2 on cachedgroupmembers cachedgroupmembers_3  (cost=0.00..50.81 rows=14 width=8)
+                                 Index Cond: (cachedgroupmembers_3.memberid = "outer".id)
+                     ->  Hash  (cost=476.17..476.17 rows=1 width=168)
+                           ->  Nested Loop  (cost=0.00..476.17 rows=1 width=168)
+                                 ->  Nested Loop  (cost=0.00..471.54 rows=1 width=168)
+                                       ->  Seq Scan on tickets main  (cost=0.00..465.62 rows=1 width=164)
+                                             Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text)))
+                                       ->  Index Scan using groups1 on groups groups_1  (cost=0.00..5.90 rows=1 width=12)
+                                             Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text))
+                                 ->  Index Scan using principals2 on principals principals_2  (cost=0.00..4.62 rows=1 width=8)
+                                       Index Cond: ("outer".id = principals_2.objectid)
+                                       Filter: ((principaltype)::text = 'Group'::text)
+(21 rows)
+
+rt3=#
+
+
+
+Christopher Browne wrote:
+
+
In the last exciting episode, mallah@trade-india.com wrote:
+  
+
+
+
mallah@trade-india.com (Rajesh Kumar Mallah) wrote:
+      
+
+
Can you please have a Look at the below and suggest why it
+apparently puts 7.3.4 on an infinite loop . the CPU utilisation of the backend running it
+approches 99%.
+        
+
+
What would be useful, for this case, would be to provide the query plan, perhaps via
+
+ EXPLAIN [Big Long Query].
+
+The difference between that EXPLAIN and what you get on 7.4 might be quite interesting.
+
+I would think it quite unlikely that it is truly an "infinite" loop; it is rather more likely
+that the plan winds up being pretty bad and doing something [a bunch of nested loops, maybe?]
+that run longer than your patience will permit.
+      
+
+
:-)   ok i will leave it running and try to get it.
+    
+
+

+No, if you just do EXPLAIN (and not EXPLAIN ANALYZE), that returns
+without executing the query.
+
+If the query runs for a really long time, then we _know_ that there is
+something troublesome.  EXPLAIN (no ANALYZE) should provide some
+insight without having anything run for a long time.
+
+If EXPLAIN [big long query] turns into what you are terming an
+"infinite loop," then you have a quite different problem, and it would
+be very useful to know that.
+  
+
+
+ + + +--------------000303000106050002000202-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 30 13:04:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BE5A0D1B8D7 + for ; + Thu, 30 Oct 2003 16:50:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88821-08 + for ; + Thu, 30 Oct 2003 12:49:56 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 1AD9BD1B923 + for ; + Thu, 30 Oct 2003 12:49:54 -0400 (AST) +Received: (qmail 24761 invoked from network); 30 Oct 2003 16:51:11 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 30 Oct 2003 16:51:11 -0000 +Message-ID: <3FA3265B.6040707@trade-india.com> +Date: Fri, 31 Oct 2003 22:19:55 -0500 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <20031029202920.GZ7337@pallas.fsck.com> + <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> + <200310301702.00275.mallah@trade-india.com> + <28551.1067530272@sss.pgh.pa.us> +In-Reply-To: <28551.1067530272@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------010705060908090409080604" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200310/763 +X-Sequence-Number: 4511 + +This is a multi-part message in MIME format. +--------------010705060908090409080604 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>Rajesh Kumar Mallah writes: +> +> +>>SELECT DISTINCT main.* FROM +>>( +>> ( +>> ( +>> ( +>> Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance) +>> ) JOIN +>> Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId) +>> ) JOIN +>> CachedGroupMembers as CachedGroupMembers_3 ON ( Principals_2.id = CachedGroupMembers_3.GroupId) +>> ) JOIN +>> Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id) +>>) WHERE +>> ... +>> +>> +> +>I think the reason for the performance difference is that 7.3 treats +>JOIN syntax as forcing a particular join order, while 7.4 doesn't. +> + +Just out of curiosity , how does 7.4 determine the optimal Join Order? +is it GEQO in case of 7.4 although i did not enable it explicitly? +Thanks for the reply , I sent the EXPLAINs also just now. + +What i really want is to help improving the Pg specific Component +for DBIx::SearchBuilder. The module is being widely used in +the mod_perl world and has impact on the performance perception +of PostgreSQL. + +> +> regards, tom lane +> +> + + +--------------010705060908090409080604 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Tom Lane wrote:
+
+
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
+  
+
+
SELECT DISTINCT main.* FROM
+(
+   (
+      (
+         (
+            Tickets main  JOIN Groups as Groups_1  ON ( main.id = Groups_1.Instance)
+         )  JOIN
+         Principals as Principals_2  ON ( Groups_1.id = Principals_2.ObjectId)
+      ) JOIN
+      CachedGroupMembers as CachedGroupMembers_3  ON ( Principals_2.id = CachedGroupMembers_3.GroupId)
+   )  JOIN
+   Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id)
+)   WHERE
+ ...
+    
+
+

+I think the reason for the performance difference is that 7.3 treats
+JOIN syntax as forcing a particular join order, while 7.4 doesn't.
+
+
+Just out of curiosity , how does 7.4 determine the optimal Join Order?
+is it GEQO in case of 7.4 although i did not enable it explicitly?
+Thanks for the reply , I sent the EXPLAINs also just now.
+
+What i really want is to help improving the Pg specific Component
+for DBIx::SearchBuilder. The module is being widely used in
+the  mod_perl world and has impact on the performance perception
+of PostgreSQL.
+
+
+
+			regards, tom lane
+  
+
+
+ + + +--------------010705060908090409080604-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 30 15:17:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D439D1B4E1 + for ; + Thu, 30 Oct 2003 19:16:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11759-08 + for ; + Thu, 30 Oct 2003 15:16:29 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 5C145D1B536 + for ; + Thu, 30 Oct 2003 15:16:27 -0400 (AST) +Received: (qmail 6549 invoked from network); 30 Oct 2003 19:17:36 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 30 Oct 2003 19:17:36 -0000 +Message-ID: <3FA34827.1030705@trade-india.com> +Date: Sat, 01 Nov 2003 00:44:07 -0500 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Christopher Browne , pgsql-performance@postgresql.org, + Jesse Vincent +Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <20031029202920.GZ7337@pallas.fsck.com> + <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> + <200310301702.00275.mallah@trade-india.com> + + <13042.61.16.154.82.1067523120.squirrel@mail.trade-india.com> + + <3FA323C2.2060302@trade-india.com> <87r80ud0nw.fsf@stark.dyndns.tv> +In-Reply-To: <87r80ud0nw.fsf@stark.dyndns.tv> +Content-Type: multipart/alternative; + boundary="------------070306070203080407090902" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200310/772 +X-Sequence-Number: 4520 + +This is a multi-part message in MIME format. +--------------070306070203080407090902 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + + +explain analyze of original Query: + +rt3=# explain analyze SELECT DISTINCT main.* FROM Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance) JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId) JOIN CachedGroupMembers as CachedGroupMembers_3 ON ( Principals_2.id = CachedGroupMembers_3.GroupId) JOIN Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id) WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( ( ( (lower(Users_4.EmailAddress) = 'mallah_rajesh@yahoo.com')AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') ) ) AND ( (main.Status = 'new')OR(main.Status = 'open') ) ) ORDER BY main.Priority DESC LIMIT 10; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=619.93..620.00 rows=1 width=164) (actual time=994.570..994.683 rows=4 loops=1) + -> Unique (cost=619.93..620.00 rows=1 width=164) (actual time=994.565..994.672 rows=4 loops=1) + -> Sort (cost=619.93..619.93 rows=1 width=164) (actual time=994.561..994.569 rows=8 loops=1) + Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled + -> Nested Loop (cost=0.00..619.92 rows=1 width=164) (actual time=1.374..993.998 rows=8 loops=1) + -> Nested Loop (cost=0.00..610.83 rows=3 width=168) (actual time=0.691..839.633 rows=9617 loops=1) + -> Nested Loop (cost=0.00..476.17 rows=1 width=168) (actual time=0.524..616.937 rows=3209 loops=1) + -> Nested Loop (cost=0.00..471.54 rows=1 width=168) (actual time=0.376..503.774 rows=3209 loops=1) + -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=164) (actual time=0.114..60.044 rows=3209 loops=1) + Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text))) + -> Index Scan using groups1 on groups groups_1 (cost=0.00..5.90 rows=1 width=12) (actual time=0.111..0.119 rows=1 loops=3209) + Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text)) + -> Index Scan using principals2 on principals principals_2 (cost=0.00..4.62 rows=1 width=8) (actual time=0.015..0.018 rows=1 loops=3209) + Index Cond: ("outer".id = principals_2.objectid) + Filter: ((principaltype)::text = 'Group'::text) + -> Index Scan using cachedgroupmembers3 on cachedgroupmembers cachedgroupmembers_3 (cost=0.00..134.06 rows=47 width=8) (actual time=0.015..0.026 rows=3 loops=3209) + Index Cond: ("outer".id = cachedgroupmembers_3.groupid) + -> Index Scan using users_pkey on users users_4 (cost=0.00..3.02 rows=1 width=4) (actual time=0.013..0.013 rows=0 loops=9617) + Index Cond: ("outer".memberid = users_4.id) + Filter: (lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text) + Total runtime: 995.326 ms +(21 rows) +rt3=# + +999 ms is not that bad but u think it deserves this many ms? + + +Nopes the query are not Equiv , earlier one returns 4 rows and the below +one none, +can you spot any obvious and resend plz. thats why i did not do an +explain analyze + +rt3=# SELECT * +rt3-# FROM tickets +rt3-# WHERE id IN ( +rt3(# SELECT groups.instance +rt3(# FROM groups +rt3(# JOIN principals ON (groups.id = principals.objectid) +rt3(# JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid) +rt3(# JOIN users ON (cachedgroupmembers.memberid = users.id) +rt3(# WHERE users.emailaddress = 'mallah_rajesh@yahoo.com' +rt3(# AND groups.domain = 'RT::Ticket-Role' +rt3(# AND groups.type = 'Requestor' +rt3(# AND principals.principaltype = 'group' +rt3(# ) +rt3-# AND type = 'ticket' +rt3-# AND effectiveid = tickets.id +rt3-# AND (status = 'new' OR status = 'open') +rt3-# ORDER BY priority DESC +rt3-# LIMIT 10; + + id | effectiveid | queue | type | issuestatement | resolution | owner | subject | initialpriority | finalpriority | priority | timeestimated | timeworked | status | timeleft | told | starts | started | due | resolved | lastupdatedby | lastupdated | creator | created | disabled +----+-------------+-------+------+----------------+------------+-------+---------+-----------------+---------------+----------+---------------+------------+--------+----------+------+--------+---------+-----+----------+---------------+-------------+---------+---------+---------- +(0 rows) + +Time: 2670.85 ms +rt3=# + + + +Well it may be of interest to write the query in best possible way +but i am not sure if it really helps the RT application becoz i do +not know whether DBIx::SearchBuilder would currently allow +auto generation of such arbitrary SQLs. + +Regds +Mallah. + + + + +Greg Stark wrote: + +>Rajesh Kumar Mallah writes: +> +> +> +>>rt3=# explain +>> +>>SELECT DISTINCT main.* +>> FROM ((( +>> (Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance)) +>> JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId) +>> ) JOIN CachedGroupMembers as CachedGroupMembers_3 ON ( Principals_2.id = CachedGroupMembers_3.GroupId) +>> ) JOIN Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id) +>> ) +>> WHERE ((main.EffectiveId = main.id)) +>> AND ((main.Type = 'ticket')) +>> AND ((( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com') +>> AND (Groups_1.Domain = 'RT::Ticket-Role') +>> AND (Groups_1.Type = 'Requestor') +>> AND (Principals_2.PrincipalType = 'Group') +>> )) +>> AND ((main.Status = 'new') OR (main.Status = 'open')) +>> ) +>> ORDER BY main.Priority DESC LIMIT 10; +>> +>> +> +>So this query seems to be going the long way around to do the equivalent of an +>IN clause. Presumably because as far as I know mysql didn't support IN +>subqueries until recently. +> +>Can you do an "explain analyze" on the above query and the following rewritten +>one in 7.4? The "analyze" is important because it'll give real timing +>information. And it's important that it be on 7.4 as there were improvements +>in this area specifically in 7.4. +> +>SELECT * +> FROM tickets +> WHERE id IN ( +> SELECT groups.instance +> FROM groups +> JOIN principals ON (groups.id = principals.objectid) +> JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid) +> JOIN users ON (cachedgroupmembers.memberid = users.id) +> WHERE users.emailaddress = 'mallah_rajesh@yahoo.com' +> AND groups.domain = 'RT::Ticket-Role' +> AND groups.type = 'Requestor' +> AND principals.principaltype = 'group' +> ) +> AND type = 'ticket' +> AND effectiveid = tickets.id +> AND (status = 'new' OR status = 'open') +>ORDER BY priority DESC +>LIMIT 10; +> +> +> +> +> +> +> +> +> + + +--------------070306070203080407090902 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+
+explain analyze of original Query:
+
+
rt3=# explain analyze SELECT DISTINCT main.* FROM Tickets main  JOIN Groups as Groups_1  ON ( main.id = Groups_1.Instance)   JOIN Principals as Principals_2  ON ( Groups_1.id = Principals_2.ObjectId)   JOIN CachedGroupMembers as CachedGroupMembers_3  ON ( Principals_2.id = CachedGroupMembers_3.GroupId)   JOIN Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id)    WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( (  ( (lower(Users_4.EmailAddress) = 'mallah_rajesh@yahoo.com')AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') )  ) AND ( (main.Status = 'new')OR(main.Status = 'open') ) )  ORDER BY main.Priority DESC LIMIT 10;
+                                                                                                                                                                                                       QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Limit  (cost=619.93..620.00 rows=1 width=164) (actual time=994.570..994.683 rows=4 loops=1)
+   ->  Unique  (cost=619.93..620.00 rows=1 width=164) (actual time=994.565..994.672 rows=4 loops=1)
+         ->  Sort  (cost=619.93..619.93 rows=1 width=164) (actual time=994.561..994.569 rows=8 loops=1)
+               Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled
+               ->  Nested Loop  (cost=0.00..619.92 rows=1 width=164) (actual time=1.374..993.998 rows=8 loops=1)
+                     ->  Nested Loop  (cost=0.00..610.83 rows=3 width=168) (actual time=0.691..839.633 rows=9617 loops=1)
+                           ->  Nested Loop  (cost=0.00..476.17 rows=1 width=168) (actual time=0.524..616.937 rows=3209 loops=1)
+                                 ->  Nested Loop  (cost=0.00..471.54 rows=1 width=168) (actual time=0.376..503.774 rows=3209 loops=1)
+                                       ->  Seq Scan on tickets main  (cost=0.00..465.62 rows=1 width=164) (actual time=0.114..60.044 rows=3209 loops=1)
+                                             Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text)))
+                                       ->  Index Scan using groups1 on groups groups_1  (cost=0.00..5.90 rows=1 width=12) (actual time=0.111..0.119 rows=1 loops=3209)
+                                             Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text))
+                                 ->  Index Scan using principals2 on principals principals_2  (cost=0.00..4.62 rows=1 width=8) (actual time=0.015..0.018 rows=1 loops=3209)
+                                       Index Cond: ("outer".id = principals_2.objectid)
+                                       Filter: ((principaltype)::text = 'Group'::text)
+                           ->  Index Scan using cachedgroupmembers3 on cachedgroupmembers cachedgroupmembers_3  (cost=0.00..134.06 rows=47 width=8) (actual time=0.015..0.026 rows=3 loops=3209)
+                                 Index Cond: ("outer".id = cachedgroupmembers_3.groupid)
+                     ->  Index Scan using users_pkey on users users_4  (cost=0.00..3.02 rows=1 width=4) (actual time=0.013..0.013 rows=0 loops=9617)
+                           Index Cond: ("outer".memberid = users_4.id)
+                           Filter: (lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text)
+ Total runtime: 995.326 ms
+(21 rows)
+rt3=#
+
+999 ms is not that bad but u think it deserves this many ms?
+
+
+Nopes the query are not Equiv , earlier one returns 4 rows and the +below one none,
+can you spot any obvious and resend plz. thats why i did not do an +explain analyze
+
rt3=# SELECT *
+rt3-#   FROM tickets
+rt3-#  WHERE id IN (
+rt3(#        SELECT groups.instance
+rt3(#          FROM groups
+rt3(#          JOIN principals ON (groups.id = principals.objectid)
+rt3(#          JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid)
+rt3(#          JOIN users ON (cachedgroupmembers.memberid = users.id)
+rt3(#         WHERE users.emailaddress = 'mallah_rajesh@yahoo.com'
+rt3(#           AND groups.domain = 'RT::Ticket-Role'
+rt3(#           AND groups.type   = 'Requestor'
+rt3(#           AND principals.principaltype = 'group'
+rt3(#   )
+rt3-#   AND type = 'ticket'
+rt3-#   AND effectiveid = tickets.id
+rt3-#   AND (status = 'new' OR status = 'open')
+rt3-# ORDER BY priority DESC
+rt3-# LIMIT 10;
+
+ id | effectiveid | queue | type | issuestatement | resolution | owner | subject | initialpriority | finalpriority | priority | timeestimated | timeworked | status | timeleft | told | starts | started | due | resolved | lastupdatedby | lastupdated | creator | created | disabled
+----+-------------+-------+------+----------------+------------+-------+---------+-----------------+---------------+----------+---------------+------------+--------+----------+------+--------+---------+-----+----------+---------------+-------------+---------+---------+----------
+(0 rows)
+
+Time: 2670.85 ms
+rt3=#
+
+
+
+Well it may be of interest to write the query in best possible way
+but i am not sure if it really helps the RT application becoz i do
+not know whether DBIx::SearchBuilder would currently allow
+auto generation of such arbitrary SQLs.
+
+Regds
+Mallah.
+
+
+
+
+Greg Stark wrote:
+
+
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
+
+  
+
+
rt3=# explain 
+
+SELECT DISTINCT main.* 
+  FROM (((
+          (Tickets main  JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance))
+          JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId)
+         ) JOIN CachedGroupMembers as CachedGroupMembers_3  ON ( Principals_2.id = CachedGroupMembers_3.GroupId)
+        ) JOIN Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id)
+       )
+ WHERE ((main.EffectiveId = main.id))
+   AND ((main.Type = 'ticket'))
+   AND (((    (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com')
+          AND (Groups_1.Domain = 'RT::Ticket-Role')
+          AND (Groups_1.Type = 'Requestor')
+          AND (Principals_2.PrincipalType = 'Group')
+         ))
+         AND ((main.Status = 'new') OR (main.Status = 'open'))
+       )
+ ORDER BY main.Priority DESC LIMIT 10;
+    
+
+

+So this query seems to be going the long way around to do the equivalent of an
+IN clause. Presumably because as far as I know mysql didn't support IN
+subqueries until recently.
+
+Can you do an "explain analyze" on the above query and the following rewritten
+one in 7.4? The "analyze" is important because it'll give real timing
+information. And it's important that it be on 7.4 as there were improvements
+in this area specifically in 7.4.
+
+SELECT * 
+  FROM tickets
+ WHERE id IN (
+       SELECT groups.instance
+         FROM groups 
+         JOIN principals ON (groups.id = principals.objectid) 
+         JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid)
+         JOIN users ON (cachedgroupmembers.memberid = users.id)
+        WHERE users.emailaddress = 'mallah_rajesh@yahoo.com'
+          AND groups.domain = 'RT::Ticket-Role'
+          AND groups.type   = 'Requestor'
+          AND principals.principaltype = 'group'
+  )
+  AND type = 'ticket'
+  AND effectiveid = tickets.id 
+  AND (status = 'new' OR status = 'open')
+ORDER BY priority DESC 
+LIMIT 10;
+       
+
+
+
+
+
+
+  
+
+
+ + + +--------------070306070203080407090902-- + + +From pgsql-performance-owner@postgresql.org Sat Nov 1 01:48:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9938D1B53E + for ; + Sat, 1 Nov 2003 05:48:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57325-08 + for ; + Sat, 1 Nov 2003 01:47:51 -0400 (AST) +Received: from rtlocal.trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id A6EA1D1B509 + for ; + Sat, 1 Nov 2003 01:47:47 -0400 (AST) +Received: (qmail 5547 invoked from network); 1 Nov 2003 06:04:40 -0000 +Received: from unknown (HELO trade-india.com) (unknown) + by unknown with SMTP; 1 Nov 2003 06:04:40 -0000 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +To: Greg Stark +Subject: [ PROBLEM SOLVED ] Re: Query puts 7.3.4 on endless loop but 7.4beta5 + is fine. +Date: Sat, 1 Nov 2003 11:17:02 +0530 +User-Agent: KMail/1.5.1 +Cc: Christopher Browne , pgsql-performance@postgresql.org, + Jesse Vincent +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <3FA34827.1030705@trade-india.com> <87vfq6bbbn.fsf@stark.dyndns.tv> +In-Reply-To: <87vfq6bbbn.fsf@stark.dyndns.tv> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311011117.02662.mallah@trade-india.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1 +X-Sequence-Number: 4561 + + + +Well Sorry everyone , + +The problem was tracked down to a silly +datatype mismatch between two join columns +in table Groups(instance) and Tickets(id) +(int vs varchar ) + +7.4b5 is automatically taking care of this +mismatch hence it was getting executed there. + +But , The problem is will this behaviour not +allow to go such mistakes unnoticed? + + +Regards +Mallah. + + +On Friday 31 Oct 2003 4:08 am, Greg Stark wrote: +> Well, you might want to try the EXISTS version. I'm not sure if it'll be +> faster or slower though. In theory it should be the same. +> +> Hum, I didn't realize the principals table was the largest table. But +> Postgres knew that so one would expect it to have found a better plan. The +> IN/EXISTS handling was recently much improved but perhaps there's still +> room :) +> +> SELECT * +> FROM tickets +> WHERE EXISTS ( +> SELECT 1 +> FROM groups +> JOIN principals ON (groups.id = principals.objectid) +> JOIN cachedgroupmembers ON (principals.id = +> cachedgroupmembers.groupid) JOIN users ON (cachedgroupmembers.memberid = +> users.id) +> WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' +> AND groups.domain = 'RT::Ticket-Role' +> AND groups.type = 'Requestor' +> AND principals.principaltype = 'group' +> AND groups.instance = tickets.id +> ) +> AND type = 'ticket' +> AND effectiveid = tickets.id +> AND (status = 'new' OR status = 'open') +> ORDER BY priority DESC +> LIMIT 10; + + +From pgsql-performance-owner@postgresql.org Thu Oct 30 18:01:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 910DAD1B4E9 + for ; + Thu, 30 Oct 2003 22:01:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44529-02 + for ; + Thu, 30 Oct 2003 18:01:09 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id A5467D1B511 + for ; + Thu, 30 Oct 2003 18:01:06 -0400 (AST) +Received: (qmail 25831 invoked from network); 30 Oct 2003 22:02:26 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 30 Oct 2003 22:02:26 -0000 +Message-ID: <3FA36F4C.2000509@trade-india.com> +Date: Sat, 01 Nov 2003 03:31:08 -0500 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Christopher Browne , pgsql-performance@postgresql.org, + Jesse Vincent +Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <20031029202920.GZ7337@pallas.fsck.com> + <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> + <200310301702.00275.mallah@trade-india.com> + + <13042.61.16.154.82.1067523120.squirrel@mail.trade-india.com> + + <3FA323C2.2060302@trade-india.com> <87r80ud0nw.fsf@stark.dyndns.tv> + <3FA34827.1030705@trade-india.com> <87ad7icsxw.fsf@stark.dyndns.tv> +In-Reply-To: <87ad7icsxw.fsf@stark.dyndns.tv> +Content-Type: multipart/alternative; + boundary="------------040101020809020906010105" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200310/780 +X-Sequence-Number: 4528 + +This is a multi-part message in MIME format. +--------------040101020809020906010105 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +The g in group had to be uppercased, the query produced the same results +but performance was worse for the IN version . 2367 ms vs 600 ms + +rt3=# explain analyze SELECT * from tickets where id in ( SELECT groups.instance FROM groups + JOIN principals ON (groups.id = principals.objectid) JOIN cachedgroupmembers ON +(principals.id = cachedgroupmembers.groupid) JOIN users ON (cachedgroupmembers.memberid = users.id) +WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' AND groups.domain = 'RT::Ticket-Role' +AND groups.type = 'Requestor' AND principals.principaltype = 'Group' ) AND type = 'ticket' AND +effectiveid = tickets.id AND (status = 'new' OR status = 'open') ORDER BY priority DESC LIMIT 10;; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=10078.18..10078.19 rows=1 width=164) (actual time=2367.084..2367.096 rows=4 loops=1) + -> Sort (cost=10078.18..10078.19 rows=1 width=164) (actual time=2367.078..2367.082 rows=4 loops=1) + Sort Key: tickets.priority + -> Hash Join (cost=10077.65..10078.17 rows=1 width=164) (actual time=2366.870..2367.051 rows=4 loops=1) + Hash Cond: (("outer".instance)::text = ("inner".id)::text) + -> HashAggregate (cost=9612.02..9612.02 rows=69 width=8) (actual time=2303.792..2303.810 rows=7 loops=1) + -> Hash Join (cost=4892.97..9611.85 rows=69 width=8) (actual time=1427.260..2303.685 rows=14 loops=1) + Hash Cond: ("outer".memberid = "inner".id) + -> Hash Join (cost=4523.65..9139.45 rows=13651 width=12) (actual time=948.960..2258.529 rows=31123 loops=1) + Hash Cond: ("outer".groupid = "inner".id) + -> Seq Scan on cachedgroupmembers (cost=0.00..3456.51 rows=204551 width=8) (actual time=0.048..365.147 rows=204551 loops=1) + -> Hash (cost=4509.93..4509.93 rows=5488 width=12) (actual time=948.843..948.843 rows=0 loops=1) + -> Hash Join (cost=1409.91..4509.93 rows=5488 width=12) (actual time=315.722..930.025 rows=10431 loops=1) + Hash Cond: ("outer".objectid = "inner".id) + -> Seq Scan on principals (cost=0.00..1583.76 rows=62625 width=8) (actual time=0.043..251.142 rows=62097 loops=1) + Filter: ((principaltype)::text = 'Group'::text) + -> Hash (cost=1359.90..1359.90 rows=7204 width=12) (actual time=315.458..315.458 rows=0 loops=1) + -> Index Scan using groups_domain on groups (cost=0.00..1359.90 rows=7204 width=12) (actual time=0.325..297.403 rows=10431 loops=1) + Index Cond: (("domain")::text = 'RT::Ticket-Role'::text) + Filter: (("type")::text = 'Requestor'::text) + -> Hash (cost=369.08..369.08 rows=101 width=4) (actual time=0.157..0.157 rows=0 loops=1) + -> Index Scan using users_emailaddress_lower on users (cost=0.00..369.08 rows=101 width=4) (actual time=0.139..0.143 rows=1 loops=1) + Index Cond: (lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text) + -> Hash (cost=465.62..465.62 rows=1 width=164) (actual time=62.944..62.944 rows=0 loops=1) + -> Seq Scan on tickets (cost=0.00..465.62 rows=1 width=164) (actual time=0.113..52.729 rows=3208 loops=1) + Filter: ((("type")::text = 'ticket'::text) AND (effectiveid = id) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text))) + Total runtime: 2367.908 ms +(27 rows) + + + +rt3=# explain analyze SELECT DISTINCT main.* FROM ((((Tickets main JOIN Groups as Groups_1 ON ( main.id = Groups_1.Instance)) +rt3(# JOIN Principals as Principals_2 ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3 +rt3(# ON ( Principals_2.id = CachedGroupMembers_3.GroupId)) JOIN Users as Users_4 ON ( CachedGroupMembers_3.MemberId = Users_4.id)) +rt3-# WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( ( ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com') +rt3(# AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') ) ) +rt3(# AND ( (main.Status = 'new')OR(main.Status = 'open') ) ) ORDER BY main.Priority DESC LIMIT 10; + + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=582.27..582.34 rows=1 width=164) (actual time=592.406..592.529 rows=4 loops=1) + -> Unique (cost=582.27..582.34 rows=1 width=164) (actual time=592.401..592.516 rows=4 loops=1) + -> Sort (cost=582.27..582.28 rows=1 width=164) (actual time=592.398..592.406 rows=8 loops=1) + Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled + -> Hash Join (cost=476.18..582.26 rows=1 width=164) (actual time=591.548..592.211 rows=8 loops=1) + Hash Cond: ("outer".groupid = "inner".id) + -> Nested Loop (cost=0.00..105.97 rows=21 width=4) (actual time=0.214..0.645 rows=37 loops=1) + -> Index Scan using users4 on users users_4 (cost=0.00..3.99 rows=2 width=4) (actual time=0.107..0.112 rows=1 loops=1) + Index Cond: ((emailaddress)::text = 'mallah_rajesh@yahoo.com'::text) + -> Index Scan using cachedgroupmembers2 on cachedgroupmembers cachedgroupmembers_3 (cost=0.00..50.81 rows=14 width=8) (actual time=0.098..0.441 rows=37 loops=1) + Index Cond: (cachedgroupmembers_3.memberid = "outer".id) + -> Hash (cost=476.17..476.17 rows=1 width=168) (actual time=591.121..591.121 rows=0 loops=1) + -> Nested Loop (cost=0.00..476.17 rows=1 width=168) (actual time=0.391..583.085 rows=3208 loops=1) + -> Nested Loop (cost=0.00..471.54 rows=1 width=168) (actual time=0.309..474.968 rows=3208 loops=1) + -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=164) (actual time=0.111..56.930 rows=3208 loops=1) + Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text))) + -> Index Scan using groups1 on groups groups_1 (cost=0.00..5.90 rows=1 width=12) (actual time=0.105..0.112 rows=1 loops=3208) + Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text)) + -> Index Scan using principals2 on principals principals_2 (cost=0.00..4.62 rows=1 width=8) (actual time=0.014..0.017 rows=1 loops=3208) + Index Cond: ("outer".id = principals_2.objectid) + Filter: ((principaltype)::text = 'Group'::text) + Total runtime: 593.062 ms +(22 rows) + + + + +Regds +Mallah. + +Greg Stark wrote: + +>Rajesh Kumar Mallah writes: +> +> +> +>>Nopes the query are not Equiv , earlier one returns 4 rows and the below one +>>none, +>> +>> +> +>Sorry, i lowercased a string constant and dropped the lower() on email. +> +>Try this: +> +>SELECT * +> FROM tickets +> WHERE id IN ( +> SELECT groups.instance +> FROM groups +> JOIN principals ON (groups.id = principals.objectid) +> JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid) +> JOIN users ON (cachedgroupmembers.memberid = users.id) +> WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' +> AND groups.domain = 'RT::Ticket-Role' +> AND groups.type = 'Requestor' +> AND principals.principaltype = 'group' +> ) +> AND type = 'ticket' +> AND effectiveid = tickets.id +> AND (status = 'new' OR status = 'open') +>ORDER BY priority DESC +>LIMIT 10; +> +> +> + + +--------------040101020809020906010105 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+The g in group had to be uppercased, the query produced the same results
+but performance was worse  for the IN version .  2367 ms vs 600 ms
+
rt3=# explain analyze SELECT  * from tickets where id in (  SELECT groups.instance FROM groups
+ JOIN principals ON (groups.id = principals.objectid) JOIN cachedgroupmembers ON 
+(principals.id = cachedgroupmembers.groupid) JOIN users ON (cachedgroupmembers.memberid = users.id)  
+WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' AND groups.domain = 'RT::Ticket-Role' 
+AND groups.type   = 'Requestor' AND principals.principaltype = 'Group' ) AND type = 'ticket' AND 
+effectiveid = tickets.id AND (status = 'new' OR status = 'open') ORDER BY priority DESC LIMIT 10;;
+
+                                                                                       QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Limit  (cost=10078.18..10078.19 rows=1 width=164) (actual time=2367.084..2367.096 rows=4 loops=1)
+   ->  Sort  (cost=10078.18..10078.19 rows=1 width=164) (actual time=2367.078..2367.082 rows=4 loops=1)
+         Sort Key: tickets.priority
+         ->  Hash Join  (cost=10077.65..10078.17 rows=1 width=164) (actual time=2366.870..2367.051 rows=4 loops=1)
+               Hash Cond: (("outer".instance)::text = ("inner".id)::text)
+               ->  HashAggregate  (cost=9612.02..9612.02 rows=69 width=8) (actual time=2303.792..2303.810 rows=7 loops=1)
+                     ->  Hash Join  (cost=4892.97..9611.85 rows=69 width=8) (actual time=1427.260..2303.685 rows=14 loops=1)
+                           Hash Cond: ("outer".memberid = "inner".id)
+                           ->  Hash Join  (cost=4523.65..9139.45 rows=13651 width=12) (actual time=948.960..2258.529 rows=31123 loops=1)
+                                 Hash Cond: ("outer".groupid = "inner".id)
+                                 ->  Seq Scan on cachedgroupmembers  (cost=0.00..3456.51 rows=204551 width=8) (actual time=0.048..365.147 rows=204551 loops=1)
+                                 ->  Hash  (cost=4509.93..4509.93 rows=5488 width=12) (actual time=948.843..948.843 rows=0 loops=1)
+                                       ->  Hash Join  (cost=1409.91..4509.93 rows=5488 width=12) (actual time=315.722..930.025 rows=10431 loops=1)
+                                             Hash Cond: ("outer".objectid = "inner".id)
+                                             ->  Seq Scan on principals  (cost=0.00..1583.76 rows=62625 width=8) (actual time=0.043..251.142 rows=62097 loops=1)
+                                                   Filter: ((principaltype)::text = 'Group'::text)
+                                             ->  Hash  (cost=1359.90..1359.90 rows=7204 width=12) (actual time=315.458..315.458 rows=0 loops=1)
+                                                   ->  Index Scan using groups_domain on groups  (cost=0.00..1359.90 rows=7204 width=12) (actual time=0.325..297.403 rows=10431 loops=1)
+                                                         Index Cond: (("domain")::text = 'RT::Ticket-Role'::text)
+                                                         Filter: (("type")::text = 'Requestor'::text)
+                           ->  Hash  (cost=369.08..369.08 rows=101 width=4) (actual time=0.157..0.157 rows=0 loops=1)
+                                 ->  Index Scan using users_emailaddress_lower on users  (cost=0.00..369.08 rows=101 width=4) (actual time=0.139..0.143 rows=1 loops=1)
+                                       Index Cond: (lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text)
+               ->  Hash  (cost=465.62..465.62 rows=1 width=164) (actual time=62.944..62.944 rows=0 loops=1)
+                     ->  Seq Scan on tickets  (cost=0.00..465.62 rows=1 width=164) (actual time=0.113..52.729 rows=3208 loops=1)
+                           Filter: ((("type")::text = 'ticket'::text) AND (effectiveid = id) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text)))
+ Total runtime: 2367.908 ms
+(27 rows)
+
+
+
+rt3=# explain analyze SELECT DISTINCT main.* FROM ((((Tickets main  JOIN Groups as Groups_1  ON ( main.id = Groups_1.Instance))
+rt3(# JOIN Principals as Principals_2  ON ( Groups_1.id = Principals_2.ObjectId)) JOIN CachedGroupMembers as CachedGroupMembers_3
+rt3(# ON ( Principals_2.id = CachedGroupMembers_3.GroupId))  JOIN Users as Users_4  ON ( CachedGroupMembers_3.MemberId = Users_4.id))
+rt3-# WHERE ((main.EffectiveId = main.id)) AND ((main.Type = 'ticket')) AND ( (  ( (Users_4.EmailAddress = 'mallah_rajesh@yahoo.com')
+rt3(# AND(Groups_1.Domain = 'RT::Ticket-Role')AND(Groups_1.Type = 'Requestor')AND(Principals_2.PrincipalType = 'Group') )  )
+rt3(# AND ( (main.Status = 'new')OR(main.Status = 'open') ) )  ORDER BY main.Priority DESC LIMIT 10;
+
+
+                                                                                                                                                                                                       QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Limit  (cost=582.27..582.34 rows=1 width=164) (actual time=592.406..592.529 rows=4 loops=1)
+   ->  Unique  (cost=582.27..582.34 rows=1 width=164) (actual time=592.401..592.516 rows=4 loops=1)
+         ->  Sort  (cost=582.27..582.28 rows=1 width=164) (actual time=592.398..592.406 rows=8 loops=1)
+               Sort Key: main.priority, main.id, main.effectiveid, main.queue, main."type", main.issuestatement, main.resolution, main."owner", main.subject, main.initialpriority, main.finalpriority, main.timeestimated, main.timeworked, main.status, main.timeleft, main.told, main.starts, main.started, main.due, main.resolved, main.lastupdatedby, main.lastupdated, main.creator, main.created, main.disabled
+               ->  Hash Join  (cost=476.18..582.26 rows=1 width=164) (actual time=591.548..592.211 rows=8 loops=1)
+                     Hash Cond: ("outer".groupid = "inner".id)
+                     ->  Nested Loop  (cost=0.00..105.97 rows=21 width=4) (actual time=0.214..0.645 rows=37 loops=1)
+                           ->  Index Scan using users4 on users users_4  (cost=0.00..3.99 rows=2 width=4) (actual time=0.107..0.112 rows=1 loops=1)
+                                 Index Cond: ((emailaddress)::text = 'mallah_rajesh@yahoo.com'::text)
+                           ->  Index Scan using cachedgroupmembers2 on cachedgroupmembers cachedgroupmembers_3  (cost=0.00..50.81 rows=14 width=8) (actual time=0.098..0.441 rows=37 loops=1)
+                                 Index Cond: (cachedgroupmembers_3.memberid = "outer".id)
+                     ->  Hash  (cost=476.17..476.17 rows=1 width=168) (actual time=591.121..591.121 rows=0 loops=1)
+                           ->  Nested Loop  (cost=0.00..476.17 rows=1 width=168) (actual time=0.391..583.085 rows=3208 loops=1)
+                                 ->  Nested Loop  (cost=0.00..471.54 rows=1 width=168) (actual time=0.309..474.968 rows=3208 loops=1)
+                                       ->  Seq Scan on tickets main  (cost=0.00..465.62 rows=1 width=164) (actual time=0.111..56.930 rows=3208 loops=1)
+                                             Filter: ((effectiveid = id) AND (("type")::text = 'ticket'::text) AND (((status)::text = 'new'::text) OR ((status)::text = 'open'::text)))
+                                       ->  Index Scan using groups1 on groups groups_1  (cost=0.00..5.90 rows=1 width=12) (actual time=0.105..0.112 rows=1 loops=3208)
+                                             Index Cond: (((groups_1."domain")::text = 'RT::Ticket-Role'::text) AND (("outer".id)::text = (groups_1.instance)::text) AND ((groups_1."type")::text = 'Requestor'::text))
+                                 ->  Index Scan using principals2 on principals principals_2  (cost=0.00..4.62 rows=1 width=8) (actual time=0.014..0.017 rows=1 loops=3208)
+                                       Index Cond: ("outer".id = principals_2.objectid)
+                                       Filter: ((principaltype)::text = 'Group'::text)
+ Total runtime: 593.062 ms
+(22 rows)
+
+
+
+
+
+Regds
+Mallah.
+
+Greg Stark wrote:
+
+
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
+
+  
+
+
Nopes the query are not Equiv , earlier one returns 4 rows and the below one
+none,
+    
+
+

+Sorry, i lowercased a string constant and dropped the lower() on email. 
+
+Try this:
+
+SELECT *
+  FROM tickets
+ WHERE id IN (
+       SELECT groups.instance
+         FROM groups
+         JOIN principals ON (groups.id = principals.objectid)
+         JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid)
+         JOIN users ON (cachedgroupmembers.memberid = users.id)
+        WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com'
+          AND groups.domain = 'RT::Ticket-Role'
+          AND groups.type   = 'Requestor'
+          AND principals.principaltype = 'group'
+  )
+  AND type = 'ticket'
+  AND effectiveid = tickets.id
+  AND (status = 'new' OR status = 'open')
+ORDER BY priority DESC
+LIMIT 10;
+
+  
+
+
+ + + +--------------040101020809020906010105-- + + +From pgsql-performance-owner@postgresql.org Thu Oct 30 18:21:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B13F1D1B50E + for ; + Thu, 30 Oct 2003 22:21:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44626-10 + for ; + Thu, 30 Oct 2003 18:21:00 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id C57A2D1B8A0 + for ; + Thu, 30 Oct 2003 18:20:57 -0400 (AST) +Received: (qmail 27522 invoked from network); 30 Oct 2003 22:22:17 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 30 Oct 2003 22:22:17 -0000 +Message-ID: <3FA373F3.9040103@trade-india.com> +Date: Sat, 01 Nov 2003 03:50:59 -0500 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Christopher Browne , pgsql-performance@postgresql.org, + Jesse Vincent +Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. +References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> + <20031029202920.GZ7337@pallas.fsck.com> + <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> + <200310301702.00275.mallah@trade-india.com> + + <13042.61.16.154.82.1067523120.squirrel@mail.trade-india.com> + + <3FA323C2.2060302@trade-india.com> <87r80ud0nw.fsf@stark.dyndns.tv> + <3FA34827.1030705@trade-india.com> <87ad7icsxw.fsf@stark.dyndns.tv> +In-Reply-To: <87ad7icsxw.fsf@stark.dyndns.tv> +Content-Type: multipart/alternative; + boundary="------------060402080107040008000108" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200310/781 +X-Sequence-Number: 4529 + +This is a multi-part message in MIME format. +--------------060402080107040008000108 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +But the new version at lease works on 7.3 instead of putting +it in an infinite loop. + + +rt3=# explain analyze SELECT * from tickets where id in ( SELECT +groups.instance FROM groups +rt3(# JOIN principals ON (groups.id = principals.objectid) JOIN +cachedgroupmembers ON +rt3(# (principals.id = cachedgroupmembers.groupid) JOIN users ON +(cachedgroupmembers.memberid = users.id) +rt3(# WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' AND +groups.domain = 'RT::Ticket-Role' +rt3(# AND groups.type = 'Requestor' AND principals.principaltype = +'Group' ) AND type = 'ticket' AND +rt3-# effectiveid = tickets.id AND (status = 'new' OR status = 'open') +ORDER BY priority DESC LIMIT 10; + + + +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=88073404.73..88073404.73 rows=1 width=163) (actual +time=2859.05..2859.07 rows=4 loops=1) + -> Sort (cost=88073404.73..88073404.73 rows=1 width=163) (actual +time=2859.05..2859.05 rows=4 loops=1) + Sort Key: priority + -> Seq Scan on tickets (cost=0.00..88073404.72 rows=1 +width=163) (actual time=2525.48..2858.95 rows=4 loops=1) + Filter: (("type" = 'ticket'::character varying) AND +(effectiveid = id) AND ((status = 'new'::character varying) OR (status = +'open'::character varying)) AND (subplan)) + SubPlan + -> Materialize (cost=8443.38..8443.38 rows=66 +width=32) (actual time=0.79..0.81 rows=14 loops=3209) + -> Hash Join (cost=3698.35..8443.38 rows=66 +width=32) (actual time=1720.53..2525.07 rows=14 loops=1) + Hash Cond: ("outer".memberid = "inner".id) + -> Hash Join (cost=3329.03..7973.87 +rows=13247 width=28) (actual time=1225.83..2458.48 rows=31123 loops=1) + Hash Cond: ("outer".groupid = "inner".id) + -> Seq Scan on cachedgroupmembers +(cost=0.00..3456.51 rows=204551 width=8) (actual time=0.06..638.91 +rows=204551 loops=1) + -> Hash (cost=3315.71..3315.71 +rows=5325 width=20) (actual time=1225.51..1225.51 rows=0 loops=1) + -> Hash Join +(cost=1355.70..3315.71 rows=5325 width=20) (actual time=529.02..1191.94 +rows=10431 loops=1) + Hash Cond: +("outer".objectid = "inner".id) + -> Seq Scan on +principals (cost=0.00..1583.76 rows=61940 width=8) (actual +time=0.02..450.42 rows=62097 loops=1) + Filter: +(principaltype = 'Group'::character varying) + -> Hash +(cost=1338.03..1338.03 rows=7068 width=12) (actual time=528.58..528.58 +rows=0 loops=1) + -> Index Scan +using groups_domain on groups (cost=0.00..1338.03 rows=7068 width=12) +(actual time=0.18..498.04 rows=10431 loops=1) + Index Cond: +("domain" = 'RT::Ticket-Role'::character varying) + Filter: +("type" = 'Requestor'::character varying) + -> Hash (cost=369.08..369.08 rows=101 +width=4) (actual time=0.10..0.10 rows=0 loops=1) + -> Index Scan using +users_emailaddress on users (cost=0.00..369.08 rows=101 width=4) +(actual time=0.09..0.10 rows=1 loops=1) + Index Cond: +(lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text) + Total runtime: 2859.34 msec +(25 rows) + + + + + +Greg Stark wrote: + +>Rajesh Kumar Mallah writes: +> +> +> +>>Nopes the query are not Equiv , earlier one returns 4 rows and the below one +>>none, +>> +>> +> +>Sorry, i lowercased a string constant and dropped the lower() on email. +> +>Try this: +> +>SELECT * +> FROM tickets +> WHERE id IN ( +> SELECT groups.instance +> FROM groups +> JOIN principals ON (groups.id = principals.objectid) +> JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid) +> JOIN users ON (cachedgroupmembers.memberid = users.id) +> WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' +> AND groups.domain = 'RT::Ticket-Role' +> AND groups.type = 'Requestor' +> AND principals.principaltype = 'group' +> ) +> AND type = 'ticket' +> AND effectiveid = tickets.id +> AND (status = 'new' OR status = 'open') +>ORDER BY priority DESC +>LIMIT 10; +> +> +> + + +--------------060402080107040008000108 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+But the new version at lease works on 7.3 instead of putting
+it in an infinite loop.
+
+
+rt3=# explain analyze SELECT  * from tickets where id in (  +SELECT groups.instance FROM groups
+rt3(#  JOIN principals ON (groups.id = principals.objectid) JOIN +cachedgroupmembers ON
+rt3(# (principals.id = cachedgroupmembers.groupid) JOIN users ON +(cachedgroupmembers.memberid = users.id)
+rt3(# WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com' AND +groups.domain = 'RT::Ticket-Role'
+rt3(# AND groups.type   = 'Requestor' AND principals.principaltype = +'Group' ) AND type = 'ticket' AND
+rt3-# effectiveid = tickets.id AND (status = 'new' OR status = 'open') +ORDER BY priority DESC LIMIT 10;
+
+
+                                                                                       +QUERY PLAN
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Limit  (cost=88073404.73..88073404.73 rows=1 width=163) (actual +time=2859.05..2859.07 rows=4 loops=1)
+   ->  Sort  (cost=88073404.73..88073404.73 rows=1 width=163) +(actual time=2859.05..2859.05 rows=4 loops=1)
+         Sort Key: priority
+         ->  Seq Scan on tickets  (cost=0.00..88073404.72 rows=1 +width=163) (actual time=2525.48..2858.95 rows=4 loops=1)
+               Filter: (("type" = 'ticket'::character varying) AND +(effectiveid = id) AND ((status = 'new'::character varying) OR (status += 'open'::character varying)) AND (subplan))
+               SubPlan
+                 ->  Materialize  (cost=8443.38..8443.38 rows=66 +width=32) (actual time=0.79..0.81 rows=14 loops=3209)
+                       ->  Hash Join  (cost=3698.35..8443.38 rows=66 +width=32) (actual time=1720.53..2525.07 rows=14 loops=1)
+                             Hash Cond: ("outer".memberid = "inner".id)
+                             ->  Hash Join  (cost=3329.03..7973.87 +rows=13247 width=28) (actual time=1225.83..2458.48 rows=31123 loops=1)
+                                   Hash Cond: ("outer".groupid = +"inner".id)
+                                   ->  Seq Scan on +cachedgroupmembers  (cost=0.00..3456.51 rows=204551 width=8) (actual +time=0.06..638.91 rows=204551 loops=1)
+                                   ->  Hash  (cost=3315.71..3315.71 +rows=5325 width=20) (actual time=1225.51..1225.51 rows=0 loops=1)
+                                         ->  Hash Join  +(cost=1355.70..3315.71 rows=5325 width=20) (actual time=529.02..1191.94 +rows=10431 loops=1)
+                                               Hash Cond: +("outer".objectid = "inner".id)
+                                               ->  Seq Scan on +principals  (cost=0.00..1583.76 rows=61940 width=8) (actual +time=0.02..450.42 rows=62097 loops=1)
+                                                     Filter: +(principaltype = 'Group'::character varying)
+                                               ->  Hash  +(cost=1338.03..1338.03 rows=7068 width=12) (actual time=528.58..528.58 +rows=0 loops=1)
+                                                     ->  Index Scan +using groups_domain on groups  (cost=0.00..1338.03 rows=7068 width=12) +(actual time=0.18..498.04 rows=10431 loops=1)
+                                                           Index Cond: +("domain" = 'RT::Ticket-Role'::character varying)
+                                                           Filter: +("type" = 'Requestor'::character varying)
+                             ->  Hash  (cost=369.08..369.08 rows=101 +width=4) (actual time=0.10..0.10 rows=0 loops=1)
+                                   ->  Index Scan using +users_emailaddress on users  (cost=0.00..369.08 rows=101 width=4) +(actual time=0.09..0.10 rows=1 loops=1)
+                                         Index Cond: +(lower((emailaddress)::text) = 'mallah_rajesh@yahoo.com'::text)
+ Total runtime: 2859.34 msec
+(25 rows)
+
+

+
+
+
+Greg Stark wrote:
+
+
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
+
+  
+
+
Nopes the query are not Equiv , earlier one returns 4 rows and the below one
+none,
+    
+
+

+Sorry, i lowercased a string constant and dropped the lower() on email. 
+
+Try this:
+
+SELECT *
+  FROM tickets
+ WHERE id IN (
+       SELECT groups.instance
+         FROM groups
+         JOIN principals ON (groups.id = principals.objectid)
+         JOIN cachedgroupmembers ON (principals.id = cachedgroupmembers.groupid)
+         JOIN users ON (cachedgroupmembers.memberid = users.id)
+        WHERE lower(users.emailaddress) = 'mallah_rajesh@yahoo.com'
+          AND groups.domain = 'RT::Ticket-Role'
+          AND groups.type   = 'Requestor'
+          AND principals.principaltype = 'group'
+  )
+  AND type = 'ticket'
+  AND effectiveid = tickets.id
+  AND (status = 'new' OR status = 'open')
+ORDER BY priority DESC
+LIMIT 10;
+
+  
+
+
+ + + +--------------060402080107040008000108-- + + +From pgsql-performance-owner@postgresql.org Sun Nov 2 12:33:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37424D1B50B + for ; + Sun, 2 Nov 2003 16:33:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64769-05 + for ; + Sun, 2 Nov 2003 12:33:10 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D4D7D1B554 + for ; + Sun, 2 Nov 2003 12:33:10 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 3AC71369B6; Sun, 2 Nov 2003 11:33:04 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AGLA0-0008WA-00; Sun, 02 Nov 2003 11:33:04 -0500 +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Pg+Linux swap use +References: <20031031143624.GB5394@libertyrms.info> + <007c01c39fc4$0844f850$640101c0@rob> +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Nov 2003 11:33:03 -0500 +Message-ID: <87y8uy91ds.fsf@stark.dyndns.tv> +Lines: 22 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/4 +X-Sequence-Number: 4564 + + +William Yu writes: + +> Rob Sell wrote: +> +> > Not being one to hijack threads, but I haven't heard of this performance hit +> > when using HT, I have what should all rights be a pretty fast server, dual +> > 2.4 Xeons with HT 205gb raid 5 array, 1 gig of memory. And it is only 50% as +> > fast as my old server which was a dual AMD MP 1400's with a 45gb raid 5 +> > array and 1gb of ram. +> +> Not to get into a big Intel vs AMD argument but 50% sounds about right. Let's +> first assume that the QS rating for the MP1400 is relatively accurate and +> convert that to a 1.4GHz Xeon. 2.4/1.4 = +71%. Since processor performance +> does not increase linearly with clockspeed, 50% is in line with expectations. + +Hm. You've read "50% as fast" as "50% faster". +I wonder which the original poster intended. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Nov 3 12:17:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 04C98D1B58D + for ; + Mon, 3 Nov 2003 16:17:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86820-07 + for ; + Mon, 3 Nov 2003 12:16:49 -0400 (AST) +Received: from mail.owensforestproducts.com (unknown [216.161.134.233]) + by svr1.postgresql.org (Postfix) with ESMTP id A2175D1B52F + for ; + Mon, 3 Nov 2003 12:16:48 -0400 (AST) +Subject: join_collapse_limit, from_collapse_limit options missing +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Mon, 3 Nov 2003 10:20:53 -0600 +content-class: urn:content-classes:message +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Message-ID: <70AA9BD4C82E76418F730DF1411A624F06DF12@meta01.owens.int> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: join_collapse_limit, from_collapse_limit options missing +thread-index: AcOiJnPKfSaPwj1oT8OZmc1hdBt5VA== +From: "Lee Hughes" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/5 +X-Sequence-Number: 4565 + +Hi, I'm trying to set these two options to tune performance but both +return 'not a valid option name'. Dumping the pg_settings table confirms +that they are missing. I'm using the PostgreSQL packages included with +RedHat 9 (7.3.2) and Mandrake 9.2 Beta (7.3.4). Do I need to install the +full tarball to get these options? Any help greatly appreciated. + +Thanks, Lee + +From pgsql-performance-owner@postgresql.org Mon Nov 3 12:25:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 52C46D1CAC1 + for ; + Mon, 3 Nov 2003 16:25:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95254-01 + for ; + Mon, 3 Nov 2003 12:24:31 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A1739D1CAB7 + for ; + Mon, 3 Nov 2003 12:24:30 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hA3GOP19028122; + Mon, 3 Nov 2003 11:24:26 -0500 (EST) +To: "Lee Hughes" +Cc: pgsql-performance@postgresql.org +Subject: Re: join_collapse_limit, from_collapse_limit options missing +In-reply-to: <70AA9BD4C82E76418F730DF1411A624F06DF12@meta01.owens.int> +References: <70AA9BD4C82E76418F730DF1411A624F06DF12@meta01.owens.int> +Comments: In-reply-to "Lee Hughes" + message dated "Mon, 03 Nov 2003 10:20:53 -0600" +Date: Mon, 03 Nov 2003 11:24:25 -0500 +Message-ID: <28121.1067876665@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/6 +X-Sequence-Number: 4566 + +"Lee Hughes" writes: +> Hi, I'm trying to set these two options to tune performance but both +> return 'not a valid option name'. Dumping the pg_settings table confirms +> that they are missing. I'm using the PostgreSQL packages included with +> RedHat 9 (7.3.2) and Mandrake 9.2 Beta (7.3.4). Do I need to install the +> full tarball to get these options? Any help greatly appreciated. + +They don't exist in 7.3. Why are you consulting 7.4 documentation for a +7.3 installation? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 3 14:42:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DDE9AD1B502 + for ; + Mon, 3 Nov 2003 18:42:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16034-04 + for ; + Mon, 3 Nov 2003 14:42:03 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 0371BD1B53E + for ; + Mon, 3 Nov 2003 14:42:02 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3863359; Mon, 03 Nov 2003 10:42:44 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Lee Hughes" , + +Subject: Re: join_collapse_limit, from_collapse_limit options missing +Date: Mon, 3 Nov 2003 10:41:04 -0800 +User-Agent: KMail/1.4.3 +References: <70AA9BD4C82E76418F730DF1411A624F06DF12@meta01.owens.int> +In-Reply-To: <70AA9BD4C82E76418F730DF1411A624F06DF12@meta01.owens.int> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311031041.04816.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/7 +X-Sequence-Number: 4567 + +Lee, + +> Hi, I'm trying to set these two options to tune performance but both +> return 'not a valid option name'. Dumping the pg_settings table confirms +> that they are missing. I'm using the PostgreSQL packages included with +> RedHat 9 (7.3.2) and Mandrake 9.2 Beta (7.3.4). Do I need to install the +> full tarball to get these options? Any help greatly appreciated. + +If you're working from the documentation on General Bits, please notice that +both of those options are marked as "new for 7.4". + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Nov 4 06:44:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CE2DD1CA63 + for ; + Tue, 4 Nov 2003 10:44:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65843-08 + for ; + Tue, 4 Nov 2003 06:44:04 -0400 (AST) +Received: from omikron.sk (cepr.nustep.sk [81.0.222.49]) + by svr1.postgresql.org (Postfix) with SMTP id BB899D1B991 + for ; + Tue, 4 Nov 2003 06:43:59 -0400 (AST) +Received: (qmail 3282 invoked from network); 4 Nov 2003 10:43:52 -0000 +Received: from nustep.casablanca.sk (HELO stratos) (81.0.208.19) + by 0 with SMTP; 4 Nov 2003 10:43:52 -0000 +Message-ID: <00e201c3a2c0$89409f00$0200a8c0@stratos> +From: "Cestmir Hybl" +To: +References: <017201c39d85$533eed70$0200a8c0@stratos> +Subject: Re: Ignoring index on (A is null), (A is not null) conditions +Date: Tue, 4 Nov 2003 11:43:51 +0100 +Organization: NUSTEP s.r.o. +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=REFERENCES +X-Spam-Level: +X-Archive-Number: 200311/8 +X-Sequence-Number: 4568 + +First of all, thanks for all your suggestions. + +They were of two classes: + +1. use different data representation (special constant from column domain +instead of NULL) + +This is possible, of course, but it makes data model less portable and +requires changes in database abstraction layer of application. + +2. use partial indexes + +This is suitable for single null-allowed column index. With increasing +number of null-allowed columns inside index, the number of partial indexes +required grows exponentially. + +All RDBMSs I ever used (Sybase, MSSQL, or even MySQL) were using index to +filter by expressions containing is NULL conditions /(A is NULL), (A is not +NULL), (A is NULL or A = const), (A is NULL or A > const)/ so it seems +pretty strange to me that PostgreSQL does not. + +Is this sheduled feature at least? + +CH + + +From pgsql-performance-owner@postgresql.org Tue Nov 4 10:50:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C00AD1B50D + for ; + Tue, 4 Nov 2003 14:50:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12573-02 + for ; + Tue, 4 Nov 2003 10:49:39 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 4415CD1B95A + for ; + Tue, 4 Nov 2003 10:49:35 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hA4EndB17845 + for ; Tue, 4 Nov 2003 08:49:39 -0600 +Received: from 134.129.92.208 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Tue, 4 Nov 2003 08:49:39 -0600 (CST) +Message-ID: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> +Date: Tue, 4 Nov 2003 08:49:39 -0600 (CST) +Subject: Re: Response time +From: +To: +X-Priority: 3 +Importance: Normal +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: * +X-Archive-Number: 200311/9 +X-Sequence-Number: 4569 + +How do we measure the response time in postgresql? + +Your response would be very much appreciated. + +Thanks and Regards, + +Radha + + + +From pgsql-performance-owner@postgresql.org Tue Nov 4 11:02:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BEF5D1B53B + for ; + Tue, 4 Nov 2003 15:02:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12573-04 + for ; + Tue, 4 Nov 2003 11:02:20 -0400 (AST) +Received: from kix.fsv.cvut.cz (Kix.FSV.CVUT.CZ [147.32.129.84]) + by svr1.postgresql.org (Postfix) with ESMTP id 827C9D1CA66 + for ; + Tue, 4 Nov 2003 11:02:15 -0400 (AST) +Received: from localhost (stehule@localhost) + by kix.fsv.cvut.cz (8.11.6/8.11.6) with ESMTP id hA4F2Bj13097; + Tue, 4 Nov 2003 16:02:11 +0100 +Date: Tue, 4 Nov 2003 16:02:11 +0100 (CET) +From: Pavel Stehule +To: radha.manohar@ndsu.nodak.edu +Cc: pgsql-performance@postgresql.org +Subject: Re: Response time +In-Reply-To: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/10 +X-Sequence-Number: 4570 + +Hello + +explain analyse select * from lidi; + QUERY PLAN + +----------------------------------------------------------------------------------------------- + Seq Scan on lidi (cost=0.00..1.04 rows=4 width=96) (actual +time=0.046..0.092 rows=4 loops=1) + Total runtime: 0.369 ms + +Regards +Pavel + + + + +On Tue, 4 Nov 2003 radha.manohar@ndsu.nodak.edu wrote: + +> How do we measure the response time in postgresql? +> +> Your response would be very much appreciated. +> +> Thanks and Regards, +> +> Radha +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> + + +From pgsql-performance-owner@postgresql.org Tue Nov 4 16:13:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85250D1B518 + for ; + Tue, 4 Nov 2003 20:13:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64568-09 + for ; + Tue, 4 Nov 2003 16:12:39 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id A7921D1B8DA + for ; + Tue, 4 Nov 2003 16:12:37 -0400 (AST) +Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id BAEA71D91; Tue, 4 Nov 2003 15:12:37 -0500 (EST) +Subject: Re: Response time +From: Neil Conway +To: radha.manohar@ndsu.nodak.edu +Cc: PostgreSQL Performance +In-Reply-To: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> +References: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> +Content-Type: text/plain +Message-Id: <1067976756.336.0.camel@tokyo> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 04 Nov 2003 15:12:37 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/11 +X-Sequence-Number: 4571 + +On Tue, 2003-11-04 at 09:49, radha.manohar@ndsu.nodak.edu wrote: +> How do we measure the response time in postgresql? + +In addition to EXPLAIN ANALYZE, the log_min_duration_statement +configuration variable and the \timing psql command might also be +useful. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 09:01:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6639D1BB4E + for ; + Wed, 5 Nov 2003 13:01:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36099-04 + for ; + Wed, 5 Nov 2003 09:00:35 -0400 (AST) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 399D5D1BB7A + for ; + Wed, 5 Nov 2003 09:00:31 -0400 (AST) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AHNGz-0006Fw-00 + for ; Wed, 05 Nov 2003 14:00:33 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +Received: from sea.gmane.org ([80.91.224.252]) + by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) + id 1AHKxE-0002zy-00 + for ; + Wed, 05 Nov 2003 11:32:00 +0100 +Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AHKxE-0002JI-00 + for ; + Wed, 05 Nov 2003 11:32:00 +0100 +From: Paul Ganainm +Subject: Interbase/Firebird - any users out there - what's the performance + like compared to PostgreSQL? +Date: Wed, 5 Nov 2003 10:28:25 -0000 +Organization: N�ant +Lines: 42 +Message-ID: +X-Complaints-To: usenet@sea.gmane.org +X-Newsreader: MicroPlanet Gravity v2.50 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char E9 hex) in message + header 'Organization' + Organization: N\351ant\n ^ +X-Archive-Number: 200311/12 +X-Sequence-Number: 4572 + + + +Hi all, + + +I have just started with PostgreSQL on Linux and in the past I've done a +good bit of work on Interbase (both on Windows and Linux). + + +What I want to know here is + + +What do people here think of Interbase/Firebird? + + +Has anybody done performance metrics or could they point me to a +comparison between the two? + + +Does Interbase/Firebird have (as far as people here are concerned) any +show-stoppers in terms of functionality which they do have on +PostgreSQL? Or, indeed, the other way round? + + +I'm not interested in starting a flame war or anything like that - just +a presentation of the facts as you see them, and if you want to put in +your opinion also, that's fine, just make a note! + + +TIA. + + +Paul... + + +-- + +plinehan__AT__yahoo__DOT__com + +C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04 W2K Pro + +Please do not top-post. + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 09:16:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E4559D1B4E6 + for ; + Wed, 5 Nov 2003 13:16:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42526-01 + for ; + Wed, 5 Nov 2003 09:15:44 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 154E6D1BB4E + for ; + Wed, 5 Nov 2003 09:15:41 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 05 Nov 2003 06:15:47 -0700 +Message-ID: <3FA8F7F8.1070602@myrealbox.com> +Date: Wed, 05 Nov 2003 18:45:36 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Paul Ganainm +Cc: pgsql-performance@postgresql.org +Subject: Re: Interbase/Firebird - any users out there - what's the +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/13 +X-Sequence-Number: 4573 + +Paul Ganainm wrote: +> Does Interbase/Firebird have (as far as people here are concerned) any +> show-stoppers in terms of functionality which they do have on +> PostgreSQL? Or, indeed, the other way round? + +Personally I think native windows port is plus that interbase/firebird has over +postgresql. It also has native threaded model which *could* be benefitial at times. + +I combed docs once or twice. It looks like the linux/unix support is failry new +so I don't know how it stacks in production and performance. + +OTOH, I don't like storing entire database in one file. That could get messy. +Otherwise two databases are on par, at least on paper. I hope SQL compliance of +interbase/firebird is better than mysql and closer to postgresql, +/- delta. + +Of course PG has it's own goodies. Rules/Create language are just tip of iceberg. + +Can you come up with some relative comparison? We can help you from postgresql +side..:-) That would be great. + + Bye + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 10:06:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 13FEED1B95A + for ; + Wed, 5 Nov 2003 14:06:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45262-03 + for ; + Wed, 5 Nov 2003 10:05:56 -0400 (AST) +Received: from lucifer.oficina (unknown [200.69.203.237]) + by svr1.postgresql.org (Postfix) with ESMTP id 20476D1BB7E + for ; + Wed, 5 Nov 2003 10:05:51 -0400 (AST) +Received: from [192.168.1.190] (taz.oficina [192.168.1.190]) + (authenticated bits=0) + by lucifer.oficina (8.12.9/8.12.9) with ESMTP id hA5E5lAN099770; + Wed, 5 Nov 2003 11:05:47 -0300 (ART) + (envelope-from franco@akyasociados.com.ar) +Subject: Re: Interbase/Firebird - any users out there - what's +From: Franco Bruno Borghesi +To: Paul Ganainm +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-pawMCHeqdTzgT2a8D//u" +Organization: AK y Asociados S.R.L. +Message-Id: <1068041145.783.10.camel@taz> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4 +Date: Wed, 05 Nov 2003 11:05:46 -0300 +X-MailScanner-Information: Please contact the ISP for more information +X-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/14 +X-Sequence-Number: 4574 + +--=-pawMCHeqdTzgT2a8D//u +Content-Type: multipart/alternative; boundary="=-zV7wHhfKmlh1MGvarLo9" + +--=-zV7wHhfKmlh1MGvarLo9 +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +About a year ago I programmed a php/firebird application, and I've never +had a problem with firebird. It's a small database (a few megabytes), +but it just works day after day. + +I've seen firebird has updatable views, they seem to work very well. + +I have the feeling that It's not as flexible as postgresql, but I still +like it. It would be my choice for win32 applications (until win32 +postgresql port become available). + + +On Wed, 2003-11-05 at 07:28, Paul Ganainm wrote: + +> Hi all, +>=20 +>=20 +> I have just started with PostgreSQL on Linux and in the past I've done a= +=20 +> good bit of work on Interbase (both on Windows and Linux). +>=20 +>=20 +> What I want to know here is +>=20 +>=20 +> What do people here think of Interbase/Firebird? +>=20 +>=20 +> Has anybody done performance metrics or could they point me to a=20 +> comparison between the two? +>=20 +>=20 +> Does Interbase/Firebird have (as far as people here are concerned) any=20 +> show-stoppers in terms of functionality which they do have on=20 +> PostgreSQL? Or, indeed, the other way round? +>=20 +>=20 +> I'm not interested in starting a flame war or anything like that - just= +=20 +> a presentation of the facts as you see them, and if you want to put in=20 +> your opinion also, that's fine, just make a note! +>=20 +>=20 +> TIA. +>=20 +>=20 +> Paul... +>=20 + +--=-zV7wHhfKmlh1MGvarLo9 +Content-Type: text/html; charset=utf-8 +Content-Transfer-Encoding: quoted-printable + + + + + + + + +About a year ago I programmed a php/firebird application, and I've never ha= +d a problem with firebird. It's a small database (a few megabytes), but it = +just works day after day.
+
+I've seen firebird has updatable views, they seem to work very well.
+
+I have the feeling that It's not as flexible as postgresql, but I still lik= +e it. It would be my choice for win32 applications (until win32 postgresql = +port become available).
+
+
+On Wed, 2003-11-05 at 07:28, Paul Ganainm wrote: +
+
Hi all,
+
+
+I have just started with PostgreSQL on Linux and in the past I've done a=20
+good bit of work on Interbase (both on Windows and Linux).
+
+
+What I want to know here is
+
+
+What do people here think of Interbase/Firebird?
+
+
+Has anybody done performance metrics or could they point me to a=20
+comparison between the two?
+
+
+Does Interbase/Firebird have (as far as people here are concerned) any=20
+show-stoppers in terms of functionality which they do have on=20
+PostgreSQL? Or, indeed, the other way round?
+
+
+I'm not interested in starting a flame war or anything like that - just=20
+a presentation of the facts as you see them, and if you want to put in=20
+your opinion also, that's fine, just make a note!
+
+
+TIA.
+
+
+Paul...
+
+
+ + + +--=-zV7wHhfKmlh1MGvarLo9-- + +--=-pawMCHeqdTzgT2a8D//u +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.2 (FreeBSD) + +iD8DBQA/qQO521dVnhLsBV0RAsAtAJ9fSlVl2HhXpZy997SM1CEAKx8TOgCfYlHx +6Qjmzj3zKiiRN4Oe1LkkHjE= +=U6qz +-----END PGP SIGNATURE----- + +--=-pawMCHeqdTzgT2a8D//u-- + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 13:36:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E1574D1B4F4 + for ; + Wed, 5 Nov 2003 17:36:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83418-05 + for ; + Wed, 5 Nov 2003 13:35:41 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 0580FD1B4ED + for ; + Wed, 5 Nov 2003 13:35:40 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hA5HZHB21072; + Wed, 5 Nov 2003 11:35:20 -0600 +Received: from 134.129.92.208 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Wed, 5 Nov 2003 11:35:22 -0600 (CST) +Message-ID: <1706.134.129.92.208.1068053722.squirrel@webmail.ndsu.nodak.edu> +Date: Wed, 5 Nov 2003 11:35:22 -0600 (CST) +Subject: Re: Response time +From: +To: +In-Reply-To: <1067976756.336.0.camel@tokyo> +References: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> + <1067976756.336.0.camel@tokyo> +X-Priority: 3 +Importance: Normal +Cc: +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/15 +X-Sequence-Number: 4575 + +The \timing psql command gives different time for the same query executed +repeatedly. + +So, how can we know the exact response time for any query? + +Thanks and Regards, + +Radha + +> On Tue, 2003-11-04 at 09:49, radha.manohar@ndsu.nodak.edu wrote: +>> How do we measure the response time in postgresql? +> +> In addition to EXPLAIN ANALYZE, the log_min_duration_statement +> configuration variable and the \timing psql command might also be +> useful. +> +> -Neil +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 13:41:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C0CDD1BB9A + for ; + Wed, 5 Nov 2003 17:40:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85177-01 + for ; + Wed, 5 Nov 2003 13:40:28 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 51429D1BB7B + for ; + Wed, 5 Nov 2003 13:40:27 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 6AB381DF2; Wed, 5 Nov 2003 12:40:20 -0500 (EST) +To: +Cc: +Subject: Re: Response time +From: Neil Conway +In-Reply-To: <1706.134.129.92.208.1068053722.squirrel@webmail.ndsu.nodak.edu> + (radha + manohar's message of "Wed, 5 Nov 2003 11:35:22 -0600 (CST)") +References: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> + <1067976756.336.0.camel@tokyo> + <1706.134.129.92.208.1068053722.squirrel@webmail.ndsu.nodak.edu> +Date: Wed, 05 Nov 2003 12:40:18 -0500 +Message-ID: <87ad7ar9x9.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/16 +X-Sequence-Number: 4576 + + writes: +> The \timing psql command gives different time for the same query executed +> repeatedly. + +That's probably because executing the query repeatedly results in +different execution times, as one would expect. \timing returns the +"exact" query response time, nevertheless. + +-Neil + + +From pgsql-performance-owner@postgresql.org Wed Nov 5 14:04:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 86020D1B947 + for ; + Wed, 5 Nov 2003 18:04:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84183-10 + for ; + Wed, 5 Nov 2003 14:04:23 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 609B0D1B8DF + for ; + Wed, 5 Nov 2003 14:04:22 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AHS10-0004Wp-00 + for ; Wed, 05 Nov 2003 13:04:22 -0500 +Received: by dba2 (Postfix, from userid 1019) + id C8468C9B3; Wed, 5 Nov 2003 13:04:22 -0500 (EST) +Date: Wed, 5 Nov 2003 13:04:22 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Response time +Message-ID: <20031105180422.GF4506@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <1243.134.129.92.208.1067957379.squirrel@webmail.ndsu.nodak.edu> + <1067976756.336.0.camel@tokyo> + <1706.134.129.92.208.1068053722.squirrel@webmail.ndsu.nodak.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1706.134.129.92.208.1068053722.squirrel@webmail.ndsu.nodak.edu> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/17 +X-Sequence-Number: 4577 + +On Wed, Nov 05, 2003 at 11:35:22AM -0600, radha.manohar@ndsu.nodak.edu wrote: +> The \timing psql command gives different time for the same query executed +> repeatedly. + +Why do you believe that the same query will always take the same time +to execute? + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Thu Nov 6 04:44:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CB326D1B8DF + for ; + Thu, 6 Nov 2003 08:44:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33882-03 + for ; + Thu, 6 Nov 2003 04:43:31 -0400 (AST) +Received: from sys-srv-1.xtec.ro (xtec.b.astral.ro [213.164.250.17]) + by svr1.postgresql.org (Postfix) with ESMTP id D3D59D1BB59 + for ; + Thu, 6 Nov 2003 04:43:28 -0400 (AST) +Received: from fx.ro (xtro-ws-1.xtec.ro [10.60.4.1]) + by sys-srv-1.xtec.ro (Postfix) with ESMTP id D03EB3FE7 + for ; + Thu, 6 Nov 2003 10:42:40 +0200 (EET) +Message-ID: <3FAA09BB.6050705@fx.ro> +Date: Thu, 06 Nov 2003 10:43:39 +0200 +From: Adrian Maier +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5b) Gecko/20030901 Thunderbird/0.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: horrible performance when trying to connect to PostgreSQL using ODBC +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/18 +X-Sequence-Number: 4578 + +Hello guys ! + +I am trying to connect to pgsql using ODBC from Visual Objects +(for the ones who don't know what is Visual Objects, it's an IDE +with its own object-oriented language made by Computer Associates. +VO's roots are related to Clipper. ). + +The time it takes to get the list of the tables, and then to get the +data and display it way too long. It took more than 16 seconds to +connect, get 200 records and print them on the console. + +I know for sure that it's not pgsql's fault: with a small c program +that uses libpq i got the same data instantaneously. Also, it looks +like it's not VO's fault (i know that there are people who used VO +against big databases). So, the problem must be related to the ODBC +(the pgsql driver or something else?). + +Anyway, i've tried to open the same table from MSAccess, and the +performance was even worse. Just an example: for going from one record +to the next one it lasts about 4-5 seconds. + +The machine is a Pentium2 266mhz (128mb) laptop running windows NT. + +Today, I have tried to access pgsql from MSAccess at work. It worked +very fast. I've used the same ODBC drivers, but the machine is +faster (p4 2.4ghz), has more memory, and the OS is windows 2000. +But it is hard for me to believe that a Pentium2 machine with 128mb RAM +can't handle 200 records ! + +I begin to think that there is something fishy about the ODBC +support installed on the laptop (i have recently "inherited" the +laptop from someone else, and i haven't reinstalled the os ). + +What do you guys think? what could be done to make things go +faster? + + +I have also two more questions. After installing the pgsql odbc +drivers, there are 3 drivers that appear: +"PostgreSQL", "POstgreSQL legacy" and "PostgreSQL unicode". +What's the difference between "PostgreSQL" and "PostgreSQL lecacy"? +Are there any options of the odbc driver that could cause a +performance boost? + +Thanks you, + +Adrian Maier + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Thu Nov 6 10:58:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 98D98D1BACF + for ; + Thu, 6 Nov 2003 14:58:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90254-02 + for ; + Thu, 6 Nov 2003 10:57:57 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 378F7D1BAE3 + for ; + Thu, 6 Nov 2003 10:57:53 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hA6Evp19019450; + Thu, 6 Nov 2003 09:57:51 -0500 (EST) +To: Adrian Maier +Cc: pgsql-performance@postgresql.org +Subject: Re: horrible performance when trying to connect to PostgreSQL using + ODBC +In-reply-to: <3FAA09BB.6050705@fx.ro> +References: <3FAA09BB.6050705@fx.ro> +Comments: In-reply-to Adrian Maier + message dated "Thu, 06 Nov 2003 10:43:39 +0200" +Date: Thu, 06 Nov 2003 09:57:51 -0500 +Message-ID: <19449.1068130671@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/19 +X-Sequence-Number: 4579 + +Adrian Maier writes: +> I begin to think that there is something fishy about the ODBC +> support installed on the laptop (i have recently "inherited" the +> laptop from someone else, and i haven't reinstalled the os ). + +You'd be better off asking these questions on pgsql-odbc. I'm not sure +that any of the ODBC gurus read this list. + +I believe that the ODBC driver has some incredibly extensive, and +expensive, debug-logging options. I dunno if max logging would entirely +explain the slowdown you see, but definitely check what you have turned +on. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Nov 8 16:24:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6255D1B99F + for ; + Thu, 6 Nov 2003 17:17:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10032-09 + for ; + Thu, 6 Nov 2003 13:17:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FE56D1B4E6 + for ; + Thu, 6 Nov 2003 13:17:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hA6HHFNu004498 + for ; Thu, 6 Nov 2003 17:17:15 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hA6GvHp9000404 + for pgsql-performance@postgresql.org; Thu, 6 Nov 2003 16:57:17 GMT +From: "Private" +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Interbase/Firebird - any users out there - what's the performance + like compared to PostgreSQL? +Date: Thu, 6 Nov 2003 11:57:15 -0500 +Organization: Hub.Org Networking Services +Lines: 65 +Message-ID: +References: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME, QUOTED_EMAIL_TEXT, REFERENCES +X-Spam-Level: +X-Archive-Number: 200311/23 +X-Sequence-Number: 4583 + +Try this benchmark on PostgreSQL, MySQL, FireBird, Oracle: + +http://go.jitbot.com/dbbench-pg-fb-mys-orcl + +This page expired but if you click on "Cache" on the side of JitBot search +pane, you'll see the cached page: + +http://go.jitbot.com/opensource-dbs-table + + +Cheers, + + +"Paul Ganainm" wrote in message +news:MPG.1a12e0e45193bd1b98969a@news.gmane.org... +> +> +> Hi all, +> +> +> I have just started with PostgreSQL on Linux and in the past I've done a +> good bit of work on Interbase (both on Windows and Linux). +> +> +> What I want to know here is +> +> +> What do people here think of Interbase/Firebird? +> +> +> Has anybody done performance metrics or could they point me to a +> comparison between the two? +> +> +> Does Interbase/Firebird have (as far as people here are concerned) any +> show-stoppers in terms of functionality which they do have on +> PostgreSQL? Or, indeed, the other way round? +> +> +> I'm not interested in starting a flame war or anything like that - just +> a presentation of the facts as you see them, and if you want to put in +> your opinion also, that's fine, just make a note! +> +> +> TIA. +> +> +> Paul... +> +> +> -- +> +> plinehan__AT__yahoo__DOT__com +> +> C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04 W2K Pro +> +> Please do not top-post. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +From pgsql-performance-owner@postgresql.org Thu Nov 6 15:17:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E0408D1B564 + for ; + Thu, 6 Nov 2003 19:17:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36146-04 + for ; + Thu, 6 Nov 2003 15:17:17 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A6221D1B522 + for ; + Thu, 6 Nov 2003 15:17:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hA6JHGNu030507 + for ; Thu, 6 Nov 2003 19:17:16 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hA6JA2wW028824 + for pgsql-performance@postgresql.org; Thu, 6 Nov 2003 19:10:02 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Interbase/Firebird - any users out there - what's the performance + like compared to PostgreSQL? +Date: Thu, 06 Nov 2003 13:23:06 -0500 +Organization: Hub.Org Networking Services +Lines: 18 +Message-ID: <60n0b9uzjp.fsf@dev6.int.libertyrms.info> +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:YytxfyG8bBSb27zjYXazEqpCb90= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/20 +X-Sequence-Number: 4580 + +"Private" writes: +> Try this benchmark on PostgreSQL, MySQL, FireBird, Oracle: +> +> http://go.jitbot.com/dbbench-pg-fb-mys-orcl + +It looks like a good candidate for adding in a plpgsql stored +procedure to get similar speedups to what was gotten with the Oracle +benchmark. + +It looks, from the numbers, as though Firebird is _slightly_ slower +than PostgreSQL, which seems not totally remarkable. I'd expect that +reimplementing the benchmark inside a stored procedure would provide +similar improvements with Firebird... +-- +(reverse (concatenate 'string "ofni.smrytrebil" "@" "enworbbc")) + +Christopher Browne +(416) 646 3304 x124 (land) + +From pgsql-performance-owner@postgresql.org Thu Nov 6 15:54:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38BB9D1B557 + for ; + Thu, 6 Nov 2003 19:54:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41709-07 + for ; + Thu, 6 Nov 2003 15:54:26 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 35432D1B4E1 + for ; + Thu, 6 Nov 2003 15:54:24 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hA6JsFgT003887; + Thu, 6 Nov 2003 21:54:17 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hA6JsDe1003885; + Thu, 6 Nov 2003 21:54:13 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: Interbase/Firebird - any users out there - what's +From: Hannu Krosing +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +In-Reply-To: <60n0b9uzjp.fsf@dev6.int.libertyrms.info> +References: + <60n0b9uzjp.fsf@dev6.int.libertyrms.info> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1068148452.3735.3.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 06 Nov 2003 21:54:13 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/21 +X-Sequence-Number: 4581 + +Christopher Browne kirjutas N, 06.11.2003 kell 20:23: +> "Private" writes: +> > Try this benchmark on PostgreSQL, MySQL, FireBird, Oracle: +> > +> > http://go.jitbot.com/dbbench-pg-fb-mys-orcl +> +> It looks like a good candidate for adding in a plpgsql stored +> procedure to get similar speedups to what was gotten with the Oracle +> benchmark. + +It would also be interesting to see the same test run on Postgresql on +Linux/UNIX. PgSQL on win2000 (most likely using cygwin) is probably not +the best you can get out of that hardware. + +----------- +Hannu + + +From pgsql-performance-owner@postgresql.org Thu Nov 6 18:59:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AA6ED1B523 + for ; + Thu, 6 Nov 2003 22:59:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73572-02 + for ; + Thu, 6 Nov 2003 18:58:58 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 79CBDD1BB5D + for ; + Thu, 6 Nov 2003 18:58:54 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hA6Mwq504482; + Thu, 6 Nov 2003 17:58:52 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311062258.hA6Mwq504482@candle.pha.pa.us> +Subject: Re: Pg+Linux swap use +In-Reply-To: <87y8uy91ds.fsf@stark.dyndns.tv> +To: Greg Stark +Date: Thu, 6 Nov 2003 17:58:52 -0500 (EST) +Cc: William Yu , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/22 +X-Sequence-Number: 4582 + +Greg Stark wrote: +> +> William Yu writes: +> +> > Rob Sell wrote: +> > +> > > Not being one to hijack threads, but I haven't heard of this performance hit +> > > when using HT, I have what should all rights be a pretty fast server, dual +> > > 2.4 Xeons with HT 205gb raid 5 array, 1 gig of memory. And it is only 50% as +> > > fast as my old server which was a dual AMD MP 1400's with a 45gb raid 5 +> > > array and 1gb of ram. +> > +> > Not to get into a big Intel vs AMD argument but 50% sounds about right. Let's +> > first assume that the QS rating for the MP1400 is relatively accurate and +> > convert that to a 1.4GHz Xeon. 2.4/1.4 = +71%. Since processor performance +> > does not increase linearly with clockspeed, 50% is in line with expectations. +> +> Hm. You've read "50% as fast" as "50% faster". +> I wonder which the original poster intended. + +Hyper-threading makes 2 cpus be 4 cpu's, but the 4 cpu's are each only +70% as fast, so HT is taking 2x cpus and making it 4x0.70 cpu's, which +gives 2.80 cpu's, and you get that only if you are hammering all four +cpu's with a full load. Imagine ifd get two cpu-bound processes on the +first die (first 2 cpu's of 4) and the other CPU die is idle, and you +can see that HT isn't all that useful unless you are sure to keep all 4 +cpu's busy. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-novice-owner@postgresql.org Sun Nov 9 11:06:50 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id ABFA0D1B50F; Sun, 9 Nov 2003 15:06:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84862-07; Sun, 9 Nov 2003 11:06:16 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id C7B1AD1B4EF; Sun, 9 Nov 2003 11:06:10 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hA9F6EB24003; + Sun, 9 Nov 2003 09:06:14 -0600 +Received: from 134.129.110.96 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Sun, 9 Nov 2003 09:06:14 -0600 (CST) +Message-ID: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +Date: Sun, 9 Nov 2003 09:06:14 -0600 (CST) +Subject: Re: error while executing a c program with embedded sql +From: +To: +X-Priority: 3 +Importance: Normal +Cc: +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/60 +X-Sequence-Number: 8763 + +I have a c program called test1.pgc with some sql statements embedded in +it. The program was preprocessed, compiled and linked. Now, I have the +executable test1. + +When I run the executable it says, + +./test1: error while loading shared libraries: libecpg.so.3: cannot open +shared object file: No such file or directory + +What does it mean by this error message? What should I do to correct this +error and run the executable successfully? + +Your response would be very much appreciated. + +Thanks and Regards, + +Radha + + + +From pgsql-novice-owner@postgresql.org Sun Nov 9 11:34:42 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id A43C3D1B4EF; Sun, 9 Nov 2003 15:34:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00602-02; Sun, 9 Nov 2003 11:34:07 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 90A37D1B4E6; Sun, 9 Nov 2003 11:34:03 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hA9FY719003364; + Sun, 9 Nov 2003 10:34:07 -0500 (EST) +To: radha.manohar@ndsu.nodak.edu +Cc: pgsql-novice@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: error while executing a c program with embedded sql +In-reply-to: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +References: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +Comments: In-reply-to + message dated "Sun, 09 Nov 2003 09:06:14 -0600" +Date: Sun, 09 Nov 2003 10:34:06 -0500 +Message-ID: <3363.1068392046@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/61 +X-Sequence-Number: 8764 + + writes: +> ./test1: error while loading shared libraries: libecpg.so.3: cannot open +> shared object file: No such file or directory + +The dynamic linker is failing to find either libecpg.so itself, or one +of the shared libraries it depends on (perhaps libpq.so). + +If you are on a Linux system you probably want to fix your ldconfig +configuration so that all these libraries are found automatically. +You can run ldd on a particular executable or shared library to see what +libraries it references and whether those libraries are getting found +in the proper places. + +Note that it is entirely possible for the program linking stage to +succeed but dynamic linking to fail at runtime. For various reasons the +search rules are not quite the same in the two contexts ... + + regards, tom lane + +From pgsql-novice-owner@postgresql.org Sun Nov 9 13:36:45 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 754E1D1B506 + for ; + Sun, 9 Nov 2003 17:36:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02715-08 + for ; + Sun, 9 Nov 2003 13:36:12 -0400 (AST) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id C0EFFD1B509 + for ; Sun, 9 Nov 2003 13:36:10 -0400 (AST) +Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AItTu-000KRu-0Z; Sun, 09 Nov 2003 17:36:10 +0000 +Received: from linda.lfix.co.uk ([192.168.1.1]) + by cerberus.lfix.co.uk with esmtp (Exim 4.24) + id 1AItQl-00082b-MO; Sun, 09 Nov 2003 17:32:55 +0000 +Subject: Re: error while executing a c program with embedded sql +From: Oliver Elphick +To: radha.manohar@ndsu.nodak.edu +Cc: pgsql-novice@postgresql.org +In-Reply-To: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +References: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +Content-Type: text/plain +Organization: LFIX Limited +Message-Id: <1068399145.2175.7.camel@linda.lfix.co.uk> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sun, 09 Nov 2003 17:32:25 +0000 +Content-Transfer-Encoding: 7bit +X-LFIX-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/62 +X-Sequence-Number: 8765 + +On Sun, 2003-11-09 at 15:06, radha.manohar@ndsu.nodak.edu wrote: +> I have a c program called test1.pgc with some sql statements embedded in +> it. The program was preprocessed, compiled and linked. Now, I have the +> executable test1. +> +> When I run the executable it says, +> +> ./test1: error while loading shared libraries: libecpg.so.3: cannot open +> shared object file: No such file or directory +> +> What does it mean by this error message? What should I do to correct this +> error and run the executable successfully? + +Shared libraries are loaded from directories specified to the system by +ldconfig. Your shared library, libecpg.so.3, is in a PostgreSQL +directory, such as /usr/local/pgsql/lib, which has not been added to the +directories known to the loader. + +If you are able to add that directory with ldconfig, that is the best +way to do it, but it requires root privilege. + +Otherwise you can set the environment variable LD_LIBRARY_PATH, thus: + + export LD_LIBRARY_PATH=/usr/local/pgsql/lib + +before you run the program, or you can use LD_PRELOAD: + + LD_PRELOAD=/usr/local/pgsql/lib/libecpg.so.3 ./test1 + +-- +Oliver Elphick Oliver.Elphick@lfix.co.uk +Isle of Wight, UK http://www.lfix.co.uk/oliver +GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C + ======================================== + "O death, where is thy sting? O grave, where is + thy victory?" 1 Corinthians 15:55 + + +From pgsql-novice-owner@postgresql.org Mon Nov 10 11:01:55 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id EDE19D1B4FE; Mon, 10 Nov 2003 15:01:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22043-03; Mon, 10 Nov 2003 11:01:23 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id 60591D1B4E4; Mon, 10 Nov 2003 11:01:18 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hAAF0RB30797; + Mon, 10 Nov 2003 09:00:27 -0600 +Received: from 134.129.92.208 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Mon, 10 Nov 2003 09:00:27 -0600 (CST) +Message-ID: <1371.134.129.92.208.1068476427.squirrel@webmail.ndsu.nodak.edu> +Date: Mon, 10 Nov 2003 09:00:27 -0600 (CST) +Subject: Re: error while executing a c program with embedded sql +From: +To: +In-Reply-To: <1068399145.2175.7.camel@linda.lfix.co.uk> +References: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> + <1068399145.2175.7.camel@linda.lfix.co.uk> +X-Priority: 3 +Importance: Normal +Cc: , +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/85 +X-Sequence-Number: 8788 + +Thanks a lot. IT WORKED! with your suggestions. + +Regards, +Radha + +> On Sun, 2003-11-09 at 15:06, radha.manohar@ndsu.nodak.edu wrote: +>> I have a c program called test1.pgc with some sql statements embedded +>> in it. The program was preprocessed, compiled and linked. Now, I have +>> the executable test1. +>> +>> When I run the executable it says, +>> +>> ./test1: error while loading shared libraries: libecpg.so.3: cannot +>> open shared object file: No such file or directory +>> +>> What does it mean by this error message? What should I do to correct +>> this error and run the executable successfully? +> +> Shared libraries are loaded from directories specified to the system by +> ldconfig. Your shared library, libecpg.so.3, is in a PostgreSQL +> directory, such as /usr/local/pgsql/lib, which has not been added to the +> directories known to the loader. +> +> If you are able to add that directory with ldconfig, that is the best +> way to do it, but it requires root privilege. +> +> Otherwise you can set the environment variable LD_LIBRARY_PATH, thus: +> +> export LD_LIBRARY_PATH=/usr/local/pgsql/lib +> +> before you run the program, or you can use LD_PRELOAD: +> +> LD_PRELOAD=/usr/local/pgsql/lib/libecpg.so.3 ./test1 +> +> -- +> Oliver Elphick Oliver.Elphick@lfix.co.uk +> Isle of Wight, UK +> http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 +> 5839 932A 614D 4C34 3E1D 0C1C +> ======================================== +> "O death, where is thy sting? O grave, where is +> thy victory?" 1 Corinthians 15:55 + + + + +From pgsql-novice-owner@postgresql.org Sun Nov 9 16:13:18 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C3D7D1B525 + for ; + Sun, 9 Nov 2003 16:27:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02715-04 + for ; + Sun, 9 Nov 2003 12:27:13 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 25CC4D1B532 + for ; Sun, 9 Nov 2003 12:27:12 -0400 (AST) +Received: (qmail 18980 invoked from network); 9 Nov 2003 16:28:18 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 9 Nov 2003 16:28:18 -0000 +Message-ID: <3FAFBC68.4020601@trade-india.com> +Date: Mon, 10 Nov 2003 21:57:20 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: radha.manohar@ndsu.nodak.edu +Cc: pgsql-novice@postgresql.org +Subject: Re: [PERFORM] error while executing a c program with embedded sql +References: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +In-Reply-To: <3324.134.129.110.96.1068390374.squirrel@webmail.ndsu.nodak.edu> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/68 +X-Sequence-Number: 8771 + +radha.manohar@ndsu.nodak.edu wrote: + +>I have a c program called test1.pgc with some sql statements embedded in +>it. The program was preprocessed, compiled and linked. Now, I have the +>executable test1. +> +>When I run the executable it says, +> +>./test1: error while loading shared libraries: libecpg.so.3: cannot open +>shared object file: No such file or directory +> +check where the so file is located. +$ locate libecpg.so.3 + +say its /usr/local/pgsql/lib +then either add the folder above to /etc/ld.so.conf and run ldconfig +as root. + +or + +$ export LD_LIBRARY_PATH=/path/to/folder/containing/the/so/file +$ ./test1 + +the above assumes u are on linux. on unix also its similar. + + +> +>What does it mean by this error message? What should I do to correct this +>error and run the executable successfully? +> +>Your response would be very much appreciated. +> +>Thanks and Regards, +> +>Radha +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> + + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 16:21:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F041AD1B507 + for ; + Mon, 10 Nov 2003 20:21:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70902-09 + for ; + Mon, 10 Nov 2003 16:21:04 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 48088D1B4F1 + for ; + Mon, 10 Nov 2003 16:21:02 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id B42F2365D6; Mon, 10 Nov 2003 16:18:52 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id AABA1349C6 + for ; + Mon, 10 Nov 2003 16:18:52 -0400 (AST) +Date: Mon, 10 Nov 2003 16:18:52 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: pgsql-performance@postgresql.org +Subject: *very* slow query to summarize data for a month ... +Message-ID: <20031110160144.C727@ganymede.hub.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/27 +X-Sequence-Number: 4587 + + +Table structure is simple: + +CREATE TABLE traffic_logs ( + company_id bigint, + ip_id bigint, + port integer, + bytes bigint, + runtime timestamp without time zone +); + +runtime is 'day of month' ... + +I need to summarize the month, per company, with a query as: + +explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS total_traffic + FROM company c, traffic_logs ts + WHERE c.company_id = ts.company_id + AND month_trunc(ts.runtime) = '2003-10-01' +GROUP BY company_name,ts.company_id; + +and the explain looks like: + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=32000.94..32083.07 rows=821 width=41) (actual time=32983.36..47586.17 rows=144 loops=1) + -> Group (cost=32000.94..32062.54 rows=8213 width=41) (actual time=32957.40..42817.88 rows=462198 loops=1) + -> Sort (cost=32000.94..32021.47 rows=8213 width=41) (actual time=32957.38..36261.31 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=31321.45..31466.92 rows=8213 width=41) (actual time=13983.07..22642.14 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.52..7.40 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.02..2.78 rows=352 loops=1) + -> Sort (cost=31297.04..31317.57 rows=8213 width=16) (actual time=13977.49..16794.41 rows=462198 loops=1) + Sort Key: ts.company_id + -> Index Scan using tl_month on traffic_logs ts (cost=0.00..30763.02 rows=8213 width=16) (actual time=0.29..5562.25 rows=462198 loops=1) + Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 47587.82 msec +(14 rows) + +the problem is that we're only taking a few months worth of data, so I +don't think there is much of a way of 'improve performance' on this, but +figured I'd ask quickly before I do something rash ... + +Note that without the month_trunc() index, the Total runtime more then +doubles: + + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=39578.63..39660.76 rows=821 width=41) (actual time=87805.47..101251.35 rows=144 loops=1) + -> Group (cost=39578.63..39640.23 rows=8213 width=41) (actual time=87779.56..96824.56 rows=462198 loops=1) + -> Sort (cost=39578.63..39599.17 rows=8213 width=41) (actual time=87779.52..90781.48 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=38899.14..39044.62 rows=8213 width=41) (actual time=64073.98..72783.68 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=64.66..66.55 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=1.76..61.70 rows=352 loops=1) + -> Sort (cost=38874.73..38895.27 rows=8213 width=16) (actual time=64009.26..66860.71 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 101277.17 msec +(14 rows) + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 16:40:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B69B0D1B507; Mon, 10 Nov 2003 20:40:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72096-09; Mon, 10 Nov 2003 16:39:40 -0400 (AST) +Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) + by svr1.postgresql.org (Postfix) with ESMTP + id 21B69D1B50C; Mon, 10 Nov 2003 16:39:38 -0400 (AST) +In-Reply-To: <20031110160144.C727@ganymede.hub.org> +Subject: Re: *very* slow query to summarize data for a month ... +To: scrappy@postgresql.org +Cc: pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +X-Mailer: Lotus Notes Release 6.0 September 26, 2002 +Message-ID: + +From: "Patrick Hatcher" +Date: Mon, 10 Nov 2003 12:31:08 -0800 +X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June + 8, 2000) at 11/10/2003 03:34:04 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/28 +X-Sequence-Number: 4588 + + +Do you have an index on ts.bytes? Josh had suggested this and after I put +it on my summed fields, I saw a speed increase. I can't remember the +article was that Josh had written about index usage, but maybe he'll chime +in and supply the URL for his article. +hth + +Patrick Hatcher + + + + + "Marc G. Fournier" + To + Sent by: pgsql-performance@postgresql.org + pgsql-performance-o cc + wner@postgresql.org + Subject + [PERFORM] *very* slow query to + 11/10/2003 12:18 PM summarize data for a month ... + + + + + + + + + + + +Table structure is simple: + +CREATE TABLE traffic_logs ( + company_id bigint, + ip_id bigint, + port integer, + bytes bigint, + runtime timestamp without time zone +); + +runtime is 'day of month' ... + +I need to summarize the month, per company, with a query as: + +explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS +total_traffic + FROM company c, traffic_logs ts + WHERE c.company_id = ts.company_id + AND month_trunc(ts.runtime) = '2003-10-01' +GROUP BY company_name,ts.company_id; + +and the explain looks like: +QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + Aggregate (cost=32000.94..32083.07 rows=821 width=41) (actual +time=32983.36..47586.17 rows=144 loops=1) + -> Group (cost=32000.94..32062.54 rows=8213 width=41) (actual +time=32957.40..42817.88 rows=462198 loops=1) + -> Sort (cost=32000.94..32021.47 rows=8213 width=41) (actual +time=32957.38..36261.31 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=31321.45..31466.92 rows=8213 width=41) +(actual time=13983.07..22642.14 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) +(actual time=5.52..7.40 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 +rows=352 width=25) (actual time=0.02..2.78 rows=352 loops=1) + -> Sort (cost=31297.04..31317.57 rows=8213 width=16) +(actual time=13977.49..16794.41 rows=462198 loops=1) + Sort Key: ts.company_id + -> Index Scan using tl_month on traffic_logs ts +(cost=0.00..30763.02 rows=8213 width=16) (actual time=0.29..5562.25 +rows=462198 loops=1) + Index Cond: (month_trunc(runtime) += '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 47587.82 msec +(14 rows) + +the problem is that we're only taking a few months worth of data, so I +don't think there is much of a way of 'improve performance' on this, but +figured I'd ask quickly before I do something rash ... + +Note that without the month_trunc() index, the Total runtime more then +doubles: + + +QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + + Aggregate (cost=39578.63..39660.76 rows=821 width=41) (actual +time=87805.47..101251.35 rows=144 loops=1) + -> Group (cost=39578.63..39640.23 rows=8213 width=41) (actual +time=87779.56..96824.56 rows=462198 loops=1) + -> Sort (cost=39578.63..39599.17 rows=8213 width=41) (actual +time=87779.52..90781.48 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=38899.14..39044.62 rows=8213 width=41) +(actual time=64073.98..72783.68 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) +(actual time=64.66..66.55 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 +rows=352 width=25) (actual time=1.76..61.70 rows=352 loops=1) + -> Sort (cost=38874.73..38895.27 rows=8213 width=16) +(actual time=64009.26..66860.71 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts +(cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 +rows=462198 loops=1) + Filter: (date_trunc('month'::text, +runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 101277.17 msec +(14 rows) + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + + + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 16:40:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id DEBC0D1B550; Mon, 10 Nov 2003 20:40:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80284-04; Mon, 10 Nov 2003 16:40:27 -0400 (AST) +Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) + by svr1.postgresql.org (Postfix) with ESMTP + id D1881D1B53B; Mon, 10 Nov 2003 16:40:25 -0400 (AST) +In-Reply-To: + +Subject: Re: *very* slow query to summarize data for a month ... +To: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org, + "Marc G. Fournier" +X-Mailer: Lotus Notes Release 6.0 September 26, 2002 +Message-ID: + +From: "Patrick Hatcher" +Date: Mon, 10 Nov 2003 12:32:12 -0800 +X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June + 8, 2000) at 11/10/2003 03:34:52 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/29 +X-Sequence-Number: 4589 + + +here's the URL: +http://techdocs.postgresql.org/techdocs/pgsqladventuresep2.php + +Patrick Hatcher +Macys.Com +Legacy Integration Developer +415-422-1610 office +HatcherPT - AIM + + + + Patrick + Hatcher/MCOM/FDD + To + 11/10/2003 12:31 PM "Marc G. Fournier" + @FDS-NOTES + cc + pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.o + rg + Subject + Re: [PERFORM] *very* slow query to + summarize data for a month ... + (Document link: Patrick Hatcher) + + + + + + + + + +Do you have an index on ts.bytes? Josh had suggested this and after I put +it on my summed fields, I saw a speed increase. I can't remember the +article was that Josh had written about index usage, but maybe he'll chime +in and supply the URL for his article. +hth + +Patrick Hatcher + + + + + "Marc G. Fournier" + To + Sent by: pgsql-performance@postgresql.org + pgsql-performance-o cc + wner@postgresql.org + Subject + [PERFORM] *very* slow query to + 11/10/2003 12:18 PM summarize data for a month ... + + + + + + + + + + + +Table structure is simple: + +CREATE TABLE traffic_logs ( + company_id bigint, + ip_id bigint, + port integer, + bytes bigint, + runtime timestamp without time zone +); + +runtime is 'day of month' ... + +I need to summarize the month, per company, with a query as: + +explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS +total_traffic + FROM company c, traffic_logs ts + WHERE c.company_id = ts.company_id + AND month_trunc(ts.runtime) = '2003-10-01' +GROUP BY company_name,ts.company_id; + +and the explain looks like: +QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + Aggregate (cost=32000.94..32083.07 rows=821 width=41) (actual +time=32983.36..47586.17 rows=144 loops=1) + -> Group (cost=32000.94..32062.54 rows=8213 width=41) (actual +time=32957.40..42817.88 rows=462198 loops=1) + -> Sort (cost=32000.94..32021.47 rows=8213 width=41) (actual +time=32957.38..36261.31 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=31321.45..31466.92 rows=8213 width=41) +(actual time=13983.07..22642.14 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) +(actual time=5.52..7.40 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 +rows=352 width=25) (actual time=0.02..2.78 rows=352 loops=1) + -> Sort (cost=31297.04..31317.57 rows=8213 width=16) +(actual time=13977.49..16794.41 rows=462198 loops=1) + Sort Key: ts.company_id + -> Index Scan using tl_month on traffic_logs ts +(cost=0.00..30763.02 rows=8213 width=16) (actual time=0.29..5562.25 +rows=462198 loops=1) + Index Cond: (month_trunc(runtime) += '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 47587.82 msec +(14 rows) + +the problem is that we're only taking a few months worth of data, so I +don't think there is much of a way of 'improve performance' on this, but +figured I'd ask quickly before I do something rash ... + +Note that without the month_trunc() index, the Total runtime more then +doubles: + + +QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + + Aggregate (cost=39578.63..39660.76 rows=821 width=41) (actual +time=87805.47..101251.35 rows=144 loops=1) + -> Group (cost=39578.63..39640.23 rows=8213 width=41) (actual +time=87779.56..96824.56 rows=462198 loops=1) + -> Sort (cost=39578.63..39599.17 rows=8213 width=41) (actual +time=87779.52..90781.48 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=38899.14..39044.62 rows=8213 width=41) +(actual time=64073.98..72783.68 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) +(actual time=64.66..66.55 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 +rows=352 width=25) (actual time=1.76..61.70 rows=352 loops=1) + -> Sort (cost=38874.73..38895.27 rows=8213 width=16) +(actual time=64009.26..66860.71 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts +(cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 +rows=462198 loops=1) + Filter: (date_trunc('month'::text, +runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 101277.17 msec +(14 rows) + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + + + + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 17:02:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3CB48D1B502; Mon, 10 Nov 2003 21:02:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82717-05; Mon, 10 Nov 2003 17:01:36 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 7F794D1B4E1; Mon, 10 Nov 2003 17:01:34 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3896758; Mon, 10 Nov 2003 13:02:18 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +Date: Mon, 10 Nov 2003 12:59:03 -0800 +User-Agent: KMail/1.4.3 +References: <20031110160144.C727@ganymede.hub.org> +In-Reply-To: <20031110160144.C727@ganymede.hub.org> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311101259.03389.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/30 +X-Sequence-Number: 4590 + +Marc, + +I'd say your machine is very low on available RAM, particularly sort_mem.= +=20=20=20 +The steps which are taking a long time are: +=20 +> Aggregate (cost=3D32000.94..32083.07 rows=3D821 width=3D41) (actual=20 +time=3D32983.36..47586.17 rows=3D144 loops=3D1) +> -> Group (cost=3D32000.94..32062.54 rows=3D8213 width=3D41) (actual= +=20 +time=3D32957.40..42817.88 rows=3D462198 loops=3D1) + +and: + +> -> Merge Join (cost=3D31321.45..31466.92 rows=3D8213 wid= +th=3D41)=20 +(actual time=3D13983.07..22642.14 rows=3D462198 loops=3D1) +> Merge Cond: ("outer".company_id =3D "inner".company_= +id) +> -> Sort (cost=3D24.41..25.29 rows=3D352 width=3D25= +) (actual=20 +time=3D5.52..7.40 rows=3D348 loops=3D1) + +There are also *large* delays between steps. Either your I/O is saturate= +d,=20 +or you haven't run a VACUUM FULL ANALYZE in a while (which would also expla= +in=20 +the estimates being off). + + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 18:51:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id EF0A4D1B532; Mon, 10 Nov 2003 22:51:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02423-05; Mon, 10 Nov 2003 18:51:12 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP + id D4DE1D1B4E4; Mon, 10 Nov 2003 18:51:09 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 512951EB9; Mon, 10 Nov 2003 17:51:11 -0500 (EST) +To: "Patrick Hatcher" +Cc: scrappy@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +From: Neil Conway +In-Reply-To: + + (Patrick Hatcher's message of "Mon, 10 Nov 2003 12:31:08 -0800") +References: + +Date: Mon, 10 Nov 2003 17:51:10 -0500 +Message-ID: <87u15bx2g1.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/31 +X-Sequence-Number: 4591 + +"Patrick Hatcher" writes: +> Do you have an index on ts.bytes? Josh had suggested this and after I put +> it on my summed fields, I saw a speed increase. + +What's the reasoning behind this? ISTM that sum() should never use an +index, nor would it benefit from using one. + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 19:16:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id ED640D1B4E4; Mon, 10 Nov 2003 23:16:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02416-10; Mon, 10 Nov 2003 19:15:45 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP + id C86AAD1B50B; Mon, 10 Nov 2003 19:15:42 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 98E6E1E37; Mon, 10 Nov 2003 18:15:44 -0500 (EST) +To: "Marc G. Fournier" +Cc: pgsql-performance@postgresql.org, Tom Lane +Subject: Re: *very* slow query to summarize data for a month ... +From: Neil Conway +In-Reply-To: <20031110160144.C727@ganymede.hub.org> (Marc G. Fournier's + message of "Mon, 10 Nov 2003 16:18:52 -0400 (AST)") +References: <20031110160144.C727@ganymede.hub.org> +Date: Mon, 10 Nov 2003 18:15:41 -0500 +Message-ID: <87ptfzx1b6.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/32 +X-Sequence-Number: 4592 + +"Marc G. Fournier" writes: +> -> Index Scan using tl_month on traffic_logs ts (cost=0.00..30763.02 rows=8213 width=16) (actual time=0.29..5562.25 rows=462198 loops=1) +> Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + +Interesting that we get the row count estimate for this index scan so +wrong -- I believe this is the root of the problem. Hmmm... I would +guess that the optimizer stats we have for estimating the selectivity +of a functional index is pretty primitive, but I haven't looked into +it at all. Tom might be able to shed some light... + +[ In the second EXPLAIN ANALYZE, ... ] + +> -> Seq Scan on traffic_logs ts (cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 rows=462198 loops=1) +> Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + +Uh, what? The "actual time" seems to have finished far before it has +begun :-) Is this just a typo, or does the actual output include a +negative number? + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 19:43:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 8BE8AD1B527; Mon, 10 Nov 2003 23:43:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06338-09; Mon, 10 Nov 2003 19:42:46 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id F369FD1B504; Mon, 10 Nov 2003 19:42:06 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAANg919016201; + Mon, 10 Nov 2003 18:42:09 -0500 (EST) +To: Neil Conway +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-reply-to: <87ptfzx1b6.fsf@mailbox.samurai.com> +References: <20031110160144.C727@ganymede.hub.org> + <87ptfzx1b6.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Mon, 10 Nov 2003 18:15:41 -0500" +Date: Mon, 10 Nov 2003 18:42:09 -0500 +Message-ID: <16200.1068507729@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/33 +X-Sequence-Number: 4593 + +Neil Conway writes: +> Interesting that we get the row count estimate for this index scan so +> wrong -- I believe this is the root of the problem. Hmmm... I would +> guess that the optimizer stats we have for estimating the selectivity +> of a functional index is pretty primitive, but I haven't looked into +> it at all. Tom might be able to shed some light... + +Try "none at all". I have speculated in the past that it would be worth +gathering statistics about the contents of functional indexes, but it's +still on the to-do-someday list. + +>> -> Seq Scan on traffic_logs ts (cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 rows=462198 loops=1) + +> Uh, what? + +That is bizarre, all right. Is it reproducible? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 10 20:22:37 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D5B88D1B522; Tue, 11 Nov 2003 00:22:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15417-05; Mon, 10 Nov 2003 20:22:07 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP + id 20FE1D1B4F2; Mon, 10 Nov 2003 20:22:04 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 0789836F68; Mon, 10 Nov 2003 20:19:57 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id EDC2236F64; Mon, 10 Nov 2003 20:19:56 -0400 (AST) +Date: Mon, 10 Nov 2003 20:19:56 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Neil Conway +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org, Tom Lane +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <87ptfzx1b6.fsf@mailbox.samurai.com> +Message-ID: <20031110201945.X727@ganymede.hub.org> +References: <20031110160144.C727@ganymede.hub.org> + <87ptfzx1b6.fsf@mailbox.samurai.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/34 +X-Sequence-Number: 4594 + + + +On Mon, 10 Nov 2003, Neil Conway wrote: + +> "Marc G. Fournier" writes: +> > -> Index Scan using tl_month on traffic_logs ts (cost=0.00..30763.02 rows=8213 width=16) (actual time=0.29..5562.25 rows=462198 loops=1) +> > Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) +> +> Interesting that we get the row count estimate for this index scan so +> wrong -- I believe this is the root of the problem. Hmmm... I would +> guess that the optimizer stats we have for estimating the selectivity +> of a functional index is pretty primitive, but I haven't looked into +> it at all. Tom might be able to shed some light... +> +> [ In the second EXPLAIN ANALYZE, ... ] +> +> > -> Seq Scan on traffic_logs ts (cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 rows=462198 loops=1) +> > Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) +> +> Uh, what? The "actual time" seems to have finished far before it has +> begun :-) Is this just a typo, or does the actual output include a +> negative number? + +This was purely a cut-n-paste ... + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 20:30:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5696FD1B537; Tue, 11 Nov 2003 00:30:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14342-08; Mon, 10 Nov 2003 20:30:17 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6DAE4D1B527; Mon, 10 Nov 2003 20:30:14 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 4A50937009; Mon, 10 Nov 2003 20:28:07 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id 3CD1A36F64; Mon, 10 Nov 2003 20:28:07 -0400 (AST) +Date: Mon, 10 Nov 2003 20:28:07 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Tom Lane +Cc: Neil Conway , + "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <16200.1068507729@sss.pgh.pa.us> +Message-ID: <20031110202726.J727@ganymede.hub.org> +References: <20031110160144.C727@ganymede.hub.org> + <87ptfzx1b6.fsf@mailbox.samurai.com> + <16200.1068507729@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/35 +X-Sequence-Number: 4595 + + + +On Mon, 10 Nov 2003, Tom Lane wrote: + +> Neil Conway writes: +> > Interesting that we get the row count estimate for this index scan so +> > wrong -- I believe this is the root of the problem. Hmmm... I would +> > guess that the optimizer stats we have for estimating the selectivity +> > of a functional index is pretty primitive, but I haven't looked into +> > it at all. Tom might be able to shed some light... +> +> Try "none at all". I have speculated in the past that it would be worth +> gathering statistics about the contents of functional indexes, but it's +> still on the to-do-someday list. +> +> >> -> Seq Scan on traffic_logs ts (cost=0.00..38340.72 rows=8213 width=16) (actual time=5.02..-645982.04 rows=462198 loops=1) +> +> > Uh, what? +> +> That is bizarre, all right. Is it reproducible? + +Nope, and a subsequent run shows better results too: + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=39674.38..39756.70 rows=823 width=41) (actual time=35573.27..49953.47 rows=144 loops=1) + -> Group (cost=39674.38..39736.12 rows=8232 width=41) (actual time=35547.27..45479.27 rows=462198 loops=1) + -> Sort (cost=39674.38..39694.96 rows=8232 width=41) (actual time=35547.23..39167.90 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=38993.22..39139.02 rows=8232 width=41) (actual time=16658.23..25559.08 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.51..7.38 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.02..2.80 rows=352 loops=1) + -> Sort (cost=38968.82..38989.40 rows=8232 width=16) (actual time=16652.66..19785.83 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38433.46 rows=8232 width=16) (actual time=0.11..8794.43 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 49955.22 msec + + +From pgsql-performance-owner@postgresql.org Mon Nov 10 20:52:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1993FD1B532; Tue, 11 Nov 2003 00:52:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23471-03; Mon, 10 Nov 2003 20:52:08 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6DE17D1B53F; Mon, 10 Nov 2003 20:52:04 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id AFBEC36BEF; Mon, 10 Nov 2003 20:49:57 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id A2A753661D; Mon, 10 Nov 2003 20:49:57 -0400 (AST) +Date: Mon, 10 Nov 2003 20:49:57 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Josh Berkus +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <200311101259.03389.josh@agliodbs.com> +Message-ID: <20031110203259.Y727@ganymede.hub.org> +References: <20031110160144.C727@ganymede.hub.org> + <200311101259.03389.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/36 +X-Sequence-Number: 4596 + + + +On Mon, 10 Nov 2003, Josh Berkus wrote: + +> Marc, +> +> I'd say your machine is very low on available RAM, particularly sort_mem. +> The steps which are taking a long time are: + +Here's the server: + +last pid: 42651; load averages: 1.52, 0.96, 0.88 +up 28+07:43:33 20:35:44 +307 processes: 2 running, 304 sleeping, 1 zombie +CPU states: 18.0% user, 0.0% nice, 29.1% system, 0.6% interrupt, 52.3% idle +Mem: 1203M Active, 1839M Inact, 709M Wired, 206M Cache, 199M Buf, 5608K Free +Swap: 8192M Total, 1804K Used, 8190M Free + +> +> > Aggregate (cost=32000.94..32083.07 rows=821 width=41) (actual +> time=32983.36..47586.17 rows=144 loops=1) +> > -> Group (cost=32000.94..32062.54 rows=8213 width=41) (actual +> time=32957.40..42817.88 rows=462198 loops=1) +> +> and: +> +> > -> Merge Join (cost=31321.45..31466.92 rows=8213 width=41) +> (actual time=13983.07..22642.14 rows=462198 loops=1) +> > Merge Cond: ("outer".company_id = "inner".company_id) +> > -> Sort (cost=24.41..25.29 rows=352 width=25) (actual +> time=5.52..7.40 rows=348 loops=1) +> +> There are also *large* delays between steps. Either your I/O is saturated, +> or you haven't run a VACUUM FULL ANALYZE in a while (which would also explain +> the estimates being off). + +thought about that before I started the thread, and ran it just in case ... + +just restarted the server with sort_mem set to 10M, and didn't help much on the Aggregate, or MergeJoin ... : + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=39674.38..39756.70 rows=823 width=41) (actual time=33066.25..54021.50 rows=144 loops=1) + -> Group (cost=39674.38..39736.12 rows=8232 width=41) (actual time=33040.25..47005.57 rows=462198 loops=1) + -> Sort (cost=39674.38..39694.96 rows=8232 width=41) (actual time=33040.22..37875.97 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=38993.22..39139.02 rows=8232 width=41) (actual time=14428.17..23568.80 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.80..7.66 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.08..3.06 rows=352 loops=1) + -> Sort (cost=38968.82..38989.40 rows=8232 width=16) (actual time=14422.27..17429.34 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38433.46 rows=8232 width=16) (actual time=0.15..8119.72 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 54034.44 msec +(14 rows) + +the problem is that the results we are comparing with right now is the one +that had the - time on it :( Just restarted the server with default +sort_mem, and here is the query with that: + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=39691.27..39773.61 rows=823 width=41) (actual time=35077.18..50424.74 rows=144 loops=1) + -> Group (cost=39691.27..39753.03 rows=8234 width=41) (actual time=35051.29..-650049.84 rows=462198 loops=1) + -> Sort (cost=39691.27..39711.86 rows=8234 width=41) (actual time=35051.26..38847.40 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=39009.92..39155.76 rows=8234 width=41) (actual time=16155.37..25439.42 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.85..7.71 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.10..3.07 rows=352 loops=1) + -> Sort (cost=38985.51..39006.10 rows=8234 width=16) (actual time=16149.46..19437.47 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38450.00 rows=8234 width=16) (actual time=0.16..8869.37 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 50426.80 msec +(14 rows) + + +And, just on a whim, here it is set to 100M: + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=39691.27..39773.61 rows=823 width=41) (actual time=25888.20..38909.88 rows=144 loops=1) + -> Group (cost=39691.27..39753.03 rows=8234 width=41) (actual time=25862.81..34591.76 rows=462198 loops=1) + -> Sort (cost=39691.27..39711.86 rows=8234 width=41) (actual time=25862.77..723885.95 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=39009.92..39155.76 rows=8234 width=41) (actual time=12471.23..21855.08 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.87..7.74 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.11..3.14 rows=352 loops=1) + -> Sort (cost=38985.51..39006.10 rows=8234 width=16) (actual time=12465.29..14941.24 rows=462198 loops=1) + Sort Key: ts.company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38450.00 rows=8234 width=16) (actual time=0.18..9106.16 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 39077.75 msec +(14 rows) + +So, it does give a noticeable improvement the higher the sort_mem ... + +And, @ 100M for sort_mem and using the month_trunc index: + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=32089.29..32171.63 rows=823 width=41) (actual time=30822.51..57202.44 rows=144 loops=1) + -> Group (cost=32089.29..32151.04 rows=8234 width=41) (actual time=30784.24..743396.18 rows=462198 loops=1) + -> Sort (cost=32089.29..32109.87 rows=8234 width=41) (actual time=30784.21..36212.96 rows=462198 loops=1) + Sort Key: c.company_name, ts.company_id + -> Merge Join (cost=31407.94..31553.77 rows=8234 width=41) (actual time=11384.79..24918.56 rows=462198 loops=1) + Merge Cond: ("outer".company_id = "inner".company_id) + -> Sort (cost=24.41..25.29 rows=352 width=25) (actual time=5.92..9.55 rows=348 loops=1) + Sort Key: c.company_id + -> Seq Scan on company c (cost=0.00..9.52 rows=352 width=25) (actual time=0.08..3.21 rows=352 loops=1) + -> Sort (cost=31383.53..31404.12 rows=8234 width=16) (actual time=11378.81..15211.07 rows=462198 loops=1) + Sort Key: ts.company_id + -> Index Scan using tl_month on traffic_logs ts (cost=0.00..30848.02 rows=8234 width=16) (actual time=0.46..7055.75 rows=462198 loops=1) + Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 57401.72 msec +(14 rows) + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 02:50:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 2ABAED1B502; Tue, 11 Nov 2003 06:50:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84838-06; Tue, 11 Nov 2003 02:50:11 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3E602D1B4E1; Tue, 11 Nov 2003 02:50:09 -0400 (AST) +Received: from zigo.dhs.org (zigo [127.0.0.1]) + by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id hAB6o8L2029244; + Tue, 11 Nov 2003 07:50:08 +0100 +Received: from localhost (db@localhost) + by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id hAB6o7FY029239; + Tue, 11 Nov 2003 07:50:08 +0100 +Date: Tue, 11 Nov 2003 07:50:07 +0100 (CET) +From: Dennis Bjorklund +To: "Marc G. Fournier" +Cc: pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <20031110160144.C727@ganymede.hub.org> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/37 +X-Sequence-Number: 4597 + +On Mon, 10 Nov 2003, Marc G. Fournier wrote: + +> +> explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS total_traffic +> FROM company c, traffic_logs ts +> WHERE c.company_id = ts.company_id +> AND month_trunc(ts.runtime) = '2003-10-01' +> GROUP BY company_name,ts.company_id; + +What if you do + + ts.runtime >= '2003-10-01' AND ts.runtime < '2003-11-01' + +and add an index like (runtime, company_name, company_id)? + + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 13:47:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 79EEBD1B564; Tue, 11 Nov 2003 17:47:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88841-08; Tue, 11 Nov 2003 13:47:23 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP + id 23559D1B51E; Tue, 11 Nov 2003 13:47:22 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id C15FC36A82; Tue, 11 Nov 2003 12:47:06 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AJcba-0007BP-00; Tue, 11 Nov 2003 12:47:06 -0500 +To: Dennis Bjorklund +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 11 Nov 2003 12:47:06 -0500 +Message-ID: <878ymmkdb9.fsf@stark.dyndns.tv> +Lines: 41 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/40 +X-Sequence-Number: 4600 + + +Dennis Bjorklund writes: + +> On Mon, 10 Nov 2003, Marc G. Fournier wrote: +> +> > +> > explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS total_traffic +> > FROM company c, traffic_logs ts +> > WHERE c.company_id = ts.company_id +> > AND month_trunc(ts.runtime) = '2003-10-01' +> > GROUP BY company_name,ts.company_id; + +So depending on how much work you're willing to do there are some more +dramatic speedups you could get: + +Use partial indexes like this (you'll need one for every month): + +create index i on traffic_log (company_id) + where month_trunc(runtime) = '2003-10-01' + +then group by company_id only so it can use the index: + +select * + from company + join ( + select company_id, sum(bytes) as total_traffic + from traffic_log + where month_trunc(runtime) = '2003-10-01' + group by company_id + ) as x using (company_id) + order by company_name + + + +Actually you might be able to get the same effect using function indexes like: + +create index i on traffic_log (month_trunc(runtime), company_id) + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 14:19:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E4763D1B53F + for ; + Tue, 11 Nov 2003 18:18:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00214-05 + for ; + Tue, 11 Nov 2003 14:18:29 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CD7FD1B53B + for ; + Tue, 11 Nov 2003 14:18:21 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hABIILNu086094 + for ; Tue, 11 Nov 2003 18:18:21 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hABICUNC085108 + for pgsql-performance@postgresql.org; Tue, 11 Nov 2003 18:12:30 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Suggestions for benchmarking 7.4RC2 against 7.3 +Date: Tue, 11 Nov 2003 13:08:08 -0500 +Organization: cbbrowne Computing Inc +Lines: 16 +Message-ID: +References: <3FB247FE.4080808@trade-india.com> + <3FB24C15.1020907@trade-india.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:VfvMkXcJ1gw579SqoonCd8FvsIw= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/42 +X-Sequence-Number: 4602 + +After a long battle with technology,mallah@trade-india.com (Rajesh Kumar Mallah), an earthling, wrote: +> the error mentioned in first email has been overcome +> by running osdb on the same machine hosting the DB server. + +Yes, it seems unrealistic to try to run the "client" on a separate +host from the database. + +I got the osdb benchmark running last week, and had to separate client +from server. I had to jump through a fair number of hoops including +copying data files over to the server. The benchmark software needs a +bit more work... +-- +let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];; +http://cbbrowne.com/info/lsf.html +Nobody can fix the economy. Nobody can be trusted with their finger +on the button. Nobody's perfect. VOTE FOR NOBODY. + +From pgsql-performance-owner@postgresql.org Tue Nov 11 14:16:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 13C71D1B544 + for ; + Tue, 11 Nov 2003 18:16:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00243-01 + for ; + Tue, 11 Nov 2003 14:16:16 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id E9DDED1B550 + for ; + Tue, 11 Nov 2003 14:16:08 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 4F6D837603; Tue, 11 Nov 2003 14:14:01 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id 4E99D37512; Tue, 11 Nov 2003 14:14:01 -0400 (AST) +Date: Tue, 11 Nov 2003 14:14:01 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Greg Stark +Cc: Dennis Bjorklund , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <878ymmkdb9.fsf@stark.dyndns.tv> +Message-ID: <20031111141328.X56037@ganymede.hub.org> +References: + <878ymmkdb9.fsf@stark.dyndns.tv> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/41 +X-Sequence-Number: 4601 + + +On Tue, 11 Nov 2003, Greg Stark wrote: + +> Actually you might be able to get the same effect using function indexes +> like: +> +> create index i on traffic_log (month_trunc(runtime), company_id) + +had actually thought of that one ... is it something that is only +available in v7.4? + +ams=# create index i on traffic_logs ( month_trunc(runtime), company_id ); +ERROR: parser: parse error at or near "," at character 54 + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 14:26:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BDADED1B53B + for ; + Tue, 11 Nov 2003 18:26:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99727-07 + for ; + Tue, 11 Nov 2003 14:25:40 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id CE3E2D1B534 + for ; + Tue, 11 Nov 2003 14:25:38 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3901393; Tue, 11 Nov 2003 10:26:24 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: Suggestions for benchmarking 7.4RC2 against 7.3 +Date: Tue, 11 Nov 2003 10:25:28 -0800 +User-Agent: KMail/1.4.3 +References: <3FB247FE.4080808@trade-india.com> + <3FB24C15.1020907@trade-india.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311111025.28806.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/43 +X-Sequence-Number: 4603 + +Rajesh, Chris, + +> I got the osdb benchmark running last week, and had to separate client +> from server. I had to jump through a fair number of hoops including +> copying data files over to the server. The benchmark software needs a +> bit more work... + +What about the OSDL's TPC-derivative benchmarks? That's a much more +respected database test, and probably less buggy than OSDB. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Nov 11 14:31:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B6C80D1B53F; Tue, 11 Nov 2003 18:31:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00243-08; Tue, 11 Nov 2003 14:30:51 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id B1486D1B53B; Tue, 11 Nov 2003 14:30:49 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3901415; Tue, 11 Nov 2003 10:31:35 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Marc G. Fournier" , Greg Stark +Subject: Re: *very* slow query to summarize data for a month ... +Date: Tue, 11 Nov 2003 10:30:39 -0800 +User-Agent: KMail/1.4.3 +Cc: Dennis Bjorklund , + pgsql-performance@postgresql.org +References: + <878ymmkdb9.fsf@stark.dyndns.tv> + <20031111141328.X56037@ganymede.hub.org> +In-Reply-To: <20031111141328.X56037@ganymede.hub.org> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311111030.39496.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/44 +X-Sequence-Number: 4604 + +marc, + +> had actually thought of that one ... is it something that is only +> available in v7.4? + +Yes. New feature. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Nov 11 14:40:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4E220D1B54C; Tue, 11 Nov 2003 18:40:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00809-07; Tue, 11 Nov 2003 14:40:13 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3E65ED1B521; Tue, 11 Nov 2003 14:40:12 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id BD5B236BD7; Tue, 11 Nov 2003 14:38:04 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id BA82436B2E; Tue, 11 Nov 2003 14:38:04 -0400 (AST) +Date: Tue, 11 Nov 2003 14:38:04 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Dennis Bjorklund +Cc: "Marc G. Fournier" , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: +Message-ID: <20031111134925.L56037@ganymede.hub.org> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/45 +X-Sequence-Number: 4605 + + + +On Tue, 11 Nov 2003, Dennis Bjorklund wrote: + +> On Mon, 10 Nov 2003, Marc G. Fournier wrote: +> +> > +> > explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS total_traffic +> > FROM company c, traffic_logs ts +> > WHERE c.company_id = ts.company_id +> > AND month_trunc(ts.runtime) = '2003-10-01' +> > GROUP BY company_name,ts.company_id; +> +> What if you do +> +> ts.runtime >= '2003-10-01' AND ts.runtime < '2003-11-01' +> +> and add an index like (runtime, company_name, company_id)? + +Good thought, but even simplifying it to the *lowest* query possible, with +no table joins, is painfully slow: + +explain analyze SELECT ts.company_id, SUM(ts.bytes) AS total_traffic + FROM traffic_logs ts + WHERE month_trunc(ts.runtime) = '2003-10-01' +GROUP BY ts.company_id; + + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=31630.84..31693.05 rows=829 width=16) (actual time=14862.71..26552.39 rows=144 loops=1) + -> Group (cost=31630.84..31672.31 rows=8295 width=16) (actual time=9634.28..20967.07 rows=462198 loops=1) + -> Sort (cost=31630.84..31651.57 rows=8295 width=16) (actual time=9634.24..12838.73 rows=462198 loops=1) + Sort Key: company_id + -> Index Scan using tl_month on traffic_logs ts (cost=0.00..31090.93 rows=8295 width=16) (actual time=0.26..6043.35 rows=462198 loops=1) + Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 26659.35 msec +(7 rows) + + + +-OR- + +explain analyze SELECT ts.company_id, SUM(ts.bytes) AS total_traffic + FROM traffic_logs ts + WHERE ts.runtime >= '2003-10-01' AND ts.runtime < '2003-11-01' +GROUP BY ts.company_id; + + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Aggregate (cost=81044.53..84424.21 rows=45062 width=16) (actual time=13307.52..29274.66 rows=144 loops=1) + -> Group (cost=81044.53..83297.65 rows=450625 width=16) (actual time=10809.02..-673265.13 rows=462198 loops=1) + -> Sort (cost=81044.53..82171.09 rows=450625 width=16) (actual time=10808.99..14069.79 rows=462198 loops=1) + Sort Key: company_id + -> Seq Scan on traffic_logs ts (cost=0.00..38727.35 rows=450625 width=16) (actual time=0.07..6801.92 rows=462198 loops=1) + Filter: ((runtime >= '2003-10-01 00:00:00'::timestamp without time zone) AND (runtime < '2003-11-01 00:00:00'::timestamp without time zone)) + Total runtime: 29385.97 msec +(7 rows) + + +Just as a side note, just doing a straight scan for the records, with no +SUM()/GROUP BY involved, with the month_trunc() index is still >8k msec: + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using tl_month on traffic_logs ts (cost=0.00..31096.36 rows=8297 width=16) (actual time=0.96..5432.93 rows=462198 loops=1) + Index Cond: (month_trunc(runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 8092.88 msec +(3 rows) + +and without the index, >15k msec: + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------ + Seq Scan on traffic_logs ts (cost=0.00..38719.55 rows=8297 width=16) (actual time=0.11..11354.45 rows=462198 loops=1) + Filter: (date_trunc('month'::text, runtime) = '2003-10-01 00:00:00'::timestamp without time zone) + Total runtime: 15353.57 msec +(3 rows) + +so the GROUP BY is affecting the overall, but even without it, its still +taking a helluva long time ... + +I'm going to modify my load script so that it dumps monthly totals to +traffic_logs, and 'details' to a schema.traffic_logs table ... I don't +need the 'per day totals' at the top level at all, only speed ... the 'per +day totals' are only required at the 'per client' level, and by moving the +'per day' into a client schema will shrink the table significantly ... + +If it wasn't for trying to pull in that 'whole month' summary, it would be +fine :( + +From pgsql-performance-owner@postgresql.org Tue Nov 11 15:51:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 064C5D1B50D; Tue, 11 Nov 2003 19:51:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11750-10; Tue, 11 Nov 2003 15:51:23 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP + id 29BF3D1B4FE; Tue, 11 Nov 2003 15:51:22 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 9826F36AD6; Tue, 11 Nov 2003 14:51:22 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AJeXq-0000EA-00; Tue, 11 Nov 2003 14:51:22 -0500 +To: "Marc G. Fournier" +Cc: Greg Stark , Dennis Bjorklund , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +References: + <878ymmkdb9.fsf@stark.dyndns.tv> + <20031111141328.X56037@ganymede.hub.org> +In-Reply-To: <20031111141328.X56037@ganymede.hub.org> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 11 Nov 2003 14:51:22 -0500 +Message-ID: <873ccuk7k5.fsf@stark.dyndns.tv> +Lines: 21 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/46 +X-Sequence-Number: 4606 + +"Marc G. Fournier" writes: + +> On Tue, 11 Nov 2003, Greg Stark wrote: +> +> > Actually you might be able to get the same effect using function indexes +> > like: +> > +> > create index i on traffic_log (month_trunc(runtime), company_id) +> +> had actually thought of that one ... is it something that is only +> available in v7.4? + +Hum, I thought you could do simple functional indexes like that in 7.3, but +perhaps only single-column indexes. + +In any case, given your situation I would seriously consider putting a +"month" integer column on your table anyways. Then your index would be a +simple (month, company_id) index. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 17:40:15 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 10010D1B535; Tue, 11 Nov 2003 21:40:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32471-05; Tue, 11 Nov 2003 17:39:44 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id ADF3FD1B4F6; Tue, 11 Nov 2003 17:39:41 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hABLdANK022676; + Tue, 11 Nov 2003 14:39:11 -0700 (MST) +Date: Tue, 11 Nov 2003 14:25:06 -0700 (MST) +From: "scott.marlowe" +To: Greg Stark +Cc: "Marc G. Fournier" , + Dennis Bjorklund , +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <873ccuk7k5.fsf@stark.dyndns.tv> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/49 +X-Sequence-Number: 4609 + +On 11 Nov 2003, Greg Stark wrote: + +> "Marc G. Fournier" writes: +> +> > On Tue, 11 Nov 2003, Greg Stark wrote: +> > +> > > Actually you might be able to get the same effect using function indexes +> > > like: +> > > +> > > create index i on traffic_log (month_trunc(runtime), company_id) +> > +> > had actually thought of that one ... is it something that is only +> > available in v7.4? +> +> Hum, I thought you could do simple functional indexes like that in 7.3, but +> perhaps only single-column indexes. +> +> In any case, given your situation I would seriously consider putting a +> "month" integer column on your table anyways. Then your index would be a +> simple (month, company_id) index. + +In 7.3 and before, you had to use only column names as inputs, so you +could cheat: + +alter table test add alp int; +alter table test add omg int; +update test set alp=0; +update test set omg=13; + +and then create a functional index: + +create index test_xy on test (substr(info,alp,omg)); + +select * from test where substr(info,alp,omg)=='abcd'; + + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 15:45:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6B55D1B559 + for ; + Tue, 11 Nov 2003 22:27:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36934-10 + for ; + Tue, 11 Nov 2003 18:27:19 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D9FED1B54E + for ; + Tue, 11 Nov 2003 18:27:00 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hABMQx5f032534 + for ; Tue, 11 Nov 2003 17:27:02 -0500 +Reply-To: +From: "Nick Fankhauser - Doxpop" +To: "Pgsql-Performance@Postgresql. Org" +Subject: Seeking help with a query that take too long +Date: Tue, 11 Nov 2003 17:26:48 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/76 +X-Sequence-Number: 4636 + +Hi- + +I have a query that takes too long. I haven't been able to come up with any +ideas for speeding it up, so I'm seeking some input from the list. + +I'm using version 7.3.2 + +I have three tables: + +case_data (1,947,386 rows) +actor (3,385,669 rows) +actor_case_assignment (8,668,650 rows) + +As the names imply, actor_case_assignment contains records that assign an +actor to a case. Actors such as attorneys or judges may have many cases, +while the average actor (we hope) only has one. + +What I'm trying to do is link these tables to get back a single row per +actor that shows the actor's name, the number of cases that actor is +assigned to, and if they only have one case, I want the public_id for that +case. This means I have to do a group by to get the case count, but I'm then +forced to use an aggregate function like max on the other fields. + +All of the fields ending in "_id" have unique indexes, and +actor_full_name_uppercase is indexed. + +Here's the select: + + select + actor.actor_id, + max(actor.actor_full_name), + max(case_data.case_public_id), + max(case_data.case_id), + count(case_data.case_id) as case_count + from + actor, + actor_case_assignment, + case_data + where + actor.actor_full_name_uppercase like upper('sanders%') + and actor.actor_id = actor_case_assignment.actor_id + and case_data.case_id = actor_case_assignment.case_id + group by + actor.actor_id + order by + max(actor.actor_full_name), + case_count desc + limit + 1000; + + +Here's the explain analyze: + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +-------------------------------------------------- + Limit (cost=2214.71..2214.72 rows=1 width=115) (actual +time=120034.61..120035.67 rows=1000 loops=1) + -> Sort (cost=2214.71..2214.72 rows=1 width=115) (actual +time=120034.60..120034.98 rows=1001 loops=1) + Sort Key: max((actor.actor_full_name)::text), +count(case_data.case_id) + -> Aggregate (cost=2214.67..2214.70 rows=1 width=115) (actual +time=119962.80..120011.49 rows=3456 loops=1) + -> Group (cost=2214.67..2214.68 rows=2 width=115) (actual +time=119962.76..119987.04 rows=5879 loops=1) + -> Sort (cost=2214.67..2214.68 rows=2 width=115) +(actual time=119962.74..119965.09 rows=5879 loops=1) + Sort Key: actor.actor_id + -> Nested Loop (cost=0.00..2214.66 rows=2 +width=115) (actual time=59.05..119929.71 rows=5879 loops=1) + -> Nested Loop (cost=0.00..2205.26 rows=3 +width=76) (actual time=51.46..66089.04 rows=5882 loops=1) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) +(actual time=37.62..677.44 rows=3501 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Index Scan using +actor_case_assignment_actor_id on actor_case_assignment (cost=0.00..2165.93 +rows=2666 width=34) (actual time=16.37..18.67 rows=2 loops=3501) + Index Cond: ("outer".actor_id = +actor_case_assignment.actor_id) + -> Index Scan using case_data_case_id on +case_data (cost=0.00..3.66 rows=1 width=39) (actual time=9.14..9.15 rows=1 +loops=5882) + Index Cond: (case_data.case_id = +"outer".case_id) + Total runtime: 120038.60 msec +(17 rows) + + +Any ideas? + +Thanks! + -Nick + + +--------------------------------------------------------------------- +Nick Fankhauser + + nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +doxpop - Court records at your fingertips - http://www.doxpop.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 19:41:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CC937D1B531 + for ; + Tue, 11 Nov 2003 23:41:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54023-10 + for ; + Tue, 11 Nov 2003 19:41:25 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EB56D1B51E + for ; + Tue, 11 Nov 2003 19:41:22 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Server Configs +Date: Tue, 11 Nov 2003 17:57:15 -0500 +Message-ID: + <2F2E24372F10744588A27DEECC85FE04023C416E@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Server Configs +Thread-Index: AcOjxEI2VXnAdXMxRXy5Wh4EYnKxpAE4LlDg +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200311/51 +X-Sequence-Number: 4611 + +Dear Gurus, + +We are planning to add more db server hardware for the apps. The +question is, what makes more sense regarding +performance/scalability/price of the hardware... + +There are a couple of apps, currently on a dual-cpu Dell server. The +usage of the apps is going to increase quite a lot, and considering the +prices, we are looking at the following options: + +Option 1: +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Have each app on a separate db server (looking at 4 of these). The +server being a PowerEdge 2650, Dual 2.8GHz/512KB XEONS, 2GB RAM, PERC-3 +RAID-5, split back plane (2+3), and 5 x 36GB HDDs (10K RPM). + +Note: These servers are 1/3 the price of the Quad-cpu 6650 server. + +Option 2: +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Have two to three apps dbs hosted on a single server. The server being a +PowerEdge 6650, 4 x 2GHz/1MB XEONS, 8GB RAM, PERC-3 RAID-5, split back +plane (2+3), and 5 x 36GB HDDs (10K RPM). + +Note: This server is 3 times more the price of the option 1. + + + +Appreciate your guidance. + +Thanks, +Anjan + +From pgsql-performance-owner@postgresql.org Tue Nov 11 19:33:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 155E5D1B51E + for ; + Tue, 11 Nov 2003 23:33:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52424-08 + for ; + Tue, 11 Nov 2003 19:33:05 -0400 (AST) +Received: from corp1.affinitysolutions.com (corp1.affinitysolutions.com + [216.52.88.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 026ADD1B50C + for ; + Tue, 11 Nov 2003 19:33:03 -0400 (AST) +Received: from tuxsrva.afsnyc-nt1.affinitysolutions.com (unknown + [216.220.102.122]) + by corp1.affinitysolutions.com (Postfix) with ESMTP id 06B9B11F705 + for ; + Tue, 11 Nov 2003 18:32:49 -0500 (EST) +Subject: Value of Quad vs. Dual Processor machine +From: Chris Field +Reply-To: cfield@affinitysolutions.com +To: pgsql-performance@postgresql.org +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-Pp9U7L6ZAviF2yFBgYtQ" +Organization: Affinity Solutions +Message-Id: <1068593567.2063.8.camel@tuxsrva> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4 +Date: Tue, 11 Nov 2003 18:32:47 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/50 +X-Sequence-Number: 4610 + +--=-Pp9U7L6ZAviF2yFBgYtQ +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +We are getting ready to spec out a new machine and are wondering about +the wisdom of buying a quad versus a dual processor machine. Seing as +how postgres in not a threaded application, and this server will only be +used for log/transaction analysis (it will only ever have a few large +queries running). Is there any performance to be gained, and if so is +it worth the large cost? Any thoughts/experience are much +appreciated... + + + + +--=20 +Chris Field +cfield@affinitysolutions.com +Affinity Solutions Inc. +386 Park Avenue South +Suite 1209 +New York, NY 10016 +(212) 685-8748 ext. 32 + +--=-Pp9U7L6ZAviF2yFBgYtQ +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.0.7 (GNU/Linux) + +iD8DBQA/sXGfkTUAUyBR2GYRAthQAJ9MUbHD426ykBbMWtbKc2udiPKXbwCfVDFY +LHQzFgVUwTNDE8PQxHwSgfQ= +=Z6sz +-----END PGP SIGNATURE----- + +--=-Pp9U7L6ZAviF2yFBgYtQ-- + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 19:51:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA3E7D1B4FA + for ; + Tue, 11 Nov 2003 23:51:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56717-03 + for ; + Tue, 11 Nov 2003 19:51:27 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 8ACD0D1B531 + for ; + Tue, 11 Nov 2003 19:51:23 -0400 (AST) +Received: (qmail 4509 invoked from network); 11 Nov 2003 23:51:50 -0000 +Received: from unknown (HELO ?192.168.1.199?) (134.22.68.129) + by 205.178.180.9 with SMTP; 11 Nov 2003 23:51:50 -0000 +Subject: Re: Value of Quad vs. Dual Processor machine +From: Rod Taylor +To: cfield@affinitysolutions.com +Cc: Postgresql Performance +In-Reply-To: <1068593567.2063.8.camel@tuxsrva> +References: <1068593567.2063.8.camel@tuxsrva> +Content-Type: text/plain +Message-Id: <1068594688.28107.16.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 11 Nov 2003 18:51:28 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/52 +X-Sequence-Number: 4612 + +On Tue, 2003-11-11 at 18:32, Chris Field wrote: +> We are getting ready to spec out a new machine and are wondering about +> the wisdom of buying a quad versus a dual processor machine. Seing as +> how postgres in not a threaded application, and this server will only be +> used for log/transaction analysis (it will only ever have a few large +> queries running). Is there any performance to be gained, and if so is +> it worth the large cost? Any thoughts/experience are much +> appreciated... + +Since you're asking the question, I'll assume you don't have CPU +intensive queries or monstrous loads. + +I'd probably invest in a Quad system with 2 chips in it (2 empty +sockets) and put the difference in funds into a few extra GB of Ram or +improved IO. + +In 6 months or a year, if you start doing longer or more complex +queries, toss in the other 2 chips. So long as you don't hit a memory +limit, it'll be fine. + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 20:55:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CD336D1B4FA + for ; + Wed, 12 Nov 2003 00:55:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65173-10 + for ; + Tue, 11 Nov 2003 20:54:38 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id BBD6CD1B50C + for ; + Tue, 11 Nov 2003 20:54:34 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hAC0sJNK002597; + Tue, 11 Nov 2003 17:54:20 -0700 (MST) +Date: Tue, 11 Nov 2003 17:40:14 -0700 (MST) +From: "scott.marlowe" +To: Rod Taylor +Cc: , + Postgresql Performance +Subject: Re: Value of Quad vs. Dual Processor machine +In-Reply-To: <1068594688.28107.16.camel@jester> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/53 +X-Sequence-Number: 4613 + +On Tue, 11 Nov 2003, Rod Taylor wrote: + +> On Tue, 2003-11-11 at 18:32, Chris Field wrote: +> > We are getting ready to spec out a new machine and are wondering about +> > the wisdom of buying a quad versus a dual processor machine. Seing as +> > how postgres in not a threaded application, and this server will only be +> > used for log/transaction analysis (it will only ever have a few large +> > queries running). Is there any performance to be gained, and if so is +> > it worth the large cost? Any thoughts/experience are much +> > appreciated... +> +> Since you're asking the question, I'll assume you don't have CPU +> intensive queries or monstrous loads. +> +> I'd probably invest in a Quad system with 2 chips in it (2 empty +> sockets) and put the difference in funds into a few extra GB of Ram or +> improved IO. +> +> In 6 months or a year, if you start doing longer or more complex +> queries, toss in the other 2 chips. So long as you don't hit a memory +> limit, it'll be fine. + +Note that you want to carefully look at the difference in cost of the +motherboard versus the CPUs. It's often the motherboard that raises the +cost, not the CPUs so much. Although with Xeons, the CPUs are not cheap. + +The second issue is that Intel (and AMD probably) only guarantee proper +performance from chips int he same batch, so you may wind up replacing the +two working CPUs with two new ones to go with the other two you'll be +buying, to make sure that they work together. + +My guess is that more CPUs aren't gonna help this problem a lot, so look +more at fast RAM and lots of it, as well as a fast I/O subsystem. + +2 CPUs should be plenty. + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 21:03:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B941D1B51E + for ; + Wed, 12 Nov 2003 01:03:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65104-10 + for ; + Tue, 11 Nov 2003 21:02:49 -0400 (AST) +Received: from lifeintegrity.com (h000476f4f1ab.ne.client2.attbi.com + [66.30.209.218]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CD7ED1B4FA + for ; + Tue, 11 Nov 2003 21:02:39 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lifeintegrity.com (Postfix) with ESMTP id CAC2C60041 + for ; + Tue, 11 Nov 2003 20:02:41 -0500 (EST) +Received: from lifeintegrity.com ([127.0.0.1]) + by localhost (pawan.lifeintegrity.com [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 05712-02-10 for ; + Tue, 11 Nov 2003 20:02:41 -0500 (EST) +Received: by lifeintegrity.com (Postfix, from userid 1000) + id 08A756001B; Tue, 11 Nov 2003 20:02:40 -0500 (EST) +Date: Tue, 11 Nov 2003 20:02:40 -0500 +To: Postgresql Performance +Subject: Re: Value of Quad vs. Dual Processor machine +Message-ID: <20031112010240.GA3751@lifeintegrity.com> +Mail-Followup-To: Postgresql Performance +References: <1068594688.28107.16.camel@jester> + +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="+QahgC5+KEYLbs62" +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +From: allanwind@lifeintegrity.com (Allan Wind) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/54 +X-Sequence-Number: 4614 + +--+QahgC5+KEYLbs62 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On 2003-11-11T17:40:14-0700, scott.marlowe wrote: +> 2 CPUs should be plenty. + +for everyone? No, I must have been thinking of someone else :-) + + +/Allan +--=20 +Allan Wind +P.O. Box 2022 +Woburn, MA 01888-0022 +USA + +--+QahgC5+KEYLbs62 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQE/sYawuDtNyOwreTYRAoe2AKDAQYKoQM7/5ZkDge18dnW6Gm2jRgCePedQ +bKNjnJvKqwAhc1fK3bsGJ5A= +=qskP +-----END PGP SIGNATURE----- + +--+QahgC5+KEYLbs62-- + +From pgsql-performance-owner@postgresql.org Tue Nov 11 21:11:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B9CED1B4F6 + for ; + Wed, 12 Nov 2003 01:11:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65807-10 + for ; + Tue, 11 Nov 2003 21:11:23 -0400 (AST) +Received: from redhotpenguin.com (12-240-9-202.client.attbi.com + [12.240.9.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 31835D1B521 + for ; + Tue, 11 Nov 2003 21:11:19 -0400 (AST) +Received: (qmail 29762 invoked from network); 12 Nov 2003 01:11:20 -0000 +Received: from localhost (HELO 127.0.0.1) (127.0.0.1) + by localhost with SMTP; 12 Nov 2003 01:11:20 -0000 +Received: from 127.0.0.1 (proxying for 12.240.9.202) + (SquirrelMail authenticated user fred@redhotpenguin.com) + by 127.0.0.1 with HTTP; Tue, 11 Nov 2003 17:11:20 -0800 (PST) +Message-ID: <53970.127.0.0.1.1068599480.squirrel@127.0.0.1> +In-Reply-To: +References: <1068594688.28107.16.camel@jester> + +Date: Tue, 11 Nov 2003 17:11:20 -0800 (PST) +Subject: Re: Value of Quad vs. Dual Processor machine +From: fred@redhotpenguin.com +To: "scott.marlowe" +Cc: "Rod Taylor" , cfield@affinitysolutions.com, + "Postgresql Performance" +User-Agent: SquirrelMail/1.4.2-1.qvcs.1 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/55 +X-Sequence-Number: 4615 + +> On Tue, 11 Nov 2003, Rod Taylor wrote: +> +>> On Tue, 2003-11-11 at 18:32, Chris Field wrote: +>> > We are getting ready to spec out a new machine and are wondering about +>> > the wisdom of buying a quad versus a dual processor machine. Seing as +>> > how postgres in not a threaded application, and this server will only +>> be +>> > used for log/transaction analysis (it will only ever have a few large +>> > queries running). Is there any performance to be gained, and if so is +>> > it worth the large cost? Any thoughts/experience are much +>> > appreciated... +>> +>> Since you're asking the question, I'll assume you don't have CPU +>> intensive queries or monstrous loads. +>> +>> I'd probably invest in a Quad system with 2 chips in it (2 empty +>> sockets) and put the difference in funds into a few extra GB of Ram or +>> improved IO. +>> +>> In 6 months or a year, if you start doing longer or more complex +>> queries, toss in the other 2 chips. So long as you don't hit a memory +>> limit, it'll be fine. +> +> Note that you want to carefully look at the difference in cost of the +> motherboard versus the CPUs. It's often the motherboard that raises the +> cost, not the CPUs so much. Although with Xeons, the CPUs are not cheap. +> +> The second issue is that Intel (and AMD probably) only guarantee proper +> performance from chips int he same batch, so you may wind up replacing the +> two working CPUs with two new ones to go with the other two you'll be +> buying, to make sure that they work together. +> +> My guess is that more CPUs aren't gonna help this problem a lot, so look +> more at fast RAM and lots of it, as well as a fast I/O subsystem. +> +> 2 CPUs should be plenty. +I agree that the additional cpus won't help as much since I haven't found +any benefits in terms of individual query speed for a quad vs. an smp on +benchmarks I've run on test machines I was considering purchasing. Quads +are also expensive - on similar architectures the quad was 20k vs 7k for +the dual. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 21:25:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E5EDFD1B4F9 + for ; + Wed, 12 Nov 2003 01:25:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74568-04 + for ; + Tue, 11 Nov 2003 21:24:52 -0400 (AST) +Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) + by svr1.postgresql.org (Postfix) with ESMTP id A87BDD1B4F6 + for ; + Tue, 11 Nov 2003 21:24:48 -0400 (AST) +Received: from lhosts ([68.11.66.83]) by lakemtao01.cox.net + (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP + id <20031112012451.LKBW23168.lakemtao01.cox.net@lhosts> + for ; + Tue, 11 Nov 2003 20:24:51 -0500 +Subject: Re: Value of Quad vs. Dual Processor machine +From: Ron Johnson +To: PgSQL Performance ML +In-Reply-To: <1068593567.2063.8.camel@tuxsrva> +References: <1068593567.2063.8.camel@tuxsrva> +Content-Type: text/plain +Message-Id: <1068600291.30969.53.camel@haggis.homelan> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 11 Nov 2003 19:24:51 -0600 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/56 +X-Sequence-Number: 4616 + +On Tue, 2003-11-11 at 17:32, Chris Field wrote: +> We are getting ready to spec out a new machine and are wondering about +> the wisdom of buying a quad versus a dual processor machine. Seing as +> how postgres in not a threaded application, and this server will only be +> used for log/transaction analysis (it will only ever have a few large +> queries running). Is there any performance to be gained, and if so is +> it worth the large cost? Any thoughts/experience are much +> appreciated... + +Xeon or Opteron? The faster Opterons *really* blaze, especially +in 64-bit mode. As others have said, though, RAM and I/O are most +important. + +-- +----------------------------------------------------------------- +Ron Johnson, Jr. ron.l.johnson@cox.net +Jefferson, LA USA + +"As I like to joke, I may have invented it, but Microsoft made it +popular" +David Bradley, regarding Ctrl-Alt-Del + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 22:12:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DF94D1B50B + for ; + Wed, 12 Nov 2003 02:12:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75635-09 + for ; + Tue, 11 Nov 2003 22:11:41 -0400 (AST) +Received: from corp1.affinitysolutions.com (corp1.affinitysolutions.com + [216.52.88.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 76B2BD1B53B + for ; + Tue, 11 Nov 2003 22:11:37 -0400 (AST) +Received: from win2000 (24-193-100-224.nyc.rr.com [24.193.100.224]) + by corp1.affinitysolutions.com (Postfix) with ESMTP + id BAAF111F703; Tue, 11 Nov 2003 21:11:39 -0500 (EST) +Message-ID: <001401c3a8c2$8c8fec30$040210ac@win2000> +Reply-To: "Chris Field" +From: "Chris Field" +To: "Ron Johnson" , + "PgSQL Performance ML" +References: <1068593567.2063.8.camel@tuxsrva> + <1068600291.30969.53.camel@haggis.homelan> +Subject: Re: Value of Quad vs. Dual Processor machine +Date: Tue, 11 Nov 2003 21:13:19 -0500 +Organization: Affinity Solutions +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=BAYES_30, + QUOTED_EMAIL_TEXT, RCVD_IN_NJABL, REFERENCES, X_NJABL_OPEN_PROXY +X-Spam-Level: +X-Archive-Number: 200311/57 +X-Sequence-Number: 4617 + +we are looking at Xeon, We are currently running it on a quad sun v880 +compiled to be 64bit and have been getting dreadful performance. I don't +think we really have much to gain from going 64bit. + + +----- Original Message ----- +From: "Ron Johnson" +To: "PgSQL Performance ML" +Sent: Tuesday, November 11, 2003 8:24 PM +Subject: Re: [PERFORM] Value of Quad vs. Dual Processor machine + + +> On Tue, 2003-11-11 at 17:32, Chris Field wrote: +> > We are getting ready to spec out a new machine and are wondering about +> > the wisdom of buying a quad versus a dual processor machine. Seing as +> > how postgres in not a threaded application, and this server will only be +> > used for log/transaction analysis (it will only ever have a few large +> > queries running). Is there any performance to be gained, and if so is +> > it worth the large cost? Any thoughts/experience are much +> > appreciated... +> +> Xeon or Opteron? The faster Opterons *really* blaze, especially +> in 64-bit mode. As others have said, though, RAM and I/O are most +> important. +> +> -- +> ----------------------------------------------------------------- +> Ron Johnson, Jr. ron.l.johnson@cox.net +> Jefferson, LA USA +> +> "As I like to joke, I may have invented it, but Microsoft made it +> popular" +> David Bradley, regarding Ctrl-Alt-Del +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 23:18:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 92EF5D1B536 + for ; + Wed, 12 Nov 2003 03:18:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77815-10 + for ; + Tue, 11 Nov 2003 23:17:39 -0400 (AST) +Received: from redhotpenguin.com (12-240-9-202.client.attbi.com + [12.240.9.202]) + by svr1.postgresql.org (Postfix) with ESMTP id D7DD7D1B4F9 + for ; + Tue, 11 Nov 2003 23:17:34 -0400 (AST) +Received: (qmail 30551 invoked from network); 12 Nov 2003 03:17:38 -0000 +Received: from 12-240-9-202.client.attbi.com (HELO harpua) + (fred@redhotpenguin.com@12.240.9.202) + by 192.168.0.2 with RC4-MD5 encrypted SMTP; 12 Nov 2003 03:17:38 -0000 +From: "Fred Moyer" +To: "'Chris Field'" , + "'Ron Johnson'" , + "'PgSQL Performance ML'" +Subject: Re: Value of Quad vs. Dual Processor machine +Date: Tue, 11 Nov 2003 19:17:40 -0800 +Message-ID: <000001c3a8cb$87ff7880$0300a8c0@harpua> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +In-Reply-To: <001401c3a8c2$8c8fec30$040210ac@win2000> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/58 +X-Sequence-Number: 4618 + +One thing I learned after spending about a week comparing the Athlon (2 +ghz, 333 mhz frontside bus) and Xeon (2.4 ghz, 266 mhz frontside bus) +platforms was that on average the select queries I was benchmarking ran +30% faster on the Athlon (this was with data cached in memory so may not +apply to the larger data sets where I/O is the limiting factor.) + +I benchmarked against the Opteron 244 when it came out and it came in +about the same as the Athlon (makes sense since both were 333 mhz +memory). The results within +/- 5-10% that of the Athlon. From testing +against a couple of other machines I noticed that the memory bus speeds +were almost directly proportional to the query times under these +conditions. + +Not sure how these compare against the quad sun but the AMD chips +returned the select queries faster than the Xeons from the informal +investigations I did. Definitely try it before you buy it if possible. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Chris Field +Sent: Tuesday, November 11, 2003 6:13 PM +To: Ron Johnson; PgSQL Performance ML +Subject: Re: [PERFORM] Value of Quad vs. Dual Processor machine + + +we are looking at Xeon, We are currently running it on a quad sun v880 +compiled to be 64bit and have been getting dreadful performance. I +don't think we really have much to gain from going 64bit. + + +----- Original Message ----- +From: "Ron Johnson" +To: "PgSQL Performance ML" +Sent: Tuesday, November 11, 2003 8:24 PM +Subject: Re: [PERFORM] Value of Quad vs. Dual Processor machine + + +> On Tue, 2003-11-11 at 17:32, Chris Field wrote: +> > We are getting ready to spec out a new machine and are wondering +> > about the wisdom of buying a quad versus a dual processor machine. +> > Seing as how postgres in not a threaded application, and this server + +> > will only be used for log/transaction analysis (it will only ever +> > have a few large queries running). Is there any performance to be +> > gained, and if so is it worth the large cost? Any +> > thoughts/experience are much appreciated... +> +> Xeon or Opteron? The faster Opterons *really* blaze, especially in +> 64-bit mode. As others have said, though, RAM and I/O are most +> important. +> +> -- +> ----------------------------------------------------------------- +> Ron Johnson, Jr. ron.l.johnson@cox.net +> Jefferson, LA USA +> +> "As I like to joke, I may have invented it, but Microsoft made it +> popular" David Bradley, regarding Ctrl-Alt-Del +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 01:53:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 47E97D1B508; Wed, 12 Nov 2003 05:53:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18988-09; Wed, 12 Nov 2003 01:52:46 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1D454D1B50C; Wed, 12 Nov 2003 01:52:45 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 6550E3692A; Wed, 12 Nov 2003 00:52:44 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AJnvo-0006jW-00; Wed, 12 Nov 2003 00:52:44 -0500 +To: "Marc G. Fournier" +Cc: Dennis Bjorklund , + pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +References: + <20031111134925.L56037@ganymede.hub.org> +In-Reply-To: <20031111134925.L56037@ganymede.hub.org> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 12 Nov 2003 00:52:44 -0500 +Message-ID: <87oevii15f.fsf@stark.dyndns.tv> +Lines: 49 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/59 +X-Sequence-Number: 4619 + + +"Marc G. Fournier" writes: + +> Just as a side note, just doing a straight scan for the records, with no +> SUM()/GROUP BY involved, with the month_trunc() index is still >8k msec: + +Well so the problem isn't the query at all, you just have too much data to +massage online. You can preprocess the data offline into a more managable +amount of data for your online reports. + +What I used to do for a similar situation was to do hourly queries sort of +like this: + +insert into data_aggregate (day, hour, company_id, total_bytes) + (select trunc(now(),'day'), trunc(now(), 'hour'), company_id, sum(bytes) + from raw_data + where time between trunc(now(),'hour') and trunc(now(),'hour')+'1 hour'::interval + group by company_id + ) + +[this was actually on oracle and the data looked kind of different, i'm making +this up as i go along] + +Then later the reports could run quickly based on data_aggregate instead of +slowly based on the much larger data set accumulated by the minute. Once I had +this schema set up it was easy to follow it for all of the rapidly growing +data tables. + +Now in my situation I had thousands of records accumulating per second, so +hourly was already a big win. I originally chose hourly because I thought I +might want time-of-day reports but that never panned out. On the other hand it +was a win when the system broke once because I could easily see that and fix +it before midnight when it would have actually mattered. Perhaps in your +situation you would want daily aggregates or something else. + +One of the other advantages of these aggregate tables was that we could purge +the old data much sooner with much less resistance from the business. Since +the reports were all still available and a lot of ad-hoc queries could still +be done without the raw data anyways. + +Alternatively you can just give up on online reports. Eventually you'll have +some query that takes way more than 8s anyways. You can pregenerate the entire +report as a batch job instead. Either send it off as a nightly e-mail, store +it as an html or csv file for the web server, or (my favourite) store the data +for the report as an sql table and then have multiple front-ends that do a +simple "select *" to pull the data and format it. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 04:43:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E0EBDD1B509 + for ; + Wed, 12 Nov 2003 08:43:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36213-09 + for ; + Wed, 12 Nov 2003 04:43:08 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id B1F25D1B531 + for ; + Wed, 12 Nov 2003 04:43:06 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 12 Nov 2003 01:43:06 -0700 +Message-ID: <3FB1F28E.702@myrealbox.com> +Date: Wed, 12 Nov 2003 14:12:54 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Fred Moyer +Cc: 'Chris Field' , + 'Ron Johnson' , + 'PgSQL Performance ML' +Subject: Re: Value of Quad vs. Dual Processor machine +References: <000001c3a8cb$87ff7880$0300a8c0@harpua> +In-Reply-To: <000001c3a8cb$87ff7880$0300a8c0@harpua> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/60 +X-Sequence-Number: 4620 + +Fred Moyer wrote: +> One thing I learned after spending about a week comparing the Athlon (2 +> ghz, 333 mhz frontside bus) and Xeon (2.4 ghz, 266 mhz frontside bus) +> platforms was that on average the select queries I was benchmarking ran +> 30% faster on the Athlon (this was with data cached in memory so may not +> apply to the larger data sets where I/O is the limiting factor.) +> +> I benchmarked against the Opteron 244 when it came out and it came in +> about the same as the Athlon (makes sense since both were 333 mhz +> memory). The results within +/- 5-10% that of the Athlon. From testing +> against a couple of other machines I noticed that the memory bus speeds +> were almost directly proportional to the query times under these +> conditions. + +I remember a posting here about opteron, which essentially said, even if opteron +works on par with athlon under few clients, as load increases it scales more +than 50% better than athlons. + +So that could be another shot at it.Sorry, no handy URL here. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 09:35:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9B8FD1B51E + for ; + Wed, 12 Nov 2003 13:35:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76401-08 + for ; + Wed, 12 Nov 2003 09:35:09 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FB63D1B51A + for ; + Wed, 12 Nov 2003 09:35:05 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hACDZ15f012637 + for ; Wed, 12 Nov 2003 08:35:04 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Pgsql-Performance@Postgresql. Org" +Subject: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 08:34:50 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/61 +X-Sequence-Number: 4621 + +[I originally posted this using the wrong E-Mail account, so a double +posting may occur if the first message gets released by the moderator later- +sorry!] + +Hi- + +I have a query that I'm trying to speed up. I haven't been able to come up +with any workable ideas for speeding it up, so I'm seeking some input from +the list. + +I'm using version 7.3.2 + +I have three tables: + +case_data (1,947,386 rows) +actor (3,385,669 rows) +actor_case_assignment (8,668,650 rows) + +As the names imply, actor_case_assignment contains records that assign an +actor to a case. Actors such as attorneys or judges may have many cases, +while the average actor (we hope) only has one. + +What I'm trying to do is link these tables to get back a single row per +actor that shows the actor's name, the number of cases that actor is +assigned to, and if they only have one case, I want the public_id for that +case. This means I have to do a group by to get the case count, but I'm then +forced to use an aggregate function like max on the other fields. + +All of the fields ending in "_id" have unique indexes, and +actor_full_name_uppercase is indexed. An analyze is done every night & the +database is fairly stable in it's composition. + +Here's the select: + + select + actor.actor_id, + max(actor.actor_full_name), + max(case_data.case_public_id), + max(case_data.case_id), + count(case_data.case_id) as case_count + from + actor, + actor_case_assignment, + case_data + where + actor.actor_full_name_uppercase like upper('sanders%') + and actor.actor_id = actor_case_assignment.actor_id + and case_data.case_id = actor_case_assignment.case_id + group by + actor.actor_id + order by + max(actor.actor_full_name), + case_count desc + limit + 1000; + + +Here's the explain analyze: + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +-------------------------------------------------- + Limit (cost=2214.71..2214.72 rows=1 width=115) (actual +time=120034.61..120035.67 rows=1000 loops=1) + -> Sort (cost=2214.71..2214.72 rows=1 width=115) (actual +time=120034.60..120034.98 rows=1001 loops=1) + Sort Key: max((actor.actor_full_name)::text), +count(case_data.case_id) + -> Aggregate (cost=2214.67..2214.70 rows=1 width=115) (actual +time=119962.80..120011.49 rows=3456 loops=1) + -> Group (cost=2214.67..2214.68 rows=2 width=115) (actual +time=119962.76..119987.04 rows=5879 loops=1) + -> Sort (cost=2214.67..2214.68 rows=2 width=115) +(actual time=119962.74..119965.09 rows=5879 loops=1) + Sort Key: actor.actor_id + -> Nested Loop (cost=0.00..2214.66 rows=2 +width=115) (actual time=59.05..119929.71 rows=5879 loops=1) + -> Nested Loop (cost=0.00..2205.26 rows=3 +width=76) (actual time=51.46..66089.04 rows=5882 loops=1) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) +(actual time=37.62..677.44 rows=3501 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Index Scan using +actor_case_assignment_actor_id on actor_case_assignment (cost=0.00..2165.93 +rows=2666 width=34) (actual time=16.37..18.67 rows=2 loops=3501) + Index Cond: ("outer".actor_id = +actor_case_assignment.actor_id) + -> Index Scan using case_data_case_id on +case_data (cost=0.00..3.66 rows=1 width=39) (actual time=9.14..9.15 rows=1 +loops=5882) + Index Cond: (case_data.case_id = +"outer".case_id) + Total runtime: 120038.60 msec +(17 rows) + + +Any ideas? + +Thanks! + -Nick + + +--------------------------------------------------------------------- +Nick Fankhauser + + nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +doxpop - Court records at your fingertips - http://www.doxpop.com/ + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 10:28:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CE44D1B51C + for ; + Wed, 12 Nov 2003 14:28:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91126-09 + for ; + Wed, 12 Nov 2003 10:28:20 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 73FB4D1B50D + for ; + Wed, 12 Nov 2003 10:28:15 -0400 (AST) +Received: (qmail 77237 invoked from network); 12 Nov 2003 14:28:21 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 12 Nov 2003 14:28:21 -0000 +Date: Wed, 12 Nov 2003 09:28:07 -0500 +From: Jeff +To: "Chris Field" +Cc: ron.l.johnson@cox.net, pgsql-performance@postgresql.org +Subject: Re: Value of Quad vs. Dual Processor machine +Message-Id: <20031112092807.14b18bf4.threshar@torgo.978.org> +In-Reply-To: <001401c3a8c2$8c8fec30$040210ac@win2000> +References: <1068593567.2063.8.camel@tuxsrva> + <1068600291.30969.53.camel@haggis.homelan> + <001401c3a8c2$8c8fec30$040210ac@win2000> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/62 +X-Sequence-Number: 4622 + +On Tue, 11 Nov 2003 21:13:19 -0500 +"Chris Field" wrote: + +> we are looking at Xeon, We are currently running it on a quad sun v880 +> compiled to be 64bit and have been getting dreadful performance. I +> don't think we really have much to gain from going 64bit. +> +> +By chance, are you running 7.3.4 on that sun? +If so, try this: +export CFLAGS=-02 +./configure + +and rebuild PG. + +Before 7.4 PG was build with _no_ optimization on Solaris. +Recompiling gives __HUGE__ (notice the underscores) performance gains. + +And onto the dual vs quad. + +PG will only use 1 cpu / connection / query. + +So if your machine iwll have 1-2 queries running at a time those other 2 +proc's will sit around idling. However if you are going to have a bunch +going, 4 cpus will be most useful. One of hte nicest things to do for +PG is more ram and fast IO. It really loves those things. + +good luck + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Tue Nov 11 10:47:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9383DD1B53F + for ; + Tue, 11 Nov 2003 14:47:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59023-02 + for ; + Tue, 11 Nov 2003 10:47:11 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id EA891D1B531 + for ; + Tue, 11 Nov 2003 10:47:06 -0400 (AST) +Received: (qmail 2566 invoked from network); 11 Nov 2003 14:48:21 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 11 Nov 2003 14:48:21 -0000 +Message-ID: <3FB247FE.4080808@trade-india.com> +Date: Wed, 12 Nov 2003 20:17:26 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Suggestions for benchmarking 7.4RC2 against 7.3 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/38 +X-Sequence-Number: 4598 + + +Hi, + +I plan to put 7.4-RC2 in our production servers in next few hours. + +Since the hardware config & the performance related GUCs parameter +are going to remain the same i am interested in seeing the performance +improvements in 7.4 as compared 7.3 . + +For this i plan to use the OSDB 0.14 and compare the results for both the +cases. + +Does any one has suggestions for comparing 7.4 against 7.3 ? +Since i am using OSDB for second time only any tips/guidance +on usage of that is also appreciated. + + + +H/W config: + +CPU: 4 X Intel(R) Xeon(TM) CPU 2.00GHz +MEM : 2 GB +I/O config : PGDATA on 10000 RPM Ultra160 scsi , pg_xlog on a similar +seperate SCSI + +GUC: +shared_buffers = 10000 +max_fsm_relations = 5000 +max_fsm_pages = 55099264 +sort_mem = 16384 +vacuum_mem = 8192 + +All other performance related parameter have default +value eg: + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + + + +BTW i get following error at the moment: +----------------------------------------- +/usr/local/bin/osdb-pg-ui --postgresql=no_hash_index +"osdb" +"Invoked: /usr/local/bin/osdb-pg-ui --postgresql=no_hash_index" + + create_tables() 0.78 seconds return value = 0 + load() 1.02 seconds return value = 0 + create_idx_uniques_key_bt() 0.64 seconds return value = 0 + create_idx_updates_key_bt() 0.61 seconds return value = 0 + create_idx_hundred_key_bt() 0.61 seconds return value = 0 + create_idx_tenpct_key_bt() 0.62 seconds return value = 0 + create_idx_tenpct_key_code_bt() 0.45 seconds return value = 0 + create_idx_tiny_key_bt() 0.46 seconds return value = 0 + create_idx_tenpct_int_bt() 0.46 seconds return value = 0 + create_idx_tenpct_signed_bt() 0.45 seconds return value = 0 + create_idx_uniques_code_h() 0.46 seconds return value = 0 + create_idx_tenpct_double_bt() 0.46 seconds return value = 0 + create_idx_updates_decim_bt() 0.45 seconds return value = 0 + create_idx_tenpct_float_bt() 0.46 seconds return value = 0 + create_idx_updates_int_bt() 0.46 seconds return value = 0 + create_idx_tenpct_decim_bt() 0.46 seconds return value = 0 + create_idx_hundred_code_h() 0.45 seconds return value = 0 + create_idx_tenpct_name_h() 0.46 seconds return value = 0 + create_idx_updates_code_h() 0.46 seconds return value = 0 + create_idx_tenpct_code_h() 0.45 seconds return value = 0 + create_idx_updates_double_bt() 0.46 seconds return value = 0 + create_idx_hundred_foreign() 0.41 seconds return value = 0 + populateDataBase() 11.54 seconds return value = 0 + +Error in test Counting tuples at (6746)osdb.c:294: +... empty database -- empty results +perror() reports: Resource temporarily unavailable + +someone sighup'd the parent + +Any clue? + +------------------------------------------ + + +Regards +Mallah. + + + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 11:06:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 96BBED1B4F2 + for ; + Wed, 12 Nov 2003 15:06:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97969-07 + for ; + Wed, 12 Nov 2003 11:06:03 -0400 (AST) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id 79A76D1B51C + for ; + Wed, 12 Nov 2003 11:05:58 -0400 (AST) +Received: (qmail 104646 invoked from network); 12 Nov 2003 15:05:56 -0000 +Received: from m161p002.dipool.highway.telekom.at (HELO cantor) ([62.46.10.2]) + (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 12 Nov 2003 15:05:56 -0000 +From: Manfred Koizar +To: +Cc: "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 16:04:48 +0100 +Message-ID: <03i4rv8cl6bgvr8r2c77ert3nfs0glfib8@email.aon.at> +References: +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/63 +X-Sequence-Number: 4623 + +On Wed, 12 Nov 2003 08:34:50 -0500, "Nick Fankhauser" + wrote: +> -> Index Scan using +>actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) + ^^^^^^ +>(actual time=37.62..677.44 rows=3501 loops=1) + ^^^^^^^^^ +> Index Cond: +>((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +>(actor_full_name_uppercase < 'SANDERT'::character varying)) +> Filter: +>(actor_full_name_uppercase ~~ 'SANDERS%'::text) + +Nick, can you find out why this row count estimation is so far off? + +\x +SELECT * FROM pg_stats + WHERE tablename='actor' AND attname='actor_full_name_uppercase'; + +BTW, there seem to be missing cases: +> -> Nested Loop (cost=0.00..2214.66 rows=2 width=115) +> (actual time=59.05..119929.71 rows=5879 loops=1) + ^^^^ +> -> Nested Loop (cost=0.00..2205.26 rows=3 width=76) +> (actual time=51.46..66089.04 rows=5882 loops=1) + ^^^^ + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Tue Nov 11 11:05:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AB73D1B540 + for ; + Tue, 11 Nov 2003 15:05:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59889-03 + for ; + Tue, 11 Nov 2003 11:04:45 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id D5230D1B535 + for ; + Tue, 11 Nov 2003 11:04:40 -0400 (AST) +Received: (qmail 3778 invoked from network); 11 Nov 2003 15:05:55 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 11 Nov 2003 15:05:55 -0000 +Message-ID: <3FB24C15.1020907@trade-india.com> +Date: Wed, 12 Nov 2003 20:34:53 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: Suggestions for benchmarking 7.4RC2 against 7.3 +References: <3FB247FE.4080808@trade-india.com> +In-Reply-To: <3FB247FE.4080808@trade-india.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/39 +X-Sequence-Number: 4599 + + + +the error mentioned in first email has been overcome +by running osdb on the same machine hosting the DB server. + +regds +mallah. + +Rajesh Kumar Mallah wrote: + +> +> Hi, +> +> I plan to put 7.4-RC2 in our production servers in next few hours. +> +> Since the hardware config & the performance related GUCs parameter +> are going to remain the same i am interested in seeing the performance +> improvements in 7.4 as compared 7.3 . +> +> For this i plan to use the OSDB 0.14 and compare the results for both +> the +> cases. +> +> Does any one has suggestions for comparing 7.4 against 7.3 ? +> Since i am using OSDB for second time only any tips/guidance +> on usage of that is also appreciated. +> +> +> +> H/W config: +> +> CPU: 4 X Intel(R) Xeon(TM) CPU 2.00GHz +> MEM : 2 GB +> I/O config : PGDATA on 10000 RPM Ultra160 scsi , pg_xlog on a similar +> seperate SCSI +> +> GUC: +> shared_buffers = 10000 +> max_fsm_relations = 5000 +> max_fsm_pages = 55099264 +> sort_mem = 16384 +> vacuum_mem = 8192 +> +> All other performance related parameter have default +> value eg: +> +> #effective_cache_size = 1000 # typically 8KB each +> #random_page_cost = 4 # units are one sequential page fetch +> cost +> #cpu_tuple_cost = 0.01 # (same) +> #cpu_index_tuple_cost = 0.001 # (same) +> #cpu_operator_cost = 0.0025 # (same) +> +> +> +> BTW i get following error at the moment: +> ----------------------------------------- +> /usr/local/bin/osdb-pg-ui --postgresql=no_hash_index +> "osdb" +> "Invoked: /usr/local/bin/osdb-pg-ui --postgresql=no_hash_index" +> +> create_tables() 0.78 seconds return value = 0 +> load() 1.02 seconds return value = 0 +> create_idx_uniques_key_bt() 0.64 seconds return value = 0 +> create_idx_updates_key_bt() 0.61 seconds return value = 0 +> create_idx_hundred_key_bt() 0.61 seconds return value = 0 +> create_idx_tenpct_key_bt() 0.62 seconds return value = 0 +> create_idx_tenpct_key_code_bt() 0.45 seconds return value = 0 +> create_idx_tiny_key_bt() 0.46 seconds return value = 0 +> create_idx_tenpct_int_bt() 0.46 seconds return value = 0 +> create_idx_tenpct_signed_bt() 0.45 seconds return value = 0 +> create_idx_uniques_code_h() 0.46 seconds return value = 0 +> create_idx_tenpct_double_bt() 0.46 seconds return value = 0 +> create_idx_updates_decim_bt() 0.45 seconds return value = 0 +> create_idx_tenpct_float_bt() 0.46 seconds return value = 0 +> create_idx_updates_int_bt() 0.46 seconds return value = 0 +> create_idx_tenpct_decim_bt() 0.46 seconds return value = 0 +> create_idx_hundred_code_h() 0.45 seconds return value = 0 +> create_idx_tenpct_name_h() 0.46 seconds return value = 0 +> create_idx_updates_code_h() 0.46 seconds return value = 0 +> create_idx_tenpct_code_h() 0.45 seconds return value = 0 +> create_idx_updates_double_bt() 0.46 seconds return value = 0 +> create_idx_hundred_foreign() 0.41 seconds return value = 0 +> populateDataBase() 11.54 seconds return value = 0 +> +> Error in test Counting tuples at (6746)osdb.c:294: +> ... empty database -- empty results +> perror() reports: Resource temporarily unavailable +> +> someone sighup'd the parent +> +> Any clue? +> +> ------------------------------------------ +> +> +> Regards +> Mallah. +> +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 11:44:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 27205D1B4FE + for ; + Wed, 12 Nov 2003 15:44:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08763-08 + for ; + Wed, 12 Nov 2003 11:43:45 -0400 (AST) +Received: from spirit.aldeiadigital.com.br + (iplus-fac-225-213-137.xdsl-fixo.ctbcnetsuper.com.br + [200.225.213.137]) + by svr1.postgresql.org (Postfix) with ESMTP id 7574ED1B537 + for ; + Wed, 12 Nov 2003 11:43:35 -0400 (AST) +Received: from webmail.ad2.com.br (localhost.localdomain [127.0.0.1]) + by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id + hACFf3715458 + for ; Wed, 12 Nov 2003 13:41:03 -0200 +Received: from 192.168.1.120 (SquirrelMail authenticated user alepaes) + by webmail.ad2.com.br with HTTP; + Wed, 12 Nov 2003 13:41:03 -0200 (BRST) +Message-ID: <2834.192.168.1.120.1068651663.squirrel@webmail.ad2.com.br> +Date: Wed, 12 Nov 2003 13:41:03 -0200 (BRST) +Subject: Superior performance in PG 7.4 +From: "alexandre :: aldeia digital" +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.0 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-milter (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/64 +X-Sequence-Number: 4624 + +Hi, + +I am trying the PG 7.4 RC1 and RC2 and I see a superb performance +improvement compared with 7.3.... + +Explaining the querys, I see a change of planner that, in my case, +prefer Nested Loops in 7.4 opposite to Hash or Merge Join in 7.3. + +To test, I disable Hash and Merge Joins in 7.3 and performance +have been very improved using nested loops... + +Both systems are identical in configurations, properly vacuuned and +analyzed before tests. + +Something can be wrong with my tests ? [ I desire that not :) ] + +Alexandre + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 12:10:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C137D1B553 + for ; + Wed, 12 Nov 2003 16:10:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11057-08 + for ; + Wed, 12 Nov 2003 12:09:30 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 86641D1B4EB + for ; + Wed, 12 Nov 2003 12:09:26 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hACG87NK009343; + Wed, 12 Nov 2003 09:08:08 -0700 (MST) +Date: Wed, 12 Nov 2003 08:53:56 -0700 (MST) +From: "scott.marlowe" +To: Chris Field +Cc: Ron Johnson , + PgSQL Performance ML +Subject: Re: Value of Quad vs. Dual Processor machine +In-Reply-To: <001401c3a8c2$8c8fec30$040210ac@win2000> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/67 +X-Sequence-Number: 4627 + +As another post pointed out, you need to set cflags to get optimization +under Solaris on that flavor of Postgresql. + +Also, Postgresql tends to get its best performance from the free unixes, +Linux and BSD. those are available for Sun Sparcs, but postgresql in 64 +bit mode on those boxes is still a bit cutting edge. + +It might be worth a try to set up the sun to dual boot to either BSD or +Linux and test Postgresql under that environment to see how it works and +compare it to Sun after you've set the cflags and recompiled. + +On Tue, 11 Nov 2003, Chris Field wrote: + +> we are looking at Xeon, We are currently running it on a quad sun v880 +> compiled to be 64bit and have been getting dreadful performance. I don't +> think we really have much to gain from going 64bit. +> +> +> ----- Original Message ----- +> From: "Ron Johnson" +> To: "PgSQL Performance ML" +> Sent: Tuesday, November 11, 2003 8:24 PM +> Subject: Re: [PERFORM] Value of Quad vs. Dual Processor machine +> +> +> > On Tue, 2003-11-11 at 17:32, Chris Field wrote: +> > > We are getting ready to spec out a new machine and are wondering about +> > > the wisdom of buying a quad versus a dual processor machine. Seing as +> > > how postgres in not a threaded application, and this server will only be +> > > used for log/transaction analysis (it will only ever have a few large +> > > queries running). Is there any performance to be gained, and if so is +> > > it worth the large cost? Any thoughts/experience are much +> > > appreciated... +> > +> > Xeon or Opteron? The faster Opterons *really* blaze, especially +> > in 64-bit mode. As others have said, though, RAM and I/O are most +> > important. +> > +> > -- +> > ----------------------------------------------------------------- +> > Ron Johnson, Jr. ron.l.johnson@cox.net +> > Jefferson, LA USA +> > +> > "As I like to joke, I may have invented it, but Microsoft made it +> > popular" +> > David Bradley, regarding Ctrl-Alt-Del +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 5: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faqs/FAQ.html +> > +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> +> + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 11:56:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1D67D1B4ED + for ; + Wed, 12 Nov 2003 15:56:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11948-01 + for ; + Wed, 12 Nov 2003 11:56:02 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B67FD1B521 + for ; + Wed, 12 Nov 2003 11:55:58 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hACFtx5f015013; Wed, 12 Nov 2003 10:56:01 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 10:55:48 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <03i4rv8cl6bgvr8r2c77ert3nfs0glfib8@email.aon.at> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=IN_REP_TO, + MSGID_GOOD_EXCHANGE, QUOTED_EMAIL_TEXT, UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200311/65 +X-Sequence-Number: 4625 + + + +>(actual time=37.62..677.44 rows=3501 loops=1) + ^^^^^^^^^ + +> Nick, can you find out why this row count estimation is so far off? + +It's actually correct: + +prod1=# select count(actor_id) from actor where actor_full_name_uppercase +like 'SANDERS%'; + count +------- + 3501 +(1 row) + +Of course, I merely chose "SANDERS" arbitrarily as a name that falls +somewhere near the middle of the frequency range for names. SMITH or JONES +would represent a worst-case, and something like KOIZAR would probably be +unique. + + +Here are the stats: + +prod1=# SELECT * FROM pg_stats +prod1-# WHERE tablename='actor' AND attname='actor_full_name_uppercase'; +-[ RECORD +1 ]-----+------------------------------------------------------------------- +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +------------------------------------------------------------- +schemaname | public +tablename | actor +attname | actor_full_name_uppercase +null_frac | 0.000333333 +avg_width | 21 +n_distinct | 24215 +most_common_vals | {"STATE OF INDIANA","INDIANA DEPARTMENT OF +REVENUE","BARTH CONS SCHOOL CORP","HOWARD COUNTY CLERK","ADVANCED RECOVERY +SERVICES","STATE OF INDIANA-DEPT OF REVENUE","ALLIED COLLECTION SERVICE +INC","CREDIT BUREAU OF LAPORTE","MIDWEST COLLECTION SVC INC","NCO FINANCIAL +SYSTEMS INC"} +most_common_freqs | +{0.0153333,0.0143333,0.00433333,0.00433333,0.004,0.00366667,0.00333333,0.003 +33333,0.00266667,0.00266667} +histogram_bounds | {"(POE) ESTELLE, DENISE","BRIEN, LIISI","COTTRELL, +CAROL","FAMILY RENTALS","HAYNES, TAMIKA","KESSLER, VICTORIA","MEFFORD, +VERNON L","PHILLIPS, GERALD L","SHELTON, ANTOINETTE","TRICARICO, MELISSA +SUE","ZUEHLKE, THOMAS L"} +correlation | -0.00147395 + + +I think this means that the average is 357 per actor. As you can see, the +range of assignments varies from people with a single parking ticket to +"State of Indiana", which is party to many thousands of cases. + + +> BTW, there seem to be missing cases: +> > -> Nested Loop (cost=0.00..2214.66 rows=2 width=115) +> > (actual time=59.05..119929.71 rows=5879 loops=1) +> ^^^^ +> > -> Nested Loop (cost=0.00..2205.26 rows=3 width=76) +> > (actual time=51.46..66089.04 rows=5882 loops=1) + +This is expected- We actually aggregate data from many county court +databases, with varying levels of data "cleanliness". + +Regards, + -Nick + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 12:06:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3BBAD1B534 + for ; + Wed, 12 Nov 2003 16:05:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10607-09 + for ; + Wed, 12 Nov 2003 12:05:28 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 5875DD1B4EB + for ; + Wed, 12 Nov 2003 12:05:27 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hACG5M5f015295; Wed, 12 Nov 2003 11:05:23 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 11:05:10 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <03i4rv8cl6bgvr8r2c77ert3nfs0glfib8@email.aon.at> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/66 +X-Sequence-Number: 4626 + + +> >actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) +> ^^^^^^ +> >(actual time=37.62..677.44 rows=3501 loops=1) +> ^^^^^^^^^ +> Nick, can you find out why this row count estimation is so far off? +^^^^^^^^^ + +Oops- I read this backward- I see what you mean now. That's a good question. +I'm not sure what part of the stats this estimate might be pulled from. The +average is 357, but the most common frequency may be around 1. + +-Nick + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 12:11:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 16359D1B560; Wed, 12 Nov 2003 16:11:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11295-10; Wed, 12 Nov 2003 12:11:02 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP + id 424CAD1B550; Wed, 12 Nov 2003 12:11:02 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 282C5372DC; Wed, 12 Nov 2003 12:08:56 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP + id 274CC372DA; Wed, 12 Nov 2003 12:08:56 -0400 (AST) +Date: Wed, 12 Nov 2003 12:08:56 -0400 (AST) +From: "Marc G. Fournier" +X-X-Sender: scrappy@ganymede.hub.org +To: Greg Stark +Cc: "Marc G. Fournier" , + Dennis Bjorklund , pgsql-performance@postgresql.org +Subject: Re: *very* slow query to summarize data for a month ... +In-Reply-To: <87oevii15f.fsf@stark.dyndns.tv> +Message-ID: <20031112120814.H56037@ganymede.hub.org> +References: + <20031111134925.L56037@ganymede.hub.org> + <87oevii15f.fsf@stark.dyndns.tv> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/69 +X-Sequence-Number: 4629 + + + +On Wed, 12 Nov 2003, Greg Stark wrote: + +> +> "Marc G. Fournier" writes: +> +> > Just as a side note, just doing a straight scan for the records, with no +> > SUM()/GROUP BY involved, with the month_trunc() index is still >8k msec: +> +> One of the other advantages of these aggregate tables was that we could +> purge the old data much sooner with much less resistance from the +> business. Since the reports were all still available and a lot of ad-hoc +> queries could still be done without the raw data anyways. + +Actually, what I've done is do this at the 'load stage' ... but same +concept ... + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 12:11:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F514D1B55D + for ; + Wed, 12 Nov 2003 16:11:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11269-09 + for ; + Wed, 12 Nov 2003 12:10:44 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 27CA6D1B50D + for ; + Wed, 12 Nov 2003 12:10:44 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hACGAY19009084; + Wed, 12 Nov 2003 11:10:35 -0500 (EST) +To: nickf@ontko.com +Cc: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +In-reply-to: +References: +Comments: In-reply-to "Nick Fankhauser" + message dated "Wed, 12 Nov 2003 10:55:48 -0500" +Date: Wed, 12 Nov 2003 11:10:34 -0500 +Message-ID: <9083.1068653434@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/68 +X-Sequence-Number: 4628 + +"Nick Fankhauser" writes: +>> Nick, can you find out why this row count estimation is so far off? + +> It's actually correct: + +Sure, the 3501 was the "actual". The estimate was 1 row, which was +pretty far off :-( + +> Here are the stats: + +It looks like you are running with the default statistics target (10). +Try boosting it to 100 or even more for this column (see ALTER TABLE +SET STATISTICS, then re-ANALYZE) and see if the estimate gets better. +I think the major problem is likely here: +> n_distinct | 24215 +which is no doubt much too small (do you have an idea of the number +of distinct actor_full_name_uppercase values?) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Nov 12 12:53:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 382B0D1B50C + for ; + Wed, 12 Nov 2003 16:53:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22780-01 + for ; + Wed, 12 Nov 2003 12:53:18 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id CFB6DD1B50B + for ; + Wed, 12 Nov 2003 12:53:17 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hACGr25f016224; Wed, 12 Nov 2003 11:53:04 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Tom Lane" +Cc: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 11:52:51 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <9083.1068653434@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/70 +X-Sequence-Number: 4630 + + +> It looks like you are running with the default statistics target (10). +> Try boosting it to 100 or even more for this column (see ALTER TABLE +> SET STATISTICS, then re-ANALYZE) and see if the estimate gets better. + + +Here are the results & a few more clues: + +prod1=# alter table actor alter column actor_full_name_uppercase set +statistics 1000; +ALTER TABLE +prod1=# analyze actor; +ANALYZE +prod1=# select count(distinct actor_full_name_uppercase) from actor; + count +--------- + 1453371 +(1 row) + +prod1=# select count(actor_id) from actor; + count +--------- + 3386359 +(1 row) + +This indicates to me that 1 isn't too shabby as an estimate if the whole +name is specified, but I'm not sure how this gets altered in the case of a +"LIKE" + + +prod1=# \x +Expanded display is on. +prod1=# SELECT * FROM pg_stats +prod1-# WHERE tablename='actor' AND attname='actor_full_name_uppercase'; + +
+ +schemaname | public +tablename | actor +attname | actor_full_name_uppercase +null_frac | 0.000586667 +avg_width | 21 +n_distinct | -0.14701 + + + +correlation | -0.00211291 + + +Question: What does it mean when n_distinct is negative? + +New results of explain analyze: + + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +-------------------------------------------------- + Limit (cost=252683.61..252683.68 rows=28 width=116) (actual +time=169377.32..169378.39 rows=1000 loops=1) + -> Sort (cost=252683.61..252683.68 rows=29 width=116) (actual +time=169377.31..169377.69 rows=1001 loops=1) + Sort Key: max((actor.actor_full_name)::text), +count(case_data.case_id) + -> Aggregate (cost=252678.57..252682.91 rows=29 width=116) +(actual time=169305.79..169354.50 rows=3456 loops=1) + -> Group (cost=252678.57..252680.01 rows=289 width=116) +(actual time=169305.76..169330.00 rows=5879 loops=1) + -> Sort (cost=252678.57..252679.29 rows=289 +width=116) (actual time=169305.75..169308.15 rows=5879 loops=1) + Sort Key: actor.actor_id + -> Nested Loop (cost=0.00..252666.74 rows=289 +width=116) (actual time=89.27..169273.51 rows=5879 loops=1) + -> Nested Loop (cost=0.00..251608.11 +rows=289 width=77) (actual time=57.73..92753.49 rows=5882 loops=1) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..456.88 rows=113 width=42) +(actual time=32.80..3197.28 rows=3501 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Index Scan using +actor_case_assignment_actor_id on actor_case_assignment (cost=0.00..2181.29 +rows=2616 width=35) (actual time=22.26..25.57 rows=2 loops=3501) + Index Cond: ("outer".actor_id = +actor_case_assignment.actor_id) + -> Index Scan using case_data_case_id on +case_data (cost=0.00..3.65 rows=1 width=39) (actual time=13.00..13.00 +rows=1 loops=5882) + Index Cond: (case_data.case_id = +"outer".case_id) + Total runtime: 169381.38 msec +(17 rows) + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 13:11:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C793D1B502 + for ; + Wed, 12 Nov 2003 17:11:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22209-06 + for ; + Wed, 12 Nov 2003 13:10:39 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F85CD1B4F2 + for ; + Wed, 12 Nov 2003 13:10:38 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hACHAa19010145; + Wed, 12 Nov 2003 12:10:36 -0500 (EST) +To: nickf@ontko.com +Cc: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +In-reply-to: +References: +Comments: In-reply-to "Nick Fankhauser" + message dated "Wed, 12 Nov 2003 11:52:51 -0500" +Date: Wed, 12 Nov 2003 12:10:35 -0500 +Message-ID: <10144.1068657035@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/71 +X-Sequence-Number: 4631 + +"Nick Fankhauser" writes: +> This indicates to me that 1 isn't too shabby as an estimate if the whole +> name is specified, but I'm not sure how this gets altered in the case of a +> "LIKE" + +For a pattern like "SANDERS%", the estimate is basically a range estimate +for this condition: + +> ((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +> (actor_full_name_uppercase < 'SANDERT'::character varying)) + +> n_distinct | -0.14701 + +> Question: What does it mean when n_distinct is negative? + +It means that the number of distinct values is estimated as a fraction +of the table size, rather than an absolute number. In this case 14.7% +of the table size, which is a bit off compared to the correct value +of 43% (1453371/3386359), but at least it's of the right order of +magnitude now ... + +> -> Index Scan using +> actor_full_name_uppercase on actor (cost=0.00..456.88 rows=113 width=42) +> (actual time=32.80..3197.28 rows=3501 loops=1) + +Hmm. Better, but not enough better to force a different plan choice. + +You might have to resort to brute force, like "set enable_nestloop=false". +Just out of curiosity, what do you get if you do that? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Nov 12 13:38:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6FF2D1B4FA + for ; + Wed, 12 Nov 2003 17:38:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23157-08 + for ; + Wed, 12 Nov 2003 13:38:12 -0400 (AST) +Received: from node-4024d1a2.mdw.onnet.us.uu.net (nsit-s229-45.uchicago.edu + [128.135.229.45]) + by svr1.postgresql.org (Postfix) with ESMTP id BF669D1B50C + for ; + Wed, 12 Nov 2003 13:38:10 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by node-4024d1a2.mdw.onnet.us.uu.net (Postfix) with ESMTP id 1E7D337D0A + for ; + Wed, 12 Nov 2003 11:34:42 -0600 (CST) +Subject: performance optimzations +From: Suchandra Thapa +To: pgsql-performance@postgresql.org +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-P64FTYF3MjJ2djem0LYO" +Organization: +Message-Id: <1068658430.1071.42.camel@hepcat> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 12 Nov 2003 11:34:41 -0600 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/72 +X-Sequence-Number: 4632 + +--=-P64FTYF3MjJ2djem0LYO +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +I'm moving a webmail service over to use a postgresql database for +storage and wanted to get any tips for optimizing performance. The +machine will be a multiprocessor (either 2 or 4 cpu ) system with a raid +array. What layout should be used? I was thinking using about using a +raid 1+0 array to hold the database but since I can use different array +types, would it be better to use 1+0 for the wal logs and a raid 5 for +the database? + +The database gets fairly heavy activity (the system handles about 500MB +of incoming and about 750MB of outgoing emails daily). I have a fairly +free rein in regards to the system's layout as well as how the +applications will interact with the database since I'm writing the +code.=20=20 + + +--=20 +Suchandra Thapa + +--=-P64FTYF3MjJ2djem0LYO +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQA/sm7+6nShCjt5AZIRAh79AKCmQ3R4/p+myiLn8aRSxSDSTKdBzwCfaSgK +gAxvE8cnf1azIdkoECAsO7s= +=gNB3 +-----END PGP SIGNATURE----- + +--=-P64FTYF3MjJ2djem0LYO-- + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 14:23:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 24D47D1B565 + for ; + Wed, 12 Nov 2003 18:23:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39874-06 + for ; + Wed, 12 Nov 2003 14:23:00 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id D734BD1B561 + for ; + Wed, 12 Nov 2003 14:22:58 -0400 (AST) +Received: (qmail 9143 invoked from network); 12 Nov 2003 18:22:58 -0000 +Received: from unknown (HELO ?10.0.2.5?) (216.208.117.7) + by 205.178.180.9 with SMTP; 12 Nov 2003 18:22:58 -0000 +Subject: Re: performance optimzations +From: Rod Taylor +To: Suchandra Thapa +Cc: Postgresql Performance +In-Reply-To: <1068658430.1071.42.camel@hepcat> +References: <1068658430.1071.42.camel@hepcat> +Content-Type: text/plain +Message-Id: <1068661380.30452.17.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 12 Nov 2003 13:23:01 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/73 +X-Sequence-Number: 4633 + +On Wed, 2003-11-12 at 12:34, Suchandra Thapa wrote: +> I'm moving a webmail service over to use a postgresql database for +> storage and wanted to get any tips for optimizing performance. The +> machine will be a multiprocessor (either 2 or 4 cpu ) system with a raid +> array. What layout should be used? I was thinking using about using a +> raid 1+0 array to hold the database but since I can use different array +> types, would it be better to use 1+0 for the wal logs and a raid 5 for +> the database? + +How much in total storage? If you have (or will have) > ~6 disks, go +for RAID 5 otherwise 10 is probably appropriate. + +> The database gets fairly heavy activity (the system handles about 500MB +> of incoming and about 750MB of outgoing emails daily). I have a fairly +> free rein in regards to the system's layout as well as how the +> applications will interact with the database since I'm writing the +> code. + +These are archived permanently -- ~450GB of annual data? Or is the data +removed upon delivery? + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 14:28:37 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 47BA8D1B535 + for ; + Wed, 12 Nov 2003 18:28:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40876-03 + for ; + Wed, 12 Nov 2003 14:28:07 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 40BCFD1B522 + for ; + Wed, 12 Nov 2003 14:28:06 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hACIS45f017833; Wed, 12 Nov 2003 13:28:05 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Tom Lane" +Cc: "Manfred Koizar" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 13:27:53 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <10144.1068657035@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/74 +X-Sequence-Number: 4634 + + +> You might have to resort to brute force, like "set enable_nestloop=false". +> Just out of curiosity, what do you get if you do that? + +I get a different plan, but similar execution time: + + + Limit (cost=323437.13..323437.13 rows=1 width=115) (actual +time=170921.89..170922.95 rows=1000 loops=1) + -> Sort (cost=323437.13..323437.13 rows=1 width=115) (actual +time=170921.89..170922.26 rows=1001 loops=1) + Sort Key: max((actor.actor_full_name)::text), +count(case_data.case_id) + -> Aggregate (cost=323437.08..323437.12 rows=1 width=115) (actual +time=170849.94..170898.06 rows=3457 loops=1) + -> Group (cost=323437.08..323437.09 rows=3 width=115) +(actual time=170849.90..170873.60 rows=5880 loops=1) + -> Sort (cost=323437.08..323437.08 rows=3 width=115) +(actual time=170847.97..170850.21 rows=5880 loops=1) + Sort Key: actor.actor_id + -> Hash Join (cost=253333.29..323437.06 rows=3 +width=115) (actual time=122873.80..170814.27 rows=5880 loops=1) + Hash Cond: ("outer".case_id = +"inner".case_id) + -> Seq Scan on case_data +(cost=0.00..60368.16 rows=1947116 width=39) (actual time=12.95..43542.25 +rows=1947377 loops=1) + -> Hash (cost=253333.28..253333.28 rows=3 +width=76) (actual time=122844.40..122844.40 rows=0 loops=1) + -> Hash Join (cost=6.02..253333.28 +rows=3 width=76) (actual time=24992.70..122810.32 rows=5883 loops=1) + Hash Cond: ("outer".actor_id = +"inner".actor_id) + -> Seq Scan on +actor_case_assignment (cost=0.00..209980.49 rows=8669349 width=34) (actual +time=9.13..85504.05 rows=8670467 loops=1) + -> Hash (cost=6.01..6.01 +rows=1 width=42) (actual time=24926.56..24926.56 rows=0 loops=1) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) +(actual time=51.67..24900.53 rows=3502 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + Total runtime: 170925.93 msec +(19 rows) + + +-Nick + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 14:55:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EF9AD1B53F + for ; + Wed, 12 Nov 2003 18:55:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40919-09 + for ; + Wed, 12 Nov 2003 14:55:13 -0400 (AST) +Received: from node-4024d1a2.mdw.onnet.us.uu.net (nsit-s229-45.uchicago.edu + [128.135.229.45]) + by svr1.postgresql.org (Postfix) with ESMTP id C6ABDD1B502 + for ; + Wed, 12 Nov 2003 14:55:04 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by node-4024d1a2.mdw.onnet.us.uu.net (Postfix) with ESMTP + id AC60D37D0A; Wed, 12 Nov 2003 12:51:10 -0600 (CST) +Subject: Re: performance optimzations +From: Suchandra Thapa +To: Rod Taylor +Cc: Postgresql Performance +In-Reply-To: <1068661380.30452.17.camel@jester> +References: <1068658430.1071.42.camel@hepcat> + <1068661380.30452.17.camel@jester> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-RPIt6DKUfon9QoHE8LNb" +Organization: +Message-Id: <1068663070.5193.21.camel@hepcat> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 12 Nov 2003 12:51:10 -0600 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/75 +X-Sequence-Number: 4635 + +--=-RPIt6DKUfon9QoHE8LNb +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Wed, 2003-11-12 at 12:23, Rod Taylor wrote: +> On Wed, 2003-11-12 at 12:34, Suchandra Thapa wrote: +> > I'm moving a webmail service over to use a postgresql database for +> > storage and wanted to get any tips for optimizing performance. The +> > machine will be a multiprocessor (either 2 or 4 cpu ) system with a raid +> > array. What layout should be used? I was thinking using about using a +> > raid 1+0 array to hold the database but since I can use different array +> > types, would it be better to use 1+0 for the wal logs and a raid 5 for +> > the database? +>=20 +> How much in total storage? If you have (or will have) > ~6 disks, go +> for RAID 5 otherwise 10 is probably appropriate. + +I'm not sure but I believe there are about 6-8 10K scsi drives on the +system. There is quite a bit of storage to spare currently so I think=20 + +> > The database gets fairly heavy activity (the system handles about 500MB +> > of incoming and about 750MB of outgoing emails daily). I have a fairly +> > free rein in regards to the system's layout as well as how the +> > applications will interact with the database since I'm writing the +> > code. +>=20 +> These are archived permanently -- ~450GB of annual data? Or is the data +> removed upon delivery? + +No, it's more like hotmail. Some users may keep mail for a longer term +but a lot of the mail probably gets deleted fairly quickly. The +database load will be mixed with a insertions due to deliveries, queries +by the webmail system, and deletions from pop and webmail. + +--=20 +Suchandra Thapa + +--=-RPIt6DKUfon9QoHE8LNb +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQA/soEe6nShCjt5AZIRAt21AKCFSDhmJ7O/Q/vm1UM3+b9PKM4XggCeOI7K +naNwR0tmY5gOldNONquIAzc= +=WvjL +-----END PGP SIGNATURE----- + +--=-RPIt6DKUfon9QoHE8LNb-- + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 16:17:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8916D1B55F + for ; + Tue, 11 Nov 2003 20:17:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21535-02 + for ; + Tue, 11 Nov 2003 16:17:07 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 46CC9D1B4EB + for ; + Tue, 11 Nov 2003 16:17:05 -0400 (AST) +Received: (qmail 581 invoked from network); 11 Nov 2003 20:18:01 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 11 Nov 2003 20:18:01 -0000 +Message-ID: <3FB29532.9060107@trade-india.com> +Date: Thu, 13 Nov 2003 01:46:50 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: Suggestions for benchmarking 7.4RC2 against 7.3 +References: <3FB247FE.4080808@trade-india.com> + <3FB24C15.1020907@trade-india.com> + + <200311111025.28806.josh@agliodbs.com> +In-Reply-To: <200311111025.28806.josh@agliodbs.com> +Content-Type: multipart/alternative; + boundary="------------070000020205060807000709" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/47 +X-Sequence-Number: 4607 + +This is a multi-part message in MIME format. +--------------070000020205060807000709 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Josh Berkus wrote: + +>Rajesh, Chris, +> +> +> +>>I got the osdb benchmark running last week, and had to separate client +>>from server. I had to jump through a fair number of hoops including +>>copying data files over to the server. The benchmark software needs a +>>bit more work... +>> +>> +> +>What about the OSDL's TPC-derivative benchmarks? That's a much more +>respected database test, and probably less buggy than OSDB. +> +> +> +Hmm... really sorry! my +pg_dump | psql is almost finishing in next 20 mins. + +creating indexes at the moment :) + +Really sorry can't rollback and delay anymore becoz my +website is *unavailable* for past 30 mins. + +I ran OSDB .15 version and pg_bench . + + +Regds +Mallah. + + + + + +--------------070000020205060807000709 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Josh Berkus wrote:
+
+
Rajesh, Chris,
+
+  
+
+
I got the osdb benchmark running last week, and had to separate client
+from server.  I had to jump through a fair number of hoops including
+copying data files over to the server.  The benchmark software needs a
+bit more work...
+    
+
+

+What about the OSDL's TPC-derivative benchmarks?   That's a much more 
+respected database test, and probably less buggy than OSDB.
+
+  
+
+Hmm... really sorry! my
+pg_dump | psql is almost finishing in next 20 mins.
+
+creating indexes at the moment :)
+
+Really sorry can't rollback and delay anymore becoz my
+website is *unavailable* for past 30 mins.
+
+I ran OSDB .15 version  and pg_bench .
+
+
+Regds
+Mallah.
+
+
+
+
+ + + +--------------070000020205060807000709-- + + +From pgsql-performance-owner@postgresql.org Tue Nov 11 17:25:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BA74BD1B531 + for ; + Tue, 11 Nov 2003 21:25:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32185-02 + for ; + Tue, 11 Nov 2003 17:25:09 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 0AFB0D1B4FE + for ; + Tue, 11 Nov 2003 17:25:07 -0400 (AST) +Received: (qmail 4307 invoked from network); 11 Nov 2003 21:26:18 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 11 Nov 2003 21:26:18 -0000 +Message-ID: <3FB2A540.2000808@trade-india.com> +Date: Thu, 13 Nov 2003 02:55:20 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Suggestions for benchmarking 7.4RC2 against 7.3 +References: <3FB247FE.4080808@trade-india.com> + <3FB24C15.1020907@trade-india.com> + +In-Reply-To: +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/48 +X-Sequence-Number: 4608 + + + + + + + + +
+
+RC2 is running in production without any apparent problems
+till now.  Well its difficult to say at the moment how much speed
+gain is there unless the heavy duty batch SQL scripts are run by
+cron.
+
+Count(*) and group by on large tables are significantly (5x) faster
+and better error reporting has made it easier to spot the faulty data.
+eg in fkey violation.
+
+Will post the OSDB .15 versions' results on 7.3 & 7.4 soon.
+
+Regds
+Mallah.
+
+Christopher Browne wrote:
+
+
After a long battle with technology,mallah@trade-india.com (Rajesh Kumar Mallah), an earthling, wrote:
+  
+
+
the error mentioned in first email has been overcome
+by running osdb on the same machine hosting the DB server.
+    
+
+

+Yes, it seems unrealistic to try to run the "client" on a separate
+host from the database.  
+
+I got the osdb benchmark running last week, and had to separate client
+from server.  I had to jump through a fair number of hoops including
+copying data files over to the server.  The benchmark software needs a
+bit more work...
+  
+
+
+ + + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 20:23:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B1B05D1B50B + for ; + Wed, 12 Nov 2003 22:28:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78209-10 + for ; + Wed, 12 Nov 2003 18:27:43 -0400 (AST) +Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) + by svr1.postgresql.org (Postfix) with SMTP id 2DD90D1B4EB + for ; + Wed, 12 Nov 2003 18:27:24 -0400 (AST) +Received: (qmail 453032 invoked from network); 12 Nov 2003 22:27:01 -0000 +Received: from m170p002.dipool.highway.telekom.at (HELO cantor) + ([62.46.11.34]) (envelope-sender ) + by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 12 Nov 2003 22:27:01 -0000 +From: Manfred Koizar +To: +Cc: "Tom Lane" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Wed, 12 Nov 2003 23:25:54 +0100 +Message-ID: +References: <10144.1068657035@sss.pgh.pa.us> + +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/78 +X-Sequence-Number: 4638 + +On Wed, 12 Nov 2003 13:27:53 -0500, "Nick Fankhauser" + wrote: +> +>> You might have to resort to brute force, like "set enable_nestloop=false". + +> -> Seq Scan on +>actor_case_assignment (cost=0.00..209980.49 rows=8669349 width=34) (actual +>time=9.13..85504.05 rows=8670467 loops=1) + +Does actor_case_assignment contain more columns than just the two ids? +If yes, do these additional fields account for ca. 70 bytes per tuple? +If not, try + VACUUM FULL ANALYSE actor_case_assignment; + +> -> Index Scan using +>actor_full_name_uppercase on actor (cost=0.00..6.01 rows=1 width=42) +>(actual time=51.67..24900.53 rows=3502 loops=1) + +This same index scan on actor has been much faster in your previous +postings (677ms, 3200ms), probably due to caching effects. 7ms per +tuple returned looks like a lot of disk seeks are involved. Is +clustering actor on actor_full_name_uppercase an option or would this +slow down other queries? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Wed Nov 12 20:23:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D392DD1B4ED + for ; + Wed, 12 Nov 2003 22:29:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81605-07 + for ; + Wed, 12 Nov 2003 18:29:31 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 29DCED1B50C + for ; + Wed, 12 Nov 2003 18:29:29 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id B52BF1FC7; Wed, 12 Nov 2003 17:29:30 -0500 (EST) +To: Suchandra Thapa +Cc: pgsql-performance@postgresql.org +Subject: Re: performance optimzations +From: Neil Conway +In-Reply-To: <1068658430.1071.42.camel@hepcat> (Suchandra Thapa's message of + "12 Nov 2003 11:34:41 -0600") +References: <1068658430.1071.42.camel@hepcat> +Date: Wed, 12 Nov 2003 17:29:30 -0500 +Message-ID: <87oevh9q5x.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/77 +X-Sequence-Number: 4637 + +Suchandra Thapa writes: +> I was thinking using about using a raid 1+0 array to hold the +> database but since I can use different array types, would it be +> better to use 1+0 for the wal logs and a raid 5 for the database? + +It has been recommended on this list that getting a RAID controller +with a battery-backed cache is pretty essential to getting good +performance. Search the list archives for lots more discussion about +RAID configurations. + +-Neil + + +From pgsql-performance-owner@postgresql.org Wed Nov 12 20:23:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FE74D1B557 + for ; + Thu, 13 Nov 2003 00:20:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05831-01 + for ; + Wed, 12 Nov 2003 20:19:34 -0400 (AST) +Received: from node-4024d1a2.mdw.onnet.us.uu.net (nsit-s227-189.uchicago.edu + [128.135.227.189]) + by svr1.postgresql.org (Postfix) with ESMTP id 975DBD1B553 + for ; + Wed, 12 Nov 2003 20:19:30 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by node-4024d1a2.mdw.onnet.us.uu.net (Postfix) with ESMTP + id D878E37D0A; Wed, 12 Nov 2003 18:15:58 -0600 (CST) +Subject: Re: performance optimzations +From: Suchandra Thapa +To: Neil Conway +Cc: pgsql-performance@postgresql.org +In-Reply-To: <87oevh9q5x.fsf@mailbox.samurai.com> +References: <1068658430.1071.42.camel@hepcat> + <87oevh9q5x.fsf@mailbox.samurai.com> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-nUmlQp/VCc50mmNOJhgO" +Organization: +Message-Id: <1068682558.5193.47.camel@hepcat> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 12 Nov 2003 18:15:58 -0600 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/79 +X-Sequence-Number: 4639 + +--=-nUmlQp/VCc50mmNOJhgO +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Wed, 2003-11-12 at 16:29, Neil Conway wrote: +> Suchandra Thapa writes: +> > I was thinking using about using a raid 1+0 array to hold the +> > database but since I can use different array types, would it be +> > better to use 1+0 for the wal logs and a raid 5 for the database? +>=20 +> It has been recommended on this list that getting a RAID controller +> with a battery-backed cache is pretty essential to getting good +> performance. Search the list archives for lots more discussion about +> RAID configurations. + +The server is already using a raid controller with battery backed ram +and the cache set to write back (the server is on a ups so power +failures shouldn't cause problems). I'll look at the list archives +for RAID information.=20=20 + +--=20 +Suchandra Thapa + +--=-nUmlQp/VCc50mmNOJhgO +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQA/ss0+6nShCjt5AZIRAj9GAJ9PQ3+CH11zo2zvQ3EXkD0pcE++ngCfSE8O ++TjrbFQ0jBgOZmwkLFUVEIw= +=5ZuI +-----END PGP SIGNATURE----- + +--=-nUmlQp/VCc50mmNOJhgO-- + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 00:07:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AA988D1B527 + for ; + Thu, 13 Nov 2003 04:07:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41081-06 + for ; + Thu, 13 Nov 2003 00:06:32 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E5D4D1B4FE + for ; + Thu, 13 Nov 2003 00:06:31 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAD46UoD004575 for ; + Thu, 13 Nov 2003 12:06:30 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FB303E9.20903@familyhealth.com.au> +Date: Thu, 13 Nov 2003 12:09:13 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: Query question +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/80 +X-Sequence-Number: 4640 + +Hi, + +I have coded some improvements to phpPgAdmin that I think are pretty +cool. Basicaly, once you are browsing the results of an arbitrary +SELECT query, you can still sort by columns, regardless of the +underlying ORDER BY of the SELECT. + +I do this like this: + +SELECT * FROM (arbitrary subquery) AS sub ORDER BY 1,3; + +Now, this all works fine, but I want to know if this is efficient or not. + +Does doing a select of a select cause serious performance degradation? + +Chris + + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 00:36:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 400BDD1B527 + for ; + Thu, 13 Nov 2003 04:36:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44534-05 + for ; + Thu, 13 Nov 2003 00:35:51 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 4C23DD1B535 + for ; + Thu, 13 Nov 2003 00:35:35 -0400 (AST) +Received: (qmail 27827 invoked from network); 13 Nov 2003 04:34:32 -0000 +Received: from unknown (HELO ?192.168.1.199?) (134.22.68.129) + by 205.178.180.9 with SMTP; 13 Nov 2003 04:34:32 -0000 +Subject: Re: performance optimzations +From: Rod Taylor +To: Suchandra Thapa +Cc: Postgresql Performance +In-Reply-To: <1068663070.5193.21.camel@hepcat> +References: <1068658430.1071.42.camel@hepcat> + <1068661380.30452.17.camel@jester> <1068663070.5193.21.camel@hepcat> +Content-Type: text/plain +Message-Id: <1068698132.31569.46.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 12 Nov 2003 23:35:33 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/81 +X-Sequence-Number: 4641 + +> > How much in total storage? If you have (or will have) > ~6 disks, go +> > for RAID 5 otherwise 10 is probably appropriate. +> +> I'm not sure but I believe there are about 6-8 10K scsi drives on the +> system. There is quite a bit of storage to spare currently so I think + +I see.. With 8 drives, you'll probably want to go with RAID 5. It grows +beyond that point fairly well with a decent controller card. Be sure to +have some battery backed write cache on the raid card (128MB goes a long +way). + +> > > The database gets fairly heavy activity (the system handles about 500MB +> > > of incoming and about 750MB of outgoing emails daily). I have a fairly + +> No, it's more like hotmail. Some users may keep mail for a longer term +> but a lot of the mail probably gets deleted fairly quickly. The +> database load will be mixed with a insertions due to deliveries, queries +> by the webmail system, and deletions from pop and webmail. + +You might consider having the mailserver gzip the emails prior to +injection into the database (turn off compression in PostgreSQL) and +decompress the data on the webserver for display to the client. Now you +have about 7 times the number of emails in memory. + +It's easier to toss a webserver at the problem than make the database +bigger in size. Take the savings in CPU on the DB and add it to ram. + +1200MB of compressed mail is about 200MB? Assume email descriptive +material (subject, from, etc.), account structure, indexes... so about +400MB for one days worth of information? + +You may want to consider keeping the compressed email in a separate +table than the information describing it. It would mean descriptive +information is more likely to be in RAM, where the body probably doesn't +matter as much (you view them 1 at a time, subjects tend to be listed +all at once). + +Most clients will be interested in say the last 7 days worth of data? +Great.. Start out with 4GB ram on a good Dual CPU -- Opterons seem to +work quite well -- and make sure the motherboard can hold double that in +memory for an upgrade sometime next year when you've become popular. + +I firmly believe lots of RAM is the answer to most IO issues until you +start getting into large sets of active data (>50GB). 64GB ram is fairly +cheap compared to ongoing maintenance of the 30+ drive system required +to get decent throughput. + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 01:21:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B02B0D1B4E1 + for ; + Thu, 13 Nov 2003 05:21:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54620-09 + for ; + Thu, 13 Nov 2003 01:20:52 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B6A91D1B507 + for ; + Thu, 13 Nov 2003 01:20:51 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3908779; Wed, 12 Nov 2003 21:21:35 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Christopher Kings-Lynne , + PostgreSQL Performance +Subject: Re: Query question +Date: Wed, 12 Nov 2003 21:20:28 -0800 +User-Agent: KMail/1.4.3 +References: <3FB303E9.20903@familyhealth.com.au> +In-Reply-To: <3FB303E9.20903@familyhealth.com.au> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311122120.28882.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/82 +X-Sequence-Number: 4642 + +Chris, + +> SELECT * FROM (arbitrary subquery) AS sub ORDER BY 1,3; +> +> Now, this all works fine, but I want to know if this is efficient or not. +> +> Does doing a select of a select cause serious performance degradation? + +It would be better if you could strip out the inner sort, but I can understand +why that might not be possible in all cases. + +The only thing you're adding to the query is a second SORT step, so it +shouldn't require any more time/memory than the query's first SORT did. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Nov 13 02:03:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AA9ACD1B50B + for ; + Thu, 13 Nov 2003 06:03:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66527-08 + for ; + Thu, 13 Nov 2003 02:03:04 -0400 (AST) +Received: from node-4024d1a2.mdw.onnet.us.uu.net (nsit-s227-70.uchicago.edu + [128.135.227.70]) + by svr1.postgresql.org (Postfix) with ESMTP id C2DE8D1B535 + for ; + Thu, 13 Nov 2003 02:02:46 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by node-4024d1a2.mdw.onnet.us.uu.net (Postfix) with ESMTP + id 1E96A37D7E; Wed, 12 Nov 2003 23:58:45 -0600 (CST) +Subject: Re: performance optimzations +From: Suchandra Thapa +To: Rod Taylor +Cc: Postgresql Performance +In-Reply-To: <1068698132.31569.46.camel@jester> +References: <1068658430.1071.42.camel@hepcat> + <1068661380.30452.17.camel@jester> <1068663070.5193.21.camel@hepcat> + <1068698132.31569.46.camel@jester> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-BcogzFHj1OVm6xatBeRz" +Organization: +Message-Id: <1068703124.12978.27.camel@hepcat> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 12 Nov 2003 23:58:45 -0600 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/83 +X-Sequence-Number: 4643 + +--=-BcogzFHj1OVm6xatBeRz +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Wed, 2003-11-12 at 22:35, Rod Taylor wrote: +> You may want to consider keeping the compressed email in a separate +> table than the information describing it. It would mean descriptive +> information is more likely to be in RAM, where the body probably doesn't +> matter as much (you view them 1 at a time, subjects tend to be listed +> all at once). + +Thanks for the suggestions. Splitting the load between several machines +was the original intent of moving the storage from the file system to a +database. I believe the schema I'm already using splits out the body +due to the size of some attachments. Luckily the code already gzips the +email body and abbreviates common email headers so storing compressed +emails isn't a problem.=20=20 + +> Most clients will be interested in say the last 7 days worth of data?=20 +> Great.. Start out with 4GB ram on a good Dual CPU -- Opterons seem to +> work quite well -- and make sure the motherboard can hold double that in +> memory for an upgrade sometime next year when you've become popular. + +Unfortunately, the hardware available is pretty much fixed in regards to +the system. I can play around with the raid configurations and have +some limited choice in regards to the raid controller and number of +drivers but that's about all in terms of hardware.=20=20=20=20 + +> I firmly believe lots of RAM is the answer to most IO issues until you +> start getting into large sets of active data (>50GB). 64GB ram is fairly +> cheap compared to ongoing maintenance of the 30+ drive system required +> to get decent throughput. + +The current file system holding the user and email information indicates +the current data has about 64GB (70K accounts, I'm not sure how many are +active but 50% might be good guess). This seems to be somewhat of a +steady state however. + +--=20 +Suchandra Thapa + +--=-BcogzFHj1OVm6xatBeRz +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQA/sx2U6nShCjt5AZIRAmVjAKCGAeAFlKcKMrY7sULbwNwoiy59rQCfcqki +Ui3n6yqsdei2GQCOzAQOi9o= +=q+x/ +-----END PGP SIGNATURE----- + +--=-BcogzFHj1OVm6xatBeRz-- + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 03:51:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DB48D1B502 + for ; + Thu, 13 Nov 2003 07:51:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86098-08 + for ; + Thu, 13 Nov 2003 03:50:55 -0400 (AST) +Received: from rtlocal.trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id B24A4D1B51C + for ; + Thu, 13 Nov 2003 03:50:47 -0400 (AST) +Received: (qmail 6741 invoked from network); 13 Nov 2003 08:09:08 -0000 +Received: from unknown (HELO trade-india.com) (unknown) + by unknown with SMTP; 13 Nov 2003 08:09:08 -0000 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +To: pgsql-performance@postgresql.org +Subject: IN surpasses NOT EXISTS in 7.4RC2 ?? +Date: Thu, 13 Nov 2003 13:23:39 +0530 +User-Agent: KMail/1.5.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311131323.39762.mallah@trade-india.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/84 +X-Sequence-Number: 4644 + + +Hi, + +NOT EXISTS is taking almost double time than NOT IN . +I know IN has been optimised in 7.4 but is anything +wrong with the NOT EXISTS? + +I have vaccumed , analyze and run the query many times +still not in is faster than exists :> + + +Regds +Mallah. + +NOT IN PLAN + +tradein_clients=# explain analyze SELECT count(*) from general.profile_master where + profile_id not in (select profile_id from general.account_profiles ) ; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- +Aggregate (cost=32238.19..32238.19 rows=1 width=0) (actual time=5329.206..5329.207 rows=1 loops=1) + -> Seq Scan on profile_master (cost=4458.25..31340.38 rows=359125 width=0) (actual time=1055.496..4637.908 rows=470386 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Seq Scan on account_profiles (cost=0.00..3817.80 rows=256180 width=4) (actual time=0.061..507.811 rows=256180 loops=1) +Total runtime: 5337.591 ms +(6 rows) + + +tradein_clients=# explain analyze SELECT count(*) from general.profile_master where not exists +(select profile_id from general.account_profiles where profile_id=general.profile_master.profile_id ) ; + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------- +Aggregate (cost=1674981.97..1674981.97 rows=1 width=0) (actual time=14600.386..14600.387 rows=1 loops=1) + -> Seq Scan on profile_master (cost=0.00..1674084.16 rows=359125 width=0) (actual time=13.687..13815.798 rows=470386 loops=1) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using account_profiles_profile_id on account_profiles (cost=0.00..4.59 rows=2 width=4) (actual time=0.013..0.013 rows=0 loops=718250) + Index Cond: (profile_id = $0) +Total runtime: 14600.531 ms + + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 09:48:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F3ADD1B535 + for ; + Thu, 13 Nov 2003 13:48:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41251-01 + for ; + Thu, 13 Nov 2003 09:47:39 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id D78DAD1B51E + for ; + Thu, 13 Nov 2003 09:47:29 -0400 (AST) +Received: (qmail 10716 invoked from network); 13 Nov 2003 13:47:27 -0000 +Received: from unknown (HELO ?192.168.1.199?) (134.22.68.129) + by 205.178.180.9 with SMTP; 13 Nov 2003 13:47:27 -0000 +Subject: Re: performance optimzations +From: Rod Taylor +To: Suchandra Thapa +Cc: Postgresql Performance +In-Reply-To: <1068703124.12978.27.camel@hepcat> +References: <1068658430.1071.42.camel@hepcat> + <1068661380.30452.17.camel@jester> <1068663070.5193.21.camel@hepcat> + <1068698132.31569.46.camel@jester> <1068703124.12978.27.camel@hepcat> +Content-Type: text/plain +Message-Id: <1068731245.31569.152.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 13 Nov 2003 08:47:33 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/85 +X-Sequence-Number: 4645 + +> > Most clients will be interested in say the last 7 days worth of data? +> > Great.. Start out with 4GB ram on a good Dual CPU -- Opterons seem to +> > work quite well -- and make sure the motherboard can hold double that in +> > memory for an upgrade sometime next year when you've become popular. +> +> Unfortunately, the hardware available is pretty much fixed in regards to +> the system. I can play around with the raid configurations and have +> some limited choice in regards to the raid controller and number of +> drivers but that's about all in terms of hardware. + +Good luck then. Unless the configuration takes into account incremental +additions in ram and disk, sustained growth could get very expensive. I +guess that depends on the business plan expectations. + +This just puts more emphasis to offload everything you can onto machines +that can multiply. + +> The current file system holding the user and email information indicates +> the current data has about 64GB (70K accounts, I'm not sure how many are +> active but 50% might be good guess). This seems to be somewhat of a +> steady state however. + +35k clients checking their mail daily isn't so bad. Around 10 pages per +second peak load? + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 12:25:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EC20D1B51C + for ; + Thu, 13 Nov 2003 14:57:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51627-04 + for ; + Thu, 13 Nov 2003 10:57:26 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id D6FF1D1B515 + for ; + Thu, 13 Nov 2003 10:57:20 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hADEuv409079; + Thu, 13 Nov 2003 09:56:57 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311131456.hADEuv409079@candle.pha.pa.us> +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +In-Reply-To: <200311131323.39762.mallah@trade-india.com> +To: Rajesh Kumar Mallah +Date: Thu, 13 Nov 2003 09:56:57 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/88 +X-Sequence-Number: 4648 + +Rajesh Kumar Mallah wrote: +> +> Hi, +> +> NOT EXISTS is taking almost double time than NOT IN . +> I know IN has been optimised in 7.4 but is anything +> wrong with the NOT EXISTS? +> +> I have vaccumed , analyze and run the query many times +> still not in is faster than exists :> + +Seems fine. In 7.4, NOT IN will often be faster that NOT EXISTS. NOT +EXISTS didn't change --- there are restrictions on how far we can +optimize NOT EXISTS. NOT IN has just become much faster in 7.4. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Nov 13 11:51:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1F40D1B527 + for ; + Thu, 13 Nov 2003 15:20:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53496-08 + for ; + Thu, 13 Nov 2003 11:19:51 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 63DA9D1B4FE + for ; + Thu, 13 Nov 2003 11:19:47 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADFJp19026332; + Thu, 13 Nov 2003 10:19:52 -0500 (EST) +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +In-reply-to: <200311131323.39762.mallah@trade-india.com> +References: <200311131323.39762.mallah@trade-india.com> +Comments: In-reply-to Rajesh Kumar Mallah + message dated "Thu, 13 Nov 2003 13:23:39 +0530" +Date: Thu, 13 Nov 2003 10:19:51 -0500 +Message-ID: <26331.1068736791@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/86 +X-Sequence-Number: 4646 + +Rajesh Kumar Mallah writes: +> NOT EXISTS is taking almost double time than NOT IN . +> I know IN has been optimised in 7.4 but is anything +> wrong with the NOT EXISTS? + +That's the expected behavior in 7.4. EXISTS in the style you are using +it effectively forces a nestloop-with-inner-indexscan implementation. +As of 7.4, IN can do that, but it can do several other things too, +including the hash-type plan you have here. So assuming that the +planner chooses the right plan choice (not always a given ;-)) +IN should be as fast or faster than EXISTS in all cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 13 12:39:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BE1D9D1B50E + for ; + Thu, 13 Nov 2003 15:32:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51621-10 + for ; + Thu, 13 Nov 2003 11:31:44 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FE00D1B4F1 + for ; + Thu, 13 Nov 2003 11:31:39 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hADEafcM008710; + Thu, 13 Nov 2003 09:36:41 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hADFVgl26052; + Thu, 13 Nov 2003 10:31:43 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id V3JRTPVA; Thu, 13 Nov 2003 10:31:41 -0500 +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +From: Robert Treat +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200311131323.39762.mallah@trade-india.com> +References: <200311131323.39762.mallah@trade-india.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 13 Nov 2003 10:31:42 -0500 +Message-Id: <1068737502.10946.18338.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/90 +X-Sequence-Number: 4650 + +It is believed that the IN optimization can lead to faster IN times than +EXIST times on some queries, the extent of which is still a bit of an +unknown. (Incidentally is there an FAQ item on this that needs +updating?) + +Does the not exist query produce worse results in 7.4 than it did in +7.3? + +Robert Treat + +On Thu, 2003-11-13 at 02:53, Rajesh Kumar Mallah wrote: +> +> Hi, +> +> NOT EXISTS is taking almost double time than NOT IN . +> I know IN has been optimised in 7.4 but is anything +> wrong with the NOT EXISTS? +> +> I have vaccumed , analyze and run the query many times +> still not in is faster than exists :> +> +> +> Regds +> Mallah. +> +> NOT IN PLAN +> +> tradein_clients=# explain analyze SELECT count(*) from general.profile_master where +> profile_id not in (select profile_id from general.account_profiles ) ; +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=32238.19..32238.19 rows=1 width=0) (actual time=5329.206..5329.207 rows=1 loops=1) +> -> Seq Scan on profile_master (cost=4458.25..31340.38 rows=359125 width=0) (actual time=1055.496..4637.908 rows=470386 loops=1) +> Filter: (NOT (hashed subplan)) +> SubPlan +> -> Seq Scan on account_profiles (cost=0.00..3817.80 rows=256180 width=4) (actual time=0.061..507.811 rows=256180 loops=1) +> Total runtime: 5337.591 ms +> (6 rows) +> +> +> tradein_clients=# explain analyze SELECT count(*) from general.profile_master where not exists +> (select profile_id from general.account_profiles where profile_id=general.profile_master.profile_id ) ; +> +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=1674981.97..1674981.97 rows=1 width=0) (actual time=14600.386..14600.387 rows=1 loops=1) +> -> Seq Scan on profile_master (cost=0.00..1674084.16 rows=359125 width=0) (actual time=13.687..13815.798 rows=470386 loops=1) +> Filter: (NOT (subplan)) +> SubPlan +> -> Index Scan using account_profiles_profile_id on account_profiles (cost=0.00..4.59 rows=2 width=4) (actual time=0.013..0.013 rows=0 loops=718250) +> Index Cond: (profile_id = $0) +> Total runtime: 14600.531 ms +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 12:00:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B4A9D1B50E + for ; + Thu, 13 Nov 2003 15:52:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63479-03 + for ; + Thu, 13 Nov 2003 11:52:31 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 5995ED1B527 + for ; + Thu, 13 Nov 2003 11:52:26 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hADEvOcM008935; + Thu, 13 Nov 2003 09:57:24 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hADFqPl26573; + Thu, 13 Nov 2003 10:52:25 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id V3JRTPZH; Thu, 13 Nov 2003 10:52:24 -0500 +Subject: Re: Value of Quad vs. Dual Processor machine +From: Robert Treat +To: Jeff +Cc: Chris Field , + ron.l.johnson@cox.net, pgsql-performance@postgresql.org +In-Reply-To: <20031112092807.14b18bf4.threshar@torgo.978.org> +References: <1068593567.2063.8.camel@tuxsrva> + <1068600291.30969.53.camel@haggis.homelan> + <001401c3a8c2$8c8fec30$040210ac@win2000> + <20031112092807.14b18bf4.threshar@torgo.978.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 13 Nov 2003 10:52:25 -0500 +Message-Id: <1068738745.10945.18380.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/87 +X-Sequence-Number: 4647 + +On Wed, 2003-11-12 at 09:28, Jeff wrote: +> On Tue, 11 Nov 2003 21:13:19 -0500 +> "Chris Field" wrote: +> +> > we are looking at Xeon, We are currently running it on a quad sun v880 +> > compiled to be 64bit and have been getting dreadful performance. I +> > don't think we really have much to gain from going 64bit. +> > +> > +> By chance, are you running 7.3.4 on that sun? +> If so, try this: +> export CFLAGS=-02 +> ./configure +> +> and rebuild PG. +> +> Before 7.4 PG was build with _no_ optimization on Solaris. +> Recompiling gives __HUGE__ (notice the underscores) performance gains. +> +> And onto the dual vs quad. +> +> PG will only use 1 cpu / connection / query. +> +> So if your machine iwll have 1-2 queries running at a time those other 2 +> proc's will sit around idling. However if you are going to have a bunch +> going, 4 cpus will be most useful. One of hte nicest things to do for +> PG is more ram and fast IO. It really loves those things. +> + +We've just started kicking around the idea of moving one of our boxes to +a quad-proc machine from a dual. Under normal circumstances the 2 +processors handle maybe 200 transactions per second with 90% system +idle. However we have people who occasionally run historical reports on +our data, and those reports are fairly CPU intensive. Usually it is not +a problem for the main web system, but when pg_dump is running, that is +also cpu intensive, so we end up with two highly cpu intensive items +running on our machine, and we start to notice issues on the main web +system. + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 13:00:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 69D98D1B502 + for ; + Thu, 13 Nov 2003 17:00:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78207-07 + for ; + Thu, 13 Nov 2003 13:00:12 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 497B2D1B531 + for ; + Thu, 13 Nov 2003 13:00:11 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADH0B19027152; + Thu, 13 Nov 2003 12:00:11 -0500 (EST) +To: Robert Treat +Cc: Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +In-reply-to: <1068737502.10946.18338.camel@camel> +References: <200311131323.39762.mallah@trade-india.com> + <1068737502.10946.18338.camel@camel> +Comments: In-reply-to Robert Treat + message dated "13 Nov 2003 10:31:42 -0500" +Date: Thu, 13 Nov 2003 12:00:10 -0500 +Message-ID: <27151.1068742810@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/91 +X-Sequence-Number: 4651 + +Robert Treat writes: +> Does the not exist query produce worse results in 7.4 than it did in +> 7.3? + +EXISTS should work the same as before. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 13 13:20:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67303D1B54B + for ; + Thu, 13 Nov 2003 17:20:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78988-07 + for ; + Thu, 13 Nov 2003 13:19:44 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E382D1B558 + for ; + Thu, 13 Nov 2003 13:19:43 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hADGOgcM009669; + Thu, 13 Nov 2003 11:24:42 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hADHJgl28561; + Thu, 13 Nov 2003 12:19:42 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id V3JRTQL2; Thu, 13 Nov 2003 12:19:41 -0500 +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +From: Robert Treat +To: Tom Lane +Cc: Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +In-Reply-To: <27151.1068742810@sss.pgh.pa.us> +References: <200311131323.39762.mallah@trade-india.com> + <1068737502.10946.18338.camel@camel> <27151.1068742810@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 13 Nov 2003 12:19:42 -0500 +Message-Id: <1068743982.10945.18510.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/92 +X-Sequence-Number: 4652 + +On Thu, 2003-11-13 at 12:00, Tom Lane wrote: +> Robert Treat writes: +> > Does the not exist query produce worse results in 7.4 than it did in +> > 7.3? +> +> EXISTS should work the same as before. +> + +right. the original poster is asking if there is "something wrong with +exist" based on the comparison to IN, he needs to compare it vs. 7.3 +EXISTS to determine if something is wrong. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 14:14:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73AEDD1B508 + for ; + Thu, 13 Nov 2003 18:14:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95024-06 + for ; + Thu, 13 Nov 2003 14:14:22 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AD38D1B4FE + for ; + Thu, 13 Nov 2003 14:14:20 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AKLyx-0007uk-00 + for ; Thu, 13 Nov 2003 13:14:15 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 9DE12CB49; Thu, 13 Nov 2003 13:14:15 -0500 (EST) +Date: Thu, 13 Nov 2003 13:14:15 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: strange estimate for number of rows +Message-ID: <20031113181415.GB25546@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/93 +X-Sequence-Number: 4653 + +Hi all, + +I've one here that I cannot fathom. Any suggestions? + +We have a table, call it tablename, where we're selecting by a range +of dates and an identifier. (This is redacted, obviously): + +\d tablename + + Column | Type | Modifiers +--------------------+--------------------------+-------------------- + id | integer | not null + transaction_date | timestamp with time zone | not null + product_id | integer | not null +Indexes: + "trans_posted_trans_date_idx" btree (transaction_date, product_id) + + +The statistics on transaction_date and product_id are set to 1000. +Everything is all analysed nicely. But I'm getting a poor plan, +because of an estimate that the number of rows to be returned is +about double how many actually are: + +explain analyse select * from transactions_posted where +transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' and +product_id = 2; + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on transactions_posted (cost=0.00..376630.33 rows=700923 +width=91) (actual time=8422.253..36176.078 rows=316029 loops=1) + Filter: ((transaction_date >= '2003-09-01 00:00:00-04'::timestamp +with time zone) AND (transaction_date < '2003-10-01 +00:00:00-04'::timestamp with time zone) AND (product_id = 2)) + Total runtime: 36357.630 ms +(3 rows) + +SET enable_seqscan = off; + +explain analyse select * from transactions_posted where +transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' and +product_id = 2; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using trans_posted_trans_date_idx on transactions_posted +(cost=0.00..1088862.56 rows=700923 width=91) (actual +time=35.214..14816.257 rows=316029 loops=1) + Index Cond: ((transaction_date >= '2003-09-01 +00:00:00-04'::timestamp with time zone) AND (transaction_date < +'2003-10-01 00:00:00-04'::timestamp with time zone) AND (product_id = +2)) + Total runtime: 15009.816 ms +(3 rows) + +SELECT attname,null_frac,avg_width,n_distinct,correlation FROM +pg_stats where tablename = 'transactions_posted' AND attname in +('transaction_date','product_id'); + attname | null_frac | avg_width | n_distinct | correlation +------------------+-----------+-----------+------------+------------- + product_id | 0 | 4 | 2 | 0.200956 + transaction_date | 0 | 8 | -0.200791 | 0.289248 + +Any ideas? I'm loathe to recommend cluster, since the data will not +stay clustered. + +A + + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 14:28:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EF5DD1B4EB + for ; + Thu, 13 Nov 2003 18:28:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98312-08 + for ; + Thu, 13 Nov 2003 14:28:17 -0400 (AST) +Received: from award.gotdns.org (pcp01097251pcs.tsclos01.al.comcast.net + [68.62.129.152]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A7CFD1B508 + for ; + Thu, 13 Nov 2003 14:28:16 -0400 (AST) +Received: (qmail 9067 invoked by uid 81); 13 Nov 2003 18:28:15 -0000 +Received: from 68.62.129.152 (SquirrelMail authenticated user award) + by award.gotdns.org with HTTP; Thu, 13 Nov 2003 12:28:15 -0600 (CST) +Message-ID: <23123.68.62.129.152.1068748095.squirrel@award.gotdns.org> +Date: Thu, 13 Nov 2003 12:28:15 -0600 (CST) +Subject: Union+group by planner estimates way off? +From: "Arthur Ward" +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.1 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/94 +X-Sequence-Number: 4654 + +On 7.4 RC2, I'm seeing a case where the query planner estimates are way +out of line after grouping the result of a union. I've tried adjusting the +statistics targets up to 200, and it made no difference in the planner's +estimates. The point of the full query this came from is that it also has +an aggregate function that produces a space-delimited list of commodity & +fak for each id. Does anyone have any suggestions on tweaks to apply or +ways to rewrite this? Is this one of those ugly corners where the query +planner doesn't have a clue how to estimate this (seeing the nice round +200 estimate makes me suspicious)? + +EXPLAIN ANALYZE SELECT id FROM +(SELECT id, commodity FROM commodities WHERE commodity IS NOT NULL + UNION + SELECT id, fak FROM commodities WHERE fak IS NOT NULL +) all_commodities GROUP BY id; + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- + HashAggregate (cost=15939.16..15939.16 rows=200 width=4) (actual +time=3537.281..3680.418 rows=83306 loops=1) + -> Subquery Scan all_commodities (cost=14002.00..15697.02 rows=96858 +width=4) (actual time=2268.052..3214.996 rows=95715 loops=1) + -> Unique (cost=14002.00..14728.44 rows=96858 width=15) (actual +time=2268.043..2881.688 rows=95715 loops=1) + -> Sort (cost=14002.00..14244.15 rows=96858 width=15) +(actual time=2268.037..2527.083 rows=100008 loops=1) + Sort Key: id, commodity + -> Append (cost=0.00..5034.42 rows=96858 width=15) +(actual time=7.402..1220.320 rows=100008 loops=1) + -> Subquery Scan "*SELECT* 1" +(cost=0.00..2401.23 rows=36831 width=15) +(actual time=7.398..590.004 rows=39772 loops=1) + -> Seq Scan on commodities +(cost=0.00..2032.92 rows=36831 width=15) +(actual time=7.388..468.415 rows=39772 +loops=1) + Filter: (commodity IS NOT NULL) + -> Subquery Scan "*SELECT* 2" +(cost=0.00..2633.19 rows=60027 width=14) +(actual time=0.016..408.160 rows=60236 loops=1) + -> Seq Scan on commodities +(cost=0.00..2032.92 rows=60027 width=14) +(actual time=0.010..221.635 rows=60236 +loops=1) + Filter: (fak IS NOT NULL) + Total runtime: 3783.009 ms +(13 rows) + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 14:47:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F095D1B508 + for ; + Thu, 13 Nov 2003 18:47:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04220-10 + for ; + Thu, 13 Nov 2003 14:46:52 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E127D1B554 + for ; + Thu, 13 Nov 2003 14:46:51 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADIkp19005807; + Thu, 13 Nov 2003 13:46:51 -0500 (EST) +To: "Arthur Ward" +Cc: pgsql-performance@postgresql.org +Subject: Re: Union+group by planner estimates way off? +In-reply-to: <23123.68.62.129.152.1068748095.squirrel@award.gotdns.org> +References: <23123.68.62.129.152.1068748095.squirrel@award.gotdns.org> +Comments: In-reply-to "Arthur Ward" + message dated "Thu, 13 Nov 2003 12:28:15 -0600" +Date: Thu, 13 Nov 2003 13:46:51 -0500 +Message-ID: <5806.1068749211@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/95 +X-Sequence-Number: 4655 + +"Arthur Ward" writes: +> EXPLAIN ANALYZE SELECT id FROM +> (SELECT id, commodity FROM commodities WHERE commodity IS NOT NULL +> UNION +> SELECT id, fak FROM commodities WHERE fak IS NOT NULL +> ) all_commodities GROUP BY id; +> QUERY +> PLAN +> ---------------------------------------------------------------------------------------------------------------------------------------------------------------- +> HashAggregate (cost=15939.16..15939.16 rows=200 width=4) (actual +> time=3537.281..3680.418 rows=83306 loops=1) +> -> Subquery Scan all_commodities (cost=14002.00..15697.02 rows=96858 +> width=4) (actual time=2268.052..3214.996 rows=95715 loops=1) + +It's falling back to a default estimate because it doesn't know how to +find any statistics for the output of a sub-select. I have a TODO +somewhere about burrowing down into sub-selects to see if the output maps +directly to a column that we'd have stats for ... but it's not done yet. + +In this particular case the inaccurate estimate doesn't matter too much, +I think, although it might be encouraging the system to select hash +aggregation since it thinks the hashtable will be pretty small. If the +estimate were getting used to plan higher-up plan steps then it could +be a bigger problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 13 14:57:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC188D1B522 + for ; + Thu, 13 Nov 2003 18:56:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05355-09 + for ; + Thu, 13 Nov 2003 14:56:28 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E78D4D1B50E + for ; + Thu, 13 Nov 2003 14:56:26 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADIuR19005883; + Thu, 13 Nov 2003 13:56:27 -0500 (EST) +To: Andrew Sullivan +Cc: pgsql-performance@postgresql.org +Subject: Re: strange estimate for number of rows +In-reply-to: <20031113181415.GB25546@libertyrms.info> +References: <20031113181415.GB25546@libertyrms.info> +Comments: In-reply-to Andrew Sullivan + message dated "Thu, 13 Nov 2003 13:14:15 -0500" +Date: Thu, 13 Nov 2003 13:56:26 -0500 +Message-ID: <5882.1068749786@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/96 +X-Sequence-Number: 4656 + +Andrew Sullivan writes: +> The statistics on transaction_date and product_id are set to 1000. +> Everything is all analysed nicely. But I'm getting a poor plan, +> because of an estimate that the number of rows to be returned is +> about double how many actually are: + +> explain analyse select * from transactions_posted where +> transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' and +> product_id = 2; + +Are the estimates accurate for queries on the two columns individually, +ie +... where transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' +... where product_id = 2 + +If so, the problem is that there's a correlation between +transaction_date and product_id, which the system cannot model because +it has no multi-column statistics. + +However, given that the estimate is only off by about a factor of 2, +you'd still be getting the wrong plan even if the estimate were perfect, +because the estimated costs differ by nearly a factor of 3. + +Given the actual runtimes, I'm thinking maybe you want to reduce +random_page_cost. What are you using for that now? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 13 15:19:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B048D1B522 + for ; + Thu, 13 Nov 2003 19:19:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16409-01 + for ; + Thu, 13 Nov 2003 15:19:08 -0400 (AST) +Received: from award.gotdns.org (pcp01097251pcs.tsclos01.al.comcast.net + [68.62.129.152]) + by svr1.postgresql.org (Postfix) with ESMTP id 059F4D1B508 + for ; + Thu, 13 Nov 2003 15:19:07 -0400 (AST) +Received: (qmail 9850 invoked by uid 81); 13 Nov 2003 19:19:07 -0000 +Received: from 68.62.129.152 (SquirrelMail authenticated user award) + by award.gotdns.org with HTTP; Thu, 13 Nov 2003 13:19:07 -0600 (CST) +Message-ID: <50572.68.62.129.152.1068751147.squirrel@award.gotdns.org> +In-Reply-To: <5806.1068749211@sss.pgh.pa.us> +References: <23123.68.62.129.152.1068748095.squirrel@award.gotdns.org> + <5806.1068749211@sss.pgh.pa.us> +Date: Thu, 13 Nov 2003 13:19:07 -0600 (CST) +Subject: Re: Union+group by planner estimates way off? +From: "Arthur Ward" +To: "Tom Lane" +Cc: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.1 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/97 +X-Sequence-Number: 4657 + +> In this particular case the inaccurate estimate doesn't matter too much, +> I think, although it might be encouraging the system to select hash +> aggregation since it thinks the hashtable will be pretty small. If the +> estimate were getting used to plan higher-up plan steps then it could +> be a bigger problem. + +That's my problem; this is a subselect feeding in to a larger query. That +wrong estimate causes the planner to select a nested-loop at the next step +up. At 83,000 rows, the word is "ouch!" + +At any rate, I discovered this while dissecting a giant & slow query. +Hence, while disabling nested-loop joins avoids this particular pitfall, +it's not good for the bigger picture. I think I'm going to end up +splitting this larger query into smaller parts and reassemble the pieces +in the application so I can push some smarts past other subselect +boundaries. For my purposes, that should skirt the issue of union+group +estimates not being calculated. + +As always, thanks for the fast answers! + +From pgsql-performance-owner@postgresql.org Thu Nov 13 15:43:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 54F97D1B4E1 + for ; + Thu, 13 Nov 2003 19:43:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16175-08 + for ; + Thu, 13 Nov 2003 15:42:30 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 69341D1B522 + for ; + Thu, 13 Nov 2003 15:42:29 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by www.postgresql.com (Postfix) with ESMTP id A5679CF48D4 + for ; + Thu, 13 Nov 2003 15:42:28 -0400 (AST) +Received: from dev7.int.libertyrms.com ([10.1.2.225] helo=libertyrms.info) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AKNHK-0000hW-00; Thu, 13 Nov 2003 14:37:18 -0500 +Message-ID: <3FB3DD1E.2000509@libertyrms.info> +Date: Thu, 13 Nov 2003 14:35:58 -0500 +From: Daniel Manley +User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.5) Gecko/20031016 +X-Accept-Language: en, fr, en-us +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: strange estimate for number of rows +References: <20031113181415.GB25546@libertyrms.info> + <5882.1068749786@sss.pgh.pa.us> +In-Reply-To: <5882.1068749786@sss.pgh.pa.us> +Content-Type: text/plain; charset=KOI8-R; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/100 +X-Sequence-Number: 4660 + +Hi, I'm the lead developer on the project this concerns (forgive my +newbiness on this list). + +We tried a couple of scenarios with effective_cache_size=60000, +cpu_index_tuple_cost=0.0001 and random_page_cost=2 with no change in the +plan. + +explain analyse select * from tablename where transaction_date >= +'2003-9-1' and transaction_date < '2003-10-1'; +----------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on tablename (cost=0.00..348199.14 rows=1180724 width=91) +(actual time=7727.668..36286.898 rows=579238 loops=1) + Filter: ((transaction_date >= '2003-09-01 00:00:00+00'::timestamp +with time zone) AND (transaction_date < '2003-10-01 +00:00:00+00'::timestamp with time zone)) + Total runtime: 36625.351 ms + +explain analyse select * from transactions_posted where product_id = 2; +----------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on transactions_posted (cost=0.00..319767.95 rows=6785237 +width=91) (actual time=0.091..35596.328 rows=5713877 loops=1) + Filter: (product_id = 2) + Total runtime: 38685.373 ms + +The product_id alone gives a difference of a millions rows from estimate +to actual, vs. the factor of 2 from the transaction_date. + +Dan Manley + +Tom Lane �����: + +>Andrew Sullivan writes: +> +> +>>The statistics on transaction_date and product_id are set to 1000. +>>Everything is all analysed nicely. But I'm getting a poor plan, +>>because of an estimate that the number of rows to be returned is +>>about double how many actually are: +>> +>> +> +> +> +>>explain analyse select * from transactions_posted where +>>transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' and +>>product_id = 2; +>> +>> +> +>Are the estimates accurate for queries on the two columns individually, +>ie +>... where transaction_date >= '2003-9-1' and transaction_date < '2003-10-1' +>... where product_id = 2 +> +>If so, the problem is that there's a correlation between +>transaction_date and product_id, which the system cannot model because +>it has no multi-column statistics. +> +>However, given that the estimate is only off by about a factor of 2, +>you'd still be getting the wrong plan even if the estimate were perfect, +>because the estimated costs differ by nearly a factor of 3. +> +>Given the actual runtimes, I'm thinking maybe you want to reduce +>random_page_cost. What are you using for that now? +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Don't 'kill -9' the postmaster +> +> + + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 15:39:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F6A3D1B540 + for ; + Thu, 13 Nov 2003 19:39:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15957-06 + for ; + Thu, 13 Nov 2003 15:38:53 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id EB0A5D1B4F1 + for ; + Thu, 13 Nov 2003 15:38:51 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3914758 for pgsql-performance@postgresql.org; + Thu, 13 Nov 2003 11:39:21 -0800 +Content-Type: text/plain; + charset="us-ascii" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Storage space, RAM for NUMERIC +Date: Thu, 13 Nov 2003 11:36:05 -0800 +User-Agent: KMail/1.4.3 +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311131136.05066.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/99 +X-Sequence-Number: 4659 + +Folks, + +How would I calculate storage space/required ram on a 50-digit NUMERIC? + +And the docs state that NUMERIC is slow. Is this just slow for calculatio= +ns=20 +(due to the conversion to float & back) or slow for index lookups as well? + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 16:19:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C6E11D1B559 + for ; + Thu, 13 Nov 2003 20:19:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19869-05 + for ; + Thu, 13 Nov 2003 16:19:10 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A20CED1B522 + for ; + Thu, 13 Nov 2003 16:19:08 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADKJ819011161; + Thu, 13 Nov 2003 15:19:09 -0500 (EST) +To: Daniel Manley +Cc: pgsql-performance@postgresql.org +Subject: Re: strange estimate for number of rows +In-reply-to: <3FB3DD1E.2000509@libertyrms.info> +References: <20031113181415.GB25546@libertyrms.info> + <5882.1068749786@sss.pgh.pa.us> <3FB3DD1E.2000509@libertyrms.info> +Comments: In-reply-to Daniel Manley + message dated "Thu, 13 Nov 2003 14:35:58 -0500" +Date: Thu, 13 Nov 2003 15:19:08 -0500 +Message-ID: <11160.1068754748@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/101 +X-Sequence-Number: 4661 + +Daniel Manley writes: +> The product_id alone gives a difference of a millions rows from estimate +> to actual, vs. the factor of 2 from the transaction_date. + +You should be thinking in terms of ratios, not absolute difference. +The rows estimate for product_id doesn't look too bad to me; the one for +transaction_date is much further off (a factor of 2). Which is odd, +because the system can usually do all right on range estimates if you've +let it run an ANALYZE with enough histogram bins. Could we see the +pg_stats row for transaction_date? + +> We tried a couple of scenarios with effective_cache_size=60000, +> cpu_index_tuple_cost=0.0001 and random_page_cost=2 with no change in the +> plan. + +Since you need about a factor of 3 change in the cost estimate to get it to +switch plans, changing random_page_cost by a factor of 2 ain't gonna do +it (the other two numbers are second-order adjustments unlikely to have +much effect, I think). Try 1.5, or even less ... of course, you have to +keep an eye on your other queries and make sure they don't go nuts, but +from what I've heard about your hardware setup a low random_page_cost +isn't out of line with the physical realities. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 13 17:37:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85FAFD1B4ED + for ; + Thu, 13 Nov 2003 21:37:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38680-04 + for ; + Thu, 13 Nov 2003 17:37:03 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D12FD1B535 + for ; + Thu, 13 Nov 2003 17:37:01 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AKP9D-0002cd-00 + for ; Thu, 13 Nov 2003 16:37:03 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 4C0FFCB49; Thu, 13 Nov 2003 16:37:03 -0500 (EST) +Date: Thu, 13 Nov 2003 16:37:03 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: strange estimate for number of rows +Message-ID: <20031113213703.GJ25546@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <20031113181415.GB25546@libertyrms.info> + <5882.1068749786@sss.pgh.pa.us> <3FB3DD1E.2000509@libertyrms.info> + <11160.1068754748@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <11160.1068754748@sss.pgh.pa.us> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/102 +X-Sequence-Number: 4662 + +On Thu, Nov 13, 2003 at 03:19:08PM -0500, Tom Lane wrote: +> because the system can usually do all right on range estimates if you've +> let it run an ANALYZE with enough histogram bins. Could we see the +> pg_stats row for transaction_date? + +Do you want the whole thing? I left out the really verbose bits when +I posted this in the original: + +SELECT attname,null_frac,avg_width,n_distinct,correlation FROM +pg_stats where tablename = 'transactions_posted' AND attname in +('transaction_date','product_id'); + attname | null_frac | avg_width | n_distinct | correlation +------------------+-----------+-----------+------------+------------- + product_id | 0 | 4 | 2 | 0.200956 + transaction_date | 0 | 8 | -0.200791 | 0.289248 + +> +> Since you need about a factor of 3 change in the cost estimate to get it to +> switch plans, changing random_page_cost by a factor of 2 ain't gonna do +> it (the other two numbers are second-order adjustments unlikely to have +> much effect, I think). Try 1.5, or even less ... of course, you have to +> keep an eye on your other queries and make sure they don't go nuts, but +> from what I've heard about your hardware setup a low random_page_cost +> isn't out of line with the physical realities. + +Actually, this one's on an internal box, and I think 1.5 is too low +-- it's really just a pair of mirrored SCSI disks on a PCI controller +in this case. That does the trick, though, so maybe I'm just being +too conservantive. + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 17:53:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 45187D1B540 + for ; + Thu, 13 Nov 2003 21:53:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38400-08 + for ; + Thu, 13 Nov 2003 17:52:52 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id D34AAD1B531 + for ; + Thu, 13 Nov 2003 17:52:49 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AKPOW-0002sK-00 + for ; Thu, 13 Nov 2003 16:52:52 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 037E9CB49; Thu, 13 Nov 2003 16:52:51 -0500 (EST) +Date: Thu, 13 Nov 2003 16:52:51 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: strange estimate for number of rows +Message-ID: <20031113215251.GL25546@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <20031113181415.GB25546@libertyrms.info> + <5882.1068749786@sss.pgh.pa.us> <3FB3DD1E.2000509@libertyrms.info> + <11160.1068754748@sss.pgh.pa.us> + <20031113213703.GJ25546@libertyrms.info> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031113213703.GJ25546@libertyrms.info> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/103 +X-Sequence-Number: 4663 + +On Thu, Nov 13, 2003 at 04:37:03PM -0500, Andrew Sullivan wrote: +> Actually, this one's on an internal box, and I think 1.5 is too low +> -- it's really just a pair of mirrored SCSI disks on a PCI controller +> in this case. That does the trick, though, so maybe I'm just being +> too conservantive. + +I spoke too soon. I'd left enable_seqscan=off set. It doesn't +actually prefer an indexscan until I set the random_page_cost to .5. +I think that's a little unrealistic ;-) + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 03:19:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A387D1B4EB + for ; + Fri, 14 Nov 2003 07:19:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30604-05 + for ; + Fri, 14 Nov 2003 03:18:50 -0400 (AST) +Received: from rtlocal.trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 56930D1B4F1 + for ; + Fri, 14 Nov 2003 03:18:46 -0400 (AST) +Received: (qmail 12618 invoked from network); 14 Nov 2003 07:37:06 -0000 +Received: from unknown (HELO trade-india.com) (unknown) + by unknown with SMTP; 14 Nov 2003 07:37:06 -0000 +From: Rajesh Kumar Mallah +Organization: Infocom Network Limited +To: pgsql-performance@postgresql.org +Subject: Help with count(*) +Date: Fri, 14 Nov 2003 12:51:38 +0530 +User-Agent: KMail/1.5.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311141251.38786.mallah@trade-india.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/104 +X-Sequence-Number: 4664 + + + +Hi , + +my database seems to be taking too long for a select count(*) +i think there are lot of dead rows. I do a vacuum full it improves +bu again the performance drops in a short while , +can anyone please tell me if anything worng with my fsm settings +current fsm=55099264 (not sure how i calculated it) + +Regds +Mallah + +tradein_clients=# SELECT count(*) from data_bank.profiles ; + ++--------+ +| count | ++--------+ +| 123065 | ++--------+ +(1 row) + +Time: 49756.969 ms +tradein_clients=# +tradein_clients=# +tradein_clients=# VACUUM full verbose analyze data_bank.profiles ; +INFO: vacuuming "data_bank.profiles" + +INFO: "profiles": found 0 removable, 369195 nonremovable row versions in 43423 pages +DETAIL: 246130 dead row versions cannot be removed yet. +Nonremovable row versions range from 136 to 2036 bytes long. +There were 427579 unused item pointers. +Total free space (including removable row versions) is 178536020 bytes. +15934 pages are or will become empty, including 0 at the end of the table. +38112 pages containing 178196624 free bytes are potential move destinations. +CPU 1.51s/0.63u sec elapsed 23.52 sec. +INFO: index "profiles_pincode" now contains 369195 row versions in 3353 pages +DETAIL: 0 index row versions were removed. +379 index pages have been deleted, 379 are currently reusable. +CPU 0.20s/0.24u sec elapsed 22.73 sec. +INFO: index "profiles_city" now contains 369195 row versions in 3411 pages +DETAIL: 0 index row versions were removed. +1030 index pages have been deleted, 1030 are currently reusable. +CPU 0.17s/0.21u sec elapsed 20.67 sec. +INFO: index "profiles_branch" now contains 369195 row versions in 2209 pages +DETAIL: 0 index row versions were removed. +783 index pages have been deleted, 783 are currently reusable. +CPU 0.07s/0.14u sec elapsed 6.38 sec. +INFO: index "profiles_area_code" now contains 369195 row versions in 2606 pages +DETAIL: 0 index row versions were removed. +856 index pages have been deleted, 856 are currently reusable. +CPU 0.11s/0.17u sec elapsed 19.62 sec. +INFO: index "profiles_source" now contains 369195 row versions in 3137 pages +DETAIL: 0 index row versions were removed. +1199 index pages have been deleted, 1199 are currently reusable. +CPU 0.14s/0.12u sec elapsed 9.95 sec. +INFO: index "co_name_index_idx" now contains 368742 row versions in 3945 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.19s/0.69u sec elapsed 11.56 sec. +INFO: index "address_index_idx" now contains 368898 row versions in 4828 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.16s/0.61u sec elapsed 9.17 sec. +INFO: index "profiles_exp_cat" now contains 153954 row versions in 2168 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.07s/0.25u sec elapsed 3.14 sec. +INFO: index "profiles_imp_cat" now contains 73476 row versions in 1030 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.05s/0.11u sec elapsed 8.73 sec. +INFO: index "profiles_manu_cat" now contains 86534 row versions in 1193 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/0.13u sec elapsed 1.44 sec. +INFO: index "profiles_serv_cat" now contains 19256 row versions in 267 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.01s/0.01u sec elapsed 0.25 sec. +INFO: index "profiles_pid" now contains 369195 row versions in 812 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/0.12u sec elapsed 0.41 sec. +INFO: index "profiles_pending_branch_id" now contains 0 row versions in 1 pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: "profiles": moved 0 row versions, truncated 43423 to 43423 pages +DETAIL: CPU 1.76s/3.01u sec elapsed 60.39 sec. +INFO: vacuuming "pg_toast.pg_toast_39873340" +INFO: "pg_toast_39873340": found 0 removable, 65 nonremovable row versions in 15 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 47 to 2034 bytes long. +There were 0 unused item pointers. +Total free space (including removable row versions) is 17672 bytes. +0 pages are or will become empty, including 0 at the end of the table. +14 pages containing 17636 free bytes are potential move destinations. +CPU 0.00s/0.00u sec elapsed 0.77 sec. +INFO: index "pg_toast_39873340_index" now contains 65 row versions in 2 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.46 sec. +INFO: "pg_toast_39873340": moved 0 row versions, truncated 15 to 15 pages +DETAIL: CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: analyzing "data_bank.profiles" +INFO: "profiles": 43423 pages, 123065 rows sampled, 123065 estimated total rows +VACUUM +Time: 246989.138 ms +tradein_clients=# SELECT count(*) from data_bank.profiles ; ++--------+ +| count | ++--------+ +| 123065 | ++--------+ +(1 row) + +Time: 4978.725 ms +tradein_clients=# + +IMPORVED but still not very good. + +Regds +Mallah. + + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 03:44:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C3BFDD1B535 + for ; + Fri, 14 Nov 2003 07:44:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38130-02 + for ; + Fri, 14 Nov 2003 03:44:18 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 7747BD1B559 + for ; + Fri, 14 Nov 2003 03:44:00 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Fri, 14 Nov 2003 00:44:02 -0700 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +Date: Fri, 14 Nov 2003 13:00:34 +0530 +User-Agent: KMail/1.5.4 +References: <200311141251.38786.mallah@trade-india.com> +In-Reply-To: <200311141251.38786.mallah@trade-india.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200311141300.34397.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/105 +X-Sequence-Number: 4665 + +On Friday 14 November 2003 12:51, Rajesh Kumar Mallah wrote: +> Hi , +> +> my database seems to be taking too long for a select count(*) +> i think there are lot of dead rows. I do a vacuum full it improves +> bu again the performance drops in a short while , +> can anyone please tell me if anything worng with my fsm settings +> current fsm=3D55099264 (not sure how i calculated it) + +If you don't need exact count, you can use statistics. Just analyze frequen= +tly=20 +and you will get the statistics. + +and I didn't exact;y understand this in the text. + +INFO: =A0"profiles": found 0 removable, 369195 nonremovable row versions in= +=20 +43423 pages +DETAIL: =A0246130 dead row versions cannot be removed yet. + +Is there a transaction holoding up large amount of stuff? + + Shridhar + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 05:45:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18E07D1B54B + for ; + Fri, 14 Nov 2003 09:45:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55482-03 + for ; + Fri, 14 Nov 2003 05:45:09 -0400 (AST) +Received: from ALPHA9.ITS.MONASH.EDU.AU (alpha9.its.monash.edu.au + [130.194.1.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 01DD4D1B544 + for ; + Fri, 14 Nov 2003 05:45:07 -0400 (AST) +Received: from localhost ([130.194.13.81]) by vaxh.its.monash.edu.au + (PMDF V5.2-31 #39306) + with ESMTP id <01L319WO9YN28WZH8O@vaxh.its.monash.edu.au> for + pgsql-performance@postgresql.org; Fri, 14 Nov 2003 20:38:33 +1100 +Received: from kapow.its.monash.edu.au + (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) + with ESMTP id 5B6EF1B0002 for ; Fri, + 14 Nov 2003 20:38:33 +1100 (EST) +Received: from bruce.csse.monash.edu.au + (bruce.csse.monash.edu.au [130.194.64.3]) by kapow.its.monash.edu.au + (Postfix) + with ESMTP id 45563124003 for ; Fri, + 14 Nov 2003 20:38:33 +1100 (EST) +Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) + by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id + hAE9cX8x014951 for ; + Fri, 14 Nov 2003 20:38:33 +1100 (EST) +Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au + (8.12.8+Sun/8.12.2/Submit) with ESMTP id hAE9cXtu014948 for + ; + Fri, 14 Nov 2003 20:38:33 +1100 (EST) +Date: Fri, 14 Nov 2003 20:38:33 +1100 (EST) +From: Slavisa Garic +Subject: INSERT extremely slow with large data sets (fwd) +To: pgsql-performance@postgresql.org +Message-id: + +MIME-version: 1.0 +Content-type: TEXT/PLAIN; charset=US-ASCII +Content-transfer-encoding: 7BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/106 +X-Sequence-Number: 4666 + +Hi Everyone, + +I am using PostgreSQL 7.3.2 and have used earlier versions (7.1.x onwards) +and with all of them I noticed same problem with INSERTs when there is a +large data set. Just to so you guys can compare time it takes to insert +one row into a table when there are only few rows present and when there +are thousands: + +Rows Present Start Time Finish Time +------------------------------------------------------------ +100 1068790804.12 1068790804.12 +1000 1068790807.87 1068790807.87 +5000 1068790839.26 1068790839.27 +10000 1068790909.24 1068790909.26 +20000 1068791172.82 1068791172.85 +30000 1068791664.06 1068791664.09 +40000 1068792369.94 1068792370.0 +50000 1068793317.53 1068793317.6 +60000 1068794369.38 1068794369.47 + +As you can see if takes awfully lots of time for me just to have those +values inserted. Now to make a picture a bit clearer for you this table +has lots of information in there, about 25 columns. Also there are few +indexes that I created so that the process of selecting values from there +is faster which by the way works fine. Selecting anything takes under 5 +seconds. + +Any help would be greatly appreciated even pointing me in the right +direction where to ask this question. By the way I designed the database +this way as my application that uses PGSQL a lot during the execution so +there was a huge need for fast SELECTs. Our experiments are getting larger +and larger every day so fast inserts would be good as well. + +Just to note those times above are of INSERTs only. Nothing else done that +would be included in those times. Machine was also free and that was the +only process running all the time and the machine was Intel(R) Pentium(R) +4 CPU 2.40GHz. + +Regards, +Slavisa + + + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 06:12:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DABDFD1B544 + for ; + Fri, 14 Nov 2003 10:12:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54100-10 + for ; + Fri, 14 Nov 2003 06:12:09 -0400 (AST) +Received: from easily.co.uk (unknown [213.161.76.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 8617BD1B535 + for ; + Fri, 14 Nov 2003 06:12:04 -0400 (AST) +Received: from [213.152.63.90] (HELO webbased10) + by easily.co.uk (CommuniGate Pro SMTP 4.1.3) + with SMTP id 34415623 for pgsql-performance@postgresql.org; + Fri, 14 Nov 2003 10:11:46 +0000 +Message-ID: <002201c3aa97$b53bbac0$2802a8c0@webbased10> +From: "Nick Barr" +To: +Subject: IDE Hardware RAID Controller +Date: Fri, 14 Nov 2003 10:11:44 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2600.0000 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200311/107 +X-Sequence-Number: 4667 + +Heya, + +FYI just spotted this and thought I would pass it on, for all those who are +looking at new boxes. + +http://www.theinquirer.net/?article=12665 +http://www.promise.com/product/product_detail_eng.asp?productId=112&familyId +=2 + +Looks like a four-channel hot-swap IDE (SATA) hardware RAID controller with +up to 256Mb onboard RAM. + + +Nick + + + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 09:38:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 92DE4D1B50D + for ; + Fri, 14 Nov 2003 13:38:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80821-09 + for ; + Fri, 14 Nov 2003 09:38:12 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 0D2A3D1B51C + for ; + Fri, 14 Nov 2003 09:38:08 -0400 (AST) +Received: (qmail 90440 invoked from network); 14 Nov 2003 13:38:10 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 14 Nov 2003 13:38:10 -0000 +Date: Fri, 14 Nov 2003 08:37:55 -0500 +From: Jeff +To: Slavisa Garic +Cc: pgsql-performance@postgresql.org +Subject: Re: INSERT extremely slow with large data sets (fwd) +Message-Id: <20031114083755.67841110.threshar@torgo.978.org> +In-Reply-To: + +References: + +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/108 +X-Sequence-Number: 4668 + +On Fri, 14 Nov 2003 20:38:33 +1100 (EST) +Slavisa Garic wrote: + +> Any help would be greatly appreciated even pointing me in the right +> direction where to ask this question. By the way I designed the +> database this way as my application that uses PGSQL a lot during the +> execution so there was a huge need for fast SELECTs. Our experiments +> are getting larger and larger every day so fast inserts would be good +> as well. +> + +First, you need to upgrade to 7.3.4, 7.4 is prefable if a dump/reload is +not too bad. + +Standard set of questions: + +1. Any foreign keys +2. are these inserts batched into transactions +3. CPU usage? +4. OS? +5. PG config? [shared_buffers, effective_cache_size, etc] +6. IO saturation? + +Also, try searching the archives. lots of juicy info there too. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Fri Nov 14 10:49:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B953D1B51E + for ; + Fri, 14 Nov 2003 14:49:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97934-05 + for ; + Fri, 14 Nov 2003 10:48:58 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id C557AD1B540 + for ; + Fri, 14 Nov 2003 10:48:54 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAEEmsNu027454 + for ; Fri, 14 Nov 2003 14:48:54 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAEEKNmv021905 + for pgsql-performance@postgresql.org; Fri, 14 Nov 2003 14:20:23 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help with count(*) +Date: Fri, 14 Nov 2003 09:13:48 -0500 +Organization: cbbrowne Computing Inc +Lines: 19 +Message-ID: +References: <200311141251.38786.mallah@trade-india.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:+5cNivcH5pqcGL+Z9tMQuNk0Vto= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/109 +X-Sequence-Number: 4669 + +Martha Stewart called it a Good Thing when mallah@trade-india.com (Rajesh Kumar Mallah) wrote: +> INFO: "profiles": found 0 removable, 369195 nonremovable row versions in 43423 pages +> DETAIL: 246130 dead row versions cannot be removed yet. +> Nonremovable row versions range from 136 to 2036 bytes long. + +It seems as though you have a transaction open that is holding onto a +whole lot of old rows. + +I have seen this happen somewhat-invisibly when a JDBC connection +manager opens transactions for each connection, and then no processing +happens to use those connections for a long time. The open +transactions prevent vacuums from doing any good... +-- +If this was helpful, rate me +http://cbbrowne.com/info/multiplexor.html +"Waving away a cloud of smoke, I look up, and am blinded by a bright, +white light. It's God. No, not Richard Stallman, or Linus Torvalds, +but God. In a booming voice, He says: "THIS IS A SIGN. USE LINUX, THE +FREE Unix SYSTEM FOR THE 386." -- Matt Welsh + +From pgsql-performance-owner@postgresql.org Fri Nov 14 11:17:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CD503D1B55B + for ; + Fri, 14 Nov 2003 15:10:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01129-03 + for ; + Fri, 14 Nov 2003 11:10:12 -0400 (AST) +Received: from mystic.root.hu (mystic.root.hu [62.68.166.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 8203FD1B50B + for ; + Fri, 14 Nov 2003 11:10:07 -0400 (AST) +Received: from [213.163.10.103] (helo=fejleszt4) + by mystic.root.hu with asmtp (Exim 3.36 #1 (Debian)) + id 1AKfaC-0007Qh-00 (authenticated sender: + fac545198474dd6187837a07256e3b3f) + for ; Fri, 14 Nov 2003 16:10:00 +0100 +Message-ID: <01a601c3aac1$281e72c0$0403a8c0@fejleszt4> +From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +To: +Subject: constant vs function param differs in performance +Date: Fri, 14 Nov 2003 16:08:27 +0100 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Authenticated-Sender: fac545198474dd6187837a07256e3b3f +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200311/110 +X-Sequence-Number: 4670 + +Dear Gurus, + +I have two SQL function that produce different times and I can't understand +why. Here is the basic difference between them: + +CREATE FUNCTION test_const_1234 () RETURNS int4 AS ' + SELECT ... 1234 ... 1234 .... 1234 ... +' LANGUAGE 'SQL'; + +CREATE FUNCTION test_param (int4) RETURNS int4 AS ' + SELECT ... $1 .... $1 .... $1 ... +' LANGUAGE 'SQL'; + +Some sample times for different data: + +test_const_1234() 450 msec +test_param(1234) 2700-4000 msec (probably disk cache) +test_const_5678() 13500 msec +test_param(5678) 14500 msec + +Is there a sane explanation? a solution? +I can send more info if you wish. + +TIA, +G. +------------------------------- cut here ------------------------------- + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 12:01:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A3FBD1B4E4 + for ; + Fri, 14 Nov 2003 16:01:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10469-04 + for ; + Fri, 14 Nov 2003 12:01:15 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AF4BD1B50C + for ; + Fri, 14 Nov 2003 12:01:15 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hAEG0n5f024840; Fri, 14 Nov 2003 11:00:50 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Manfred Koizar" +Cc: "Tom Lane" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Fri, 14 Nov 2003 11:00:38 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +In-Reply-To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/111 +X-Sequence-Number: 4671 + + +> Does actor_case_assignment contain more columns than just the two ids? +> If yes, do these additional fields account for ca. 70 bytes per tuple? +> If not, try +> VACUUM FULL ANALYSE actor_case_assignment; + +actor_case_assignment has its own primary key and a "role" field in addition +to the ids you've seen, so 70 bytes sounds reasonable. (The PK is to allow a +remote mirroring application to update these records- otherwise it would be +unnecessary.) + + + +> 7ms per +> tuple returned looks like a lot of disk seeks are involved. Is +> clustering actor on actor_full_name_uppercase an option or would this +> slow down other queries? + +Good question... I've never used clustering in PostgreSQL before, so I'm +unsure. I presume this is like clustering in Oracle where the table is +ordered to match the index? If so, I think you may be onto something because +the only other field We regularly query on is the actor_id. Actor_id has a +unique index with no clustering currently, so I don't think I'd lose a thing +by clustering on actor_full_name_uppercase. + +I'll give this a try & let you know how it changes. + +BTW, you are correct that caching has a big affect on the actual time +figures in this case- I'm working on my development DB, so cahced info +doesn't get trampled as quickly by other users. Is there a way to flush out +the cache in a testing situation like this in order to start from a +consistent base? + + +Thanks! + -Nick + + + +From pgsql-performance-owner@postgresql.org Thu Nov 13 12:34:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D63CD1B51C + for ; + Thu, 13 Nov 2003 16:01:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67143-01 + for ; + Thu, 13 Nov 2003 12:01:28 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 59328D1B552 + for ; + Thu, 13 Nov 2003 12:01:27 -0400 (AST) +Received: (qmail 2473 invoked from network); 13 Nov 2003 16:02:34 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 13 Nov 2003 16:02:34 -0000 +Message-ID: <3FB4FC66.3060503@trade-india.com> +Date: Fri, 14 Nov 2003 21:31:42 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Robert Treat +Cc: pgsql-performance@postgresql.org +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +References: <200311131323.39762.mallah@trade-india.com> + <1068737502.10946.18338.camel@camel> +In-Reply-To: <1068737502.10946.18338.camel@camel> +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/89 +X-Sequence-Number: 4649 + + + + + + + + +Robert Treat wrote:
+
+
It is believed that the IN optimization can lead to faster IN times than
+EXIST times on some queries, the extent of which is still a bit of an
+unknown. (Incidentally is there an FAQ item on this that needs
+updating?)
+  
+
+
+Thanks every one for clarifying. Its really a nice thing to see IN +working
+so well becoz its easier to read the SQL using IN.
+
+looks like NOT IN is indifferent to indexes where is IN uses indexes , +is it true?
+
+does indexes affect the new manner in which IN works in 7.4 ?
+
+
+
+
+
+
+
+Does the not exist query produce worse results in 7.4 than it did in
+7.3?
+
+Will surely post the overvation sometime.
+
+
+
+Regards
+Mallah.
+
+
+
+
+
+Robert Treat
+
+On Thu, 2003-11-13 at 02:53, Rajesh Kumar Mallah wrote:
+  
+
+
Hi,
+
+NOT EXISTS is taking almost double time than NOT IN .
+I know IN has been optimised in 7.4 but is anything 
+wrong with the NOT EXISTS?
+
+I have vaccumed , analyze and run the query many times
+still not in is faster than exists :>
+
+
+Regds
+Mallah.
+
+NOT IN PLAN
+
+tradein_clients=# explain analyze SELECT  count(*) from general.profile_master where
+ profile_id not in (select  profile_id from general.account_profiles ) ;
+                                                             QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------
+Aggregate  (cost=32238.19..32238.19 rows=1 width=0) (actual time=5329.206..5329.207 rows=1 loops=1)
+  ->  Seq Scan on profile_master  (cost=4458.25..31340.38 rows=359125 width=0) (actual time=1055.496..4637.908 rows=470386 loops=1)
+        Filter: (NOT (hashed subplan))
+        SubPlan
+          ->  Seq Scan on account_profiles  (cost=0.00..3817.80 rows=256180 width=4) (actual time=0.061..507.811 rows=256180 loops=1)
+Total runtime: 5337.591 ms
+(6 rows)
+
+
+tradein_clients=# explain analyze SELECT  count(*) from general.profile_master where not exists 
+(select  profile_id from general.account_profiles where profile_id=general.profile_master.profile_id ) ;
+
+                                                                          QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------------
+Aggregate  (cost=1674981.97..1674981.97 rows=1 width=0) (actual time=14600.386..14600.387 rows=1 loops=1)
+  ->  Seq Scan on profile_master  (cost=0.00..1674084.16 rows=359125 width=0) (actual time=13.687..13815.798 rows=470386 loops=1)
+        Filter: (NOT (subplan))
+        SubPlan
+          ->  Index Scan using account_profiles_profile_id on account_profiles  (cost=0.00..4.59 rows=2 width=4) (actual time=0.013..0.013 rows=0 loops=718250)
+                Index Cond: (profile_id = $0)
+Total runtime: 14600.531 ms
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
+    
+
+

+  
+
+
+ + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 12:08:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D59A6D1B55C + for ; + Fri, 14 Nov 2003 16:08:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12108-02 + for ; + Fri, 14 Nov 2003 12:07:39 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A50AD1B50D + for ; + Fri, 14 Nov 2003 12:07:36 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 9DF361FAE; Fri, 14 Nov 2003 11:07:15 -0500 (EST) +To: Josh Berkus +Cc: Christopher Kings-Lynne , + PostgreSQL Performance +Subject: Re: Query question +From: Neil Conway +In-Reply-To: <200311122120.28882.josh@agliodbs.com> (Josh Berkus's message + of "Wed, 12 Nov 2003 21:20:28 -0800") +References: <3FB303E9.20903@familyhealth.com.au> + <200311122120.28882.josh@agliodbs.com> +Date: Fri, 14 Nov 2003 11:07:15 -0500 +Message-ID: <87llqjj5n0.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/112 +X-Sequence-Number: 4672 + +Josh Berkus writes: +> The only thing you're adding to the query is a second SORT step, so it +> shouldn't require any more time/memory than the query's first SORT +> did. + +Interesting -- I wonder if it would be possible for the optimizer to +detect this and avoid the redundant inner sort ... (/me muses to +himself) + +-Neil + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 12:38:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A5731D1B535 + for ; + Fri, 14 Nov 2003 16:38:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18783-06 + for ; + Fri, 14 Nov 2003 12:37:53 -0400 (AST) +Received: from email04.aon.at (WARSL402PIP2.highway.telekom.at [195.3.96.74]) + by svr1.postgresql.org (Postfix) with SMTP id CDD2AD1B50D + for ; + Fri, 14 Nov 2003 12:37:50 -0400 (AST) +Received: (qmail 313860 invoked from network); 14 Nov 2003 16:37:43 -0000 +Received: from m170p014.dipool.highway.telekom.at (HELO cantor) + ([62.46.11.46]) (envelope-sender ) + by qmail7rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 14 Nov 2003 16:37:43 -0000 +From: Manfred Koizar +To: +Cc: "Tom Lane" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Seeking help with a query that takes too long +Date: Fri, 14 Nov 2003 17:35:44 +0100 +Message-ID: +References: + +In-Reply-To: +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/113 +X-Sequence-Number: 4673 + +On Fri, 14 Nov 2003 11:00:38 -0500, "Nick Fankhauser" + wrote: +>Good question... I've never used clustering in PostgreSQL before, so I'm +>unsure. I presume this is like clustering in Oracle where the table is +>ordered to match the index? + +Yes, something like that. With the exception that Postgres looses the +clustered status, while you INSERT and UPDATE tuples. So you have to +re-CLUSTER from time to time. Look at pg_stats.correlation to see, if +its necessary. + +> Is there a way to flush out +>the cache in a testing situation like this in order to start from a +>consistent base? + +To flush Postgres shared buffers: + SELECT count(*) FROM another_large_table; + +To flush your database pages from the OS cache: + tar cf /dev/null /some/large/directory + +And run each of your tests at least twice to get a feeling how caching +affects your specific queries. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Nov 14 12:41:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 850F1D1B50C + for ; + Fri, 14 Nov 2003 16:41:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 18783-07 + for ; + Fri, 14 Nov 2003 12:40:55 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 58C84D1B535 + for ; + Fri, 14 Nov 2003 12:40:54 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAEGeh19026649; + Fri, 14 Nov 2003 11:40:43 -0500 (EST) +To: Neil Conway +Cc: Josh Berkus , + Christopher Kings-Lynne , + PostgreSQL Performance +Subject: Re: Query question +In-reply-to: <87llqjj5n0.fsf@mailbox.samurai.com> +References: <3FB303E9.20903@familyhealth.com.au> + <200311122120.28882.josh@agliodbs.com> + <87llqjj5n0.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Fri, 14 Nov 2003 11:07:15 -0500" +Date: Fri, 14 Nov 2003 11:40:42 -0500 +Message-ID: <26648.1068828042@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/114 +X-Sequence-Number: 4674 + +Neil Conway writes: +> Interesting -- I wonder if it would be possible for the optimizer to +> detect this and avoid the redundant inner sort ... (/me muses to +> himself) + +I think the ability to generate two sort steps is a feature, not a bug. +This has been often requested in connection with user-defined +aggregates, where it's handy to be able to control the order of arrival +of rows at the aggregation function. If the optimizer suppressed the +inner sort then we'd lose that ability. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 14 13:44:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D6801D1B53F + for ; + Fri, 14 Nov 2003 17:43:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29579-04 + for ; + Fri, 14 Nov 2003 13:43:27 -0400 (AST) +Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D01DD1B51C + for ; + Fri, 14 Nov 2003 13:43:26 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAEHhSP5003241; + Fri, 14 Nov 2003 19:43:28 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAEHhSZd003239; + Fri, 14 Nov 2003 19:43:28 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: Help with count(*) +From: Hannu Krosing +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: <200311141251.38786.mallah@trade-india.com> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1068831807.2540.44.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Fri, 14 Nov 2003 19:43:27 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/115 +X-Sequence-Number: 4675 + +Christopher Browne kirjutas R, 14.11.2003 kell 16:13: +> Martha Stewart called it a Good Thing when mallah@trade-india.com (Rajesh Kumar Mallah) wrote: +> > INFO: "profiles": found 0 removable, 369195 nonremovable row versions in 43423 pages +> > DETAIL: 246130 dead row versions cannot be removed yet. +> > Nonremovable row versions range from 136 to 2036 bytes long. +> +> It seems as though you have a transaction open that is holding onto a +> whole lot of old rows. +> +> I have seen this happen somewhat-invisibly when a JDBC connection +> manager opens transactions for each connection, and then no processing +> happens to use those connections for a long time. The open +> transactions prevent vacuums from doing any good... + +Can't the backend be made to delay the "real" start of transaction until +the first query gets executed ? + +------------ +Hannu + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 14:51:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A0F3D1B518 + for ; + Fri, 14 Nov 2003 18:51:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42993-08 + for ; + Fri, 14 Nov 2003 14:51:15 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A991AD1B502 + for ; + Fri, 14 Nov 2003 14:51:13 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAEInx19003132; + Fri, 14 Nov 2003 13:49:59 -0500 (EST) +To: Hannu Krosing +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +In-reply-to: <1068831807.2540.44.camel@fuji.krosing.net> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> +Comments: In-reply-to Hannu Krosing + message dated "Fri, 14 Nov 2003 19:43:27 +0200" +Date: Fri, 14 Nov 2003 13:49:59 -0500 +Message-ID: <3131.1068835799@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/116 +X-Sequence-Number: 4676 + +Hannu Krosing writes: +> Christopher Browne kirjutas R, 14.11.2003 kell 16:13: +>> I have seen this happen somewhat-invisibly when a JDBC connection +>> manager opens transactions for each connection, and then no processing +>> happens to use those connections for a long time. The open +>> transactions prevent vacuums from doing any good... + +> Can't the backend be made to delay the "real" start of transaction until +> the first query gets executed ? + +That is on the TODO list. I looked at it briefly towards the end of the +7.4 development cycle, and decided that it was nontrivial and I didn't +have time to make it happen before beta started. I don't recall why it +didn't seem trivial. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 14 15:49:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0649ED1B4E1 + for ; + Fri, 14 Nov 2003 19:49:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53927-01 + for ; + Fri, 14 Nov 2003 15:49:01 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 47F45D1B4E4 + for ; + Fri, 14 Nov 2003 15:49:00 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAEJn0Nu046147 + for ; Fri, 14 Nov 2003 19:49:00 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAEJKfCQ041683 + for pgsql-performance@postgresql.org; Fri, 14 Nov 2003 19:20:41 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help with count(*) +Date: Fri, 14 Nov 2003 14:16:56 -0500 +Organization: cbbrowne Computing Inc +Lines: 35 +Message-ID: +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:vI2O3yzZC8Gyhd5OMVqxPwSIIdc= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/118 +X-Sequence-Number: 4678 + +After a long battle with technology, hannu@tm.ee (Hannu Krosing), an earthling, wrote: +> Christopher Browne kirjutas R, 14.11.2003 kell 16:13: +>> Martha Stewart called it a Good Thing when mallah@trade-india.com (Rajesh Kumar Mallah) wrote: +>> > INFO: "profiles": found 0 removable, 369195 nonremovable row versions in 43423 pages +>> > DETAIL: 246130 dead row versions cannot be removed yet. +>> > Nonremovable row versions range from 136 to 2036 bytes long. +>> +>> It seems as though you have a transaction open that is holding onto a +>> whole lot of old rows. +>> +>> I have seen this happen somewhat-invisibly when a JDBC connection +>> manager opens transactions for each connection, and then no processing +>> happens to use those connections for a long time. The open +>> transactions prevent vacuums from doing any good... +> +> Can't the backend be made to delay the "real" start of transaction until +> the first query gets executed ? + +One would hope so. Some time when I have the Round Tuits, I ought to +take a browse of the connection pool code to notice if there's +anything to notice. + +The thing that I keep imagining would be a slick idea would be to have +a thread periodically go through once for however many connections the +pool permits and fire a short transaction through every +otherwise-unoccupied connection in the pool, in effect, doing a sort +of "vacuum" of the connections. I don't get very favorable reactions +when I suggest that, though... +-- +(reverse (concatenate 'string "ac.notelrac.teneerf" "@" "454aa")) +http://cbbrowne.com/info/sgml.html +Rules of the Evil Overlord #80. "If my weakest troops fail to +eliminate a hero, I will send out my best troops instead of wasting +time with progressively stronger ones as he gets closer and closer to +my fortress." + +From pgsql-performance-owner@postgresql.org Thu Nov 13 15:27:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 25493D1B4E1 + for ; + Thu, 13 Nov 2003 19:27:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16910-01 + for ; + Thu, 13 Nov 2003 15:27:28 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 8A329D1B551 + for ; + Thu, 13 Nov 2003 15:27:26 -0400 (AST) +Received: (qmail 10415 invoked from network); 13 Nov 2003 19:28:33 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 13 Nov 2003 19:28:33 -0000 +Message-ID: <3FB52CAD.9070404@trade-india.com> +Date: Sat, 15 Nov 2003 00:57:41 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? +References: <200311131323.39762.mallah@trade-india.com> + <26331.1068736791@sss.pgh.pa.us> +In-Reply-To: <26331.1068736791@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------070600040606020801020106" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/98 +X-Sequence-Number: 4658 + +This is a multi-part message in MIME format. +--------------070600040606020801020106 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>Rajesh Kumar Mallah writes: +> +> +>>NOT EXISTS is taking almost double time than NOT IN . +>>I know IN has been optimised in 7.4 but is anything +>>wrong with the NOT EXISTS? +>> +>> +> +>That's the expected behavior in 7.4. EXISTS in the style you are using +>it effectively forces a nestloop-with-inner-indexscan implementation. +>As of 7.4, IN can do that, but it can do several other things too, +>including the hash-type plan you have here. So assuming that the +>planner chooses the right plan choice (not always a given ;-)) +> + +>IN should be as fast or faster than EXISTS in *all* *cases.* +> + +Not in this case :) , did i miss something silly? + +tradein_clients=# explain SELECT count(*) from user_accounts where +email is not null and email not in + (select email from profile_master where email is not null) ; + QUERY PLAN +-------------------------------------------------------------------------------------- + Aggregate (cost=*9587726326.93..9587726326.93* rows=1 width=0) + -> Seq Scan on user_accounts (cost=0.00..9587725473.40 rows=341412 +width=0) + Filter: ((email IS NOT NULL) AND (NOT (subplan))) + SubPlan + -> Seq Scan on profile_master (cost=0.00..25132.24 +rows=674633 width=25) + Filter: (email IS NOT NULL) +(6 rows) + +*The query above does not return* + +tradein_clients=# explain analyze SELECT count(*) from user_accounts +where email is not null and +not exists (select email from profile_master where +email=user_accounts.email) ; + +QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=2850847.55..2850847.55 rows=1 width=0) (actual +time=34075.100..34075.101 rows=1 loops=1) + -> Seq Scan on user_accounts (cost=0.00..2849994.02 rows=341412 +width=0) (actual time=8.066..34066.329 rows=3882 loops=1) + Filter: ((email IS NOT NULL) AND (NOT (subplan))) + SubPlan + -> Index Scan using profile_master_email on profile_master +(cost=0.00..35.60 rows=9 width=25) (actual time=0.044..0.044 rows=1 +loops=686716) + Index Cond: ((email)::text = ($0)::text) + Total runtime: 34075.213 ms +(7 rows) + +tradein_clients=# + + +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> + + +-- + +Rajesh Kumar Mallah, +Infocom Network Limited, New Delhi +phone: +91(11)6152172 (221) (L) ,9811255597 (M) + +Visit http://www.trade-india.com , +India's Leading B2B eMarketplace. + + +--------------070600040606020801020106 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Tom Lane wrote:
+
+
Rajesh Kumar Mallah <mallah@trade-india.com> writes:
+  
+
+
NOT EXISTS is taking almost double time than NOT IN .
+I know IN has been optimised in 7.4 but is anything 
+wrong with the NOT EXISTS?
+    
+
+

+That's the expected behavior in 7.4.  EXISTS in the style you are using
+it effectively forces a nestloop-with-inner-indexscan implementation.
+As of 7.4, IN can do that, but it can do several other things too,
+including the hash-type plan you have here.  So assuming that the
+planner chooses the right plan choice (not always a given ;-))
+
+
+
+
IN should be as fast or faster than EXISTS in all cases.
+
+
+Not in this case :) , did i miss something silly?
+
+tradein_clients=# explain  SELECT count(*) +from user_accounts where email is not null and email not in
+ (select email from profile_master where email is not null) ;
+                                      QUERY PLAN
+--------------------------------------------------------------------------------------
+ Aggregate  (cost=9587726326.93..9587726326.93 +rows=1 width=0)
+   ->  Seq Scan on user_accounts  (cost=0.00..9587725473.40 +rows=341412 width=0)
+         Filter: ((email IS NOT NULL) AND (NOT (subplan)))
+         SubPlan
+           ->  Seq Scan on profile_master  (cost=0.00..25132.24 +rows=674633 width=25)
+                 Filter: (email IS NOT NULL)
+(6 rows)

+
+The query above does not return
+
+tradein_clients=# explain analyze SELECT count(*) +from user_accounts where email is not null and
+not exists (select email from profile_master where +email=user_accounts.email) ;
+                                                                        +QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------------------------------
+ Aggregate  (cost=2850847.55..2850847.55 rows=1 width=0) (actual +time=34075.100..34075.101 rows=1 loops=1)
+   ->  Seq Scan on user_accounts  (cost=0.00..2849994.02 rows=341412 +width=0) (actual time=8.066..34066.329 rows=3882 loops=1)
+         Filter: ((email IS NOT NULL) AND (NOT (subplan)))
+         SubPlan
+           ->  Index Scan using profile_master_email on +profile_master  (cost=0.00..35.60 rows=9 width=25) (actual +time=0.044..0.044 rows=1 loops=686716)
+                 Index Cond: ((email)::text = ($0)::text)
+ Total runtime: 34075.213 ms
+(7 rows)
+

+tradein_clients=#
+

+
+
+
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+  
+
+
+
+
-- 
+
+Rajesh Kumar Mallah,
+Infocom Network Limited, New Delhi
+phone: +91(11)6152172 (221) (L) ,9811255597 (M)
+
+Visit http://www.trade-india.com ,
+India's Leading B2B eMarketplace.
+
+ + + +--------------070600040606020801020106-- + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 15:41:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 26C03D1B4E4 + for ; + Fri, 14 Nov 2003 19:41:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51358-10 + for ; + Fri, 14 Nov 2003 15:40:30 -0400 (AST) +Received: from jwilhelm.ofsloans.com (unknown [209.180.142.225]) + by svr1.postgresql.org (Postfix) with ESMTP id 78FE8D1B50B + for ; + Fri, 14 Nov 2003 15:40:28 -0400 (AST) +Message-ID: <3FB52FA7.8060508@lashell.net> +Date: Fri, 14 Nov 2003 12:40:23 -0700 +From: Will LaShell +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hannu Krosing +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> +In-Reply-To: <1068831807.2540.44.camel@fuji.krosing.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/117 +X-Sequence-Number: 4677 + +Hannu Krosing wrote: + +>Christopher Browne kirjutas R, 14.11.2003 kell 16:13: +> +> +>>Martha Stewart called it a Good Thing when mallah@trade-india.com (Rajesh Kumar Mallah) wrote: +>> +>> +>>>INFO: "profiles": found 0 removable, 369195 nonremovable row versions in 43423 pages +>>>DETAIL: 246130 dead row versions cannot be removed yet. +>>>Nonremovable row versions range from 136 to 2036 bytes long. +>>> +>>> +>>It seems as though you have a transaction open that is holding onto a +>>whole lot of old rows. +>> +>>I have seen this happen somewhat-invisibly when a JDBC connection +>>manager opens transactions for each connection, and then no processing +>>happens to use those connections for a long time. The open +>>transactions prevent vacuums from doing any good... +>> +>> +> +>Can't the backend be made to delay the "real" start of transaction until +>the first query gets executed ? +> +> + +That seems counter intuitive doesn't it? Why write more code in the +server when the client is the thing that has the problem? + +Will + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 16:39:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1149CD1B4EB + for ; + Fri, 14 Nov 2003 20:39:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62492-03 + for ; + Fri, 14 Nov 2003 16:38:53 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B374AD1B4E1 + for ; + Fri, 14 Nov 2003 16:38:47 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAEKck19004988; + Fri, 14 Nov 2003 15:38:47 -0500 (EST) +To: Will LaShell +Cc: Hannu Krosing , Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +In-reply-to: <3FB52FA7.8060508@lashell.net> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> +Comments: In-reply-to Will LaShell + message dated "Fri, 14 Nov 2003 12:40:23 -0700" +Date: Fri, 14 Nov 2003 15:38:46 -0500 +Message-ID: <4987.1068842326@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/119 +X-Sequence-Number: 4679 + +Will LaShell writes: +> Hannu Krosing wrote: +>> Can't the backend be made to delay the "real" start of transaction until +>> the first query gets executed ? + +> That seems counter intuitive doesn't it? Why write more code in the +> server when the client is the thing that has the problem? + +Because there are a lot of clients with the same problem :-( + +A more principled argument is that we already postpone the setting of +the transaction snapshot until the first query arrives within the +transaction. In a very real sense, the setting of the snapshot *is* +the start of the transaction. So it would make sense if incidental +stuff like VACUUM also thought that the transaction hadn't started +until the first query arrives. (I believe the previous discussion +also agreed that we wanted to postpone the freezing of now(), which +currently also happens at BEGIN rather than the first command after +BEGIN.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 14 16:59:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4278D1B4ED + for ; + Fri, 14 Nov 2003 20:59:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55314-10 + for ; + Fri, 14 Nov 2003 16:59:16 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A1D5FD1B4EB + for ; + Fri, 14 Nov 2003 16:59:14 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAEKxE19005188; + Fri, 14 Nov 2003 15:59:14 -0500 (EST) +To: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +Cc: pgsql-performance@postgresql.org +Subject: Re: constant vs function param differs in performance +In-reply-to: <01a601c3aac1$281e72c0$0403a8c0@fejleszt4> +References: <01a601c3aac1$281e72c0$0403a8c0@fejleszt4> +Comments: In-reply-to "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" + message dated "Fri, 14 Nov 2003 16:08:27 +0100" +Date: Fri, 14 Nov 2003 15:59:14 -0500 +Message-ID: <5187.1068843554@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/120 +X-Sequence-Number: 4680 + +"=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: +> I have two SQL function that produce different times and I can't understand +> why. + +The planner often produces different plans when there are constants in +WHERE clauses than when there are variables, because it can get more +accurate ideas of how many rows will be retrieved. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 14 17:28:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3781BD1B4ED + for ; + Fri, 14 Nov 2003 21:27:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72153-01 + for ; + Fri, 14 Nov 2003 17:27:30 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DCD8D1B51A + for ; + Fri, 14 Nov 2003 17:27:28 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hAELRR5f030427; Fri, 14 Nov 2003 16:27:29 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Pgsql-Performance@Postgresql. Org" +Cc: "Ray Ontko" +Subject: n_distinct way off, but following a pattern. +Date: Fri, 14 Nov 2003 16:27:16 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/121 +X-Sequence-Number: 4681 + +Hi- + +I'm seeing estimates for n_distinct that are way off for a large table +(8,700,000 rows). They get better by setting the stats target higher, but +are still off by a factor of 10 with the stats set to 1000. I've noticed and +reported a similar pattern before on another table. Because this follows the +same very consistent pattern, I figured it was worth reporting again. This +looks more like a bug than randomness. If the poor result was simply due to +having a small sample to work from, the estimates should be all over the +map, but these are consistently low, and vary in almost exact inverse +proportion to the stats target: + + run 1: run2: run3: +n_distinct estimate, statistics = 10: 3168 3187 3212 +n_distinct estimate, statistics = 100: 23828 24059 23615 +n_distinct estimate, statistics = 1000: 194690 194516 194081 +Actual distinct values: 3340724 + +Or to put it another way, if you were to take the estimate from analyze, +divide by the stats target and multiply by 10000, the result would be pretty +close to exact. (Within a factor of 2, which ought to be plenty close for +planning purposes.) + +I'm running version 7.3.2 + +Any thoughts from folks familiar with this part of the source code? + +Regards, + -Nick + +PS- +Here's a log of the session that I got this from. + +alpha=# select count(distinct actor_id) from actor_case_assignment; +-[ RECORD 1 ]-- +count | 3340724 +alpha=# analyze; +ANALYZE +alpha=# SELECT * FROM pg_stats +alpha-# WHERE tablename='actor_case_assignment' AND attname='actor_id'; +-[ RECORD +1 ]-----+------------------------------------------------------------------- +---------------------------------------------------------------------------- +---------------- +schemaname | public +tablename | actor_case_assignment +attname | actor_id +null_frac | 0 +avg_width | 16 +n_distinct | 3168 +most_common_vals | +{18105XS,18115XS,18106XS,18113JD02,18115JD02,18106J27,18113XS,18113A10656,18 +115LST,18108XS} +most_common_freqs | +{0.0206667,0.0206667,0.0196667,0.019,0.0176667,0.0173333,0.0163333,0.015,0.0 +14,0.0136667} +histogram_bounds | +{18067A000-07P,18067PD397SC1574-1,18105LBPD,18106A2119-49,18106PD399IF845-1, +18108A03068-20,18108LECS207,18108PTW03737278-2,18111A19788-77,18115A50420,18 +115XC} +correlation | 0.876795 +alpha=# +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 100; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# SELECT * FROM pg_stats +alpha-# WHERE tablename='actor_case_assignment' AND attname='actor_id'; +-[ RECORD 1 ] +
+schemaname | public +tablename | actor_case_assignment +attname | actor_id +null_frac | 0 +avg_width | 17 +n_distinct | 23828 +most_common_vals | {18115XS,18113JD02,18106XS,1.... + +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 1000; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# SELECT * FROM pg_stats +alpha-# WHERE tablename='actor_case_assignment' AND attname='actor_id'; +-[ RECORD 1 ]----- +
+schemaname | public +tablename | actor_case_assignment +attname | actor_id +null_frac | 0 +avg_width | 16 +n_distinct | 194690 +most_common_vals | {18106XS,18115XS,18115... + + +alpha=# \x +Expanded display is off. +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 10; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment and attname='actor_id'; +alpha'# '; +ERROR: parser: parse error at or near "actor_id" at character 85 +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 3187 +(1 row) + +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 10; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 3212 +(1 row) + +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 100; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 24059 +(1 row) + +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 100; +ALTER TABLE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 23615 +(1 row) + +alpha=# alter table actor_case_assignment alter column actor_id set +statistics 1000; +ALTER TABLE +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 194516 +(1 row) + +alpha=# analyze actor_case_assignment; +ANALYZE +alpha=# select n_distinct from pg_stats where +tablename='actor_case_assignment' and attname='actor_id'; + n_distinct +------------ + 194081 +(1 row) + +alpha=# + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 17:30:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75140D1B563 + for ; + Fri, 14 Nov 2003 21:30:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64706-06 + for ; + Fri, 14 Nov 2003 17:30:16 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E473D1B570 + for ; + Fri, 14 Nov 2003 17:30:14 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AKlWC-000711-00 + for ; Fri, 14 Nov 2003 16:30:16 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 0731BCBB8; Fri, 14 Nov 2003 16:30:16 -0500 (EST) +Date: Fri, 14 Nov 2003 16:30:16 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +Message-ID: <20031114213015.GT28153@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/122 +X-Sequence-Number: 4682 + +On Fri, Nov 14, 2003 at 02:16:56PM -0500, Christopher Browne wrote: +> otherwise-unoccupied connection in the pool, in effect, doing a sort +> of "vacuum" of the connections. I don't get very favorable reactions +> when I suggest that, though... + +Because it's a kludge on top of another kludge, perhaps? ;-) This +needs to be fixed properly, not through an ungraceful series of +workarounds. + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 18:03:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EFBCD1B4F2 + for ; + Fri, 14 Nov 2003 22:03:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73031-05 + for ; + Fri, 14 Nov 2003 18:02:39 -0400 (AST) +Received: from web80210.mail.yahoo.com (web80210.mail.yahoo.com + [66.218.79.45]) + by svr1.postgresql.org (Postfix) with SMTP id 737EBD1B4E4 + for ; + Fri, 14 Nov 2003 18:02:36 -0400 (AST) +Message-ID: <20031114220238.87764.qmail@web80210.mail.yahoo.com> +Received: from [199.169.240.132] by web80210.mail.yahoo.com via HTTP; + Fri, 14 Nov 2003 14:02:38 PST +Date: Fri, 14 Nov 2003 14:02:38 -0800 (PST) +From: George Essig +Subject: Re: INSERT extremely slow with large data sets (fwd) +To: Slavisa Garic , + pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/123 +X-Sequence-Number: 4683 + +Slavisa Garic wrote: + +> Hi Everyone, + +> I am using PostgreSQL 7.3.2 and have used earlier versions (7.1.x +> onwards) +> and with all of them I noticed same problem with INSERTs when there is +> a +> large data set. Just to so you guys can compare time it takes to insert +> one row into a table when there are only few rows present and when +> there +> are thousands: + +Try running VACUUM ANALYZE periodically during inserts. I found this to help. + +George Essig + + +From pgsql-novice-owner@postgresql.org Fri Nov 14 18:08:01 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1CCC0D1B53F; Fri, 14 Nov 2003 22:07:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72910-07; Fri, 14 Nov 2003 18:07:28 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id 04109D1B4E4; Fri, 14 Nov 2003 18:07:25 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hAEM7QB00739; + Fri, 14 Nov 2003 16:07:26 -0600 +Received: from 134.129.92.208 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Fri, 14 Nov 2003 16:07:26 -0600 (CST) +Message-ID: <1710.134.129.92.208.1068847646.squirrel@webmail.ndsu.nodak.edu> +Date: Fri, 14 Nov 2003 16:07:26 -0600 (CST) +Subject: Re: Error in transaction processing +From: +To: , +X-Priority: 3 +Importance: Normal +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/107 +X-Sequence-Number: 8810 + +When I execute a transaction using embedded sql statements in a c program, +I get the error, + +Error in transaction processing. I could see from the documentation that +it means, "Postgres signalled to us that we cannot start, commit or +rollback the transaction" + +I don't find any mistakes in the transaction statements. + +What can I do to correct this error? + +Your response would be very much appreciated. + +Thanks and Regards, + +Radha + + + + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 18:13:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 35FBFD1B4E4 + for ; + Fri, 14 Nov 2003 22:13:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81185-01 + for ; + Fri, 14 Nov 2003 18:12:36 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 7233FD1B561 + for ; + Fri, 14 Nov 2003 18:12:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAEMCS19005810; + Fri, 14 Nov 2003 17:12:28 -0500 (EST) +To: nickf@ontko.com +Cc: "Pgsql-Performance@Postgresql. Org" , + "Ray Ontko" +Subject: Re: n_distinct way off, but following a pattern. +In-reply-to: +References: +Comments: In-reply-to "Nick Fankhauser" + message dated "Fri, 14 Nov 2003 16:27:16 -0500" +Date: Fri, 14 Nov 2003 17:12:27 -0500 +Message-ID: <5809.1068847947@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/125 +X-Sequence-Number: 4685 + +"Nick Fankhauser" writes: +> I'm seeing estimates for n_distinct that are way off for a large table + +Estimating n_distinct from a small sample is inherently a hard problem. +I'm not surprised that the estimates would get better as the sample size +increases. But maybe we can do better. The method we are currently +using is this: + + /*---------- + * Estimate the number of distinct values using the estimator + * proposed by Haas and Stokes in IBM Research Report RJ 10025: + * n*d / (n - f1 + f1*n/N) + * where f1 is the number of distinct values that occurred + * exactly once in our sample of n rows (from a total of N), + * and d is the total number of distinct values in the sample. + * This is their Duj1 estimator; the other estimators they + * recommend are considerably more complex, and are numerically + * very unstable when n is much smaller than N. + +It would be interesting to see exactly what inputs are going into this +equation. Do you feel like adding some debug printouts into this code? +Or just looking at the variables with a debugger? In 7.3 it's about +line 1060 in src/backend/commands/analyze.c. + +BTW, this is already our second try at this problem, the original 7.2 +equation didn't last long at all ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 14 21:21:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EEFC8D1B4E1 + for ; + Sat, 15 Nov 2003 01:21:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02155-08 + for ; + Fri, 14 Nov 2003 21:21:07 -0400 (AST) +Received: from ALPHA9.ITS.MONASH.EDU.AU (alpha9.its.monash.edu.au + [130.194.1.9]) + by svr1.postgresql.org (Postfix) with ESMTP id E09D4D1B4F2 + for ; + Fri, 14 Nov 2003 21:21:03 -0400 (AST) +Received: from localhost ([130.194.13.84]) by vaxh.its.monash.edu.au + (PMDF V5.2-31 #39306) + with ESMTP id <01L326TBENQ68ZRL0J@vaxh.its.monash.edu.au> for + pgsql-performance@postgresql.org; Sat, 15 Nov 2003 12:20:21 +1100 +Received: from blammo.its.monash.edu.au + (localhost.its.monash.edu.au [127.0.0.1]) by localhost (Postfix) + with ESMTP id 8C93239C003; Sat, 15 Nov 2003 12:20:21 +1100 (EST) +Received: from bruce.csse.monash.edu.au + (bruce.csse.monash.edu.au [130.194.64.3]) by blammo.its.monash.edu.au + (Postfix) with ESMTP id 7E2162DC002; + Sat, 15 Nov 2003 12:20:21 +1100 (EST) +Received: from bruce.csse.monash.edu.au (localhost [127.0.0.1]) + by bruce.csse.monash.edu.au (8.12.8+Sun/8.12.8) with ESMTP id + hAF1KK8x013015; Sat, 15 Nov 2003 12:20:20 +1100 (EST) +Received: from localhost (sgaric@localhost) by bruce.csse.monash.edu.au + (8.12.8+Sun/8.12.2/Submit) with ESMTP id hAF1KKKr013012; Sat, + 15 Nov 2003 12:20:20 +1100 (EST) +Date: Sat, 15 Nov 2003 12:20:20 +1100 (EST) +From: Slavisa Garic +Subject: Re: INSERT extremely slow with large data sets (fwd) +In-reply-to: <20031114220238.87764.qmail@web80210.mail.yahoo.com> +To: George Essig +Cc: Slavisa Garic , + pgsql-performance@postgresql.org +Message-id: + +MIME-version: 1.0 +Content-type: TEXT/PLAIN; charset=US-ASCII +Content-transfer-encoding: 7BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/126 +X-Sequence-Number: 4686 + +Does VACUUM ANALYZE help with the analysis or it also speeds up the +process. I know i could try that before I ask but experiment is running +now and I am too curious to wait :), + +Anyway thanks for the hint, +Slavisa + +On Fri, 14 Nov 2003, George Essig wrote: + +> Slavisa Garic wrote: +> +> > Hi Everyone, +> +> > I am using PostgreSQL 7.3.2 and have used earlier versions (7.1.x +> > onwards) +> > and with all of them I noticed same problem with INSERTs when there is +> > a +> > large data set. Just to so you guys can compare time it takes to insert +> > one row into a table when there are only few rows present and when +> > there +> > are thousands: +> +> Try running VACUUM ANALYZE periodically during inserts. I found this to help. +> +> George Essig +> +> + + +From pgsql-performance-owner@postgresql.org Fri Nov 14 23:37:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C2A2CD1B4ED + for ; + Sat, 15 Nov 2003 03:37:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31805-05 + for ; + Fri, 14 Nov 2003 23:36:43 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id E90B5D1B4EB + for ; + Fri, 14 Nov 2003 23:36:38 -0400 (AST) +Received: from [203.221.246.150] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #1) + id 1AKrEO-0007bJ-00; Sat, 15 Nov 2003 14:36:17 +1100 +Message-ID: <3FB59F12.2090704@familyhealth.com.au> +Date: Sat, 15 Nov 2003 11:35:46 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Neil Conway +Cc: Josh Berkus , + PostgreSQL Performance +Subject: Re: Query question +References: <3FB303E9.20903@familyhealth.com.au> + <200311122120.28882.josh@agliodbs.com> + <87llqjj5n0.fsf@mailbox.samurai.com> +In-Reply-To: <87llqjj5n0.fsf@mailbox.samurai.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/127 +X-Sequence-Number: 4687 + +>>The only thing you're adding to the query is a second SORT step, so it +>>shouldn't require any more time/memory than the query's first SORT +>>did. +> +> +> Interesting -- I wonder if it would be possible for the optimizer to +> detect this and avoid the redundant inner sort ... (/me muses to +> himself) + +That's somethign I've wondered myself as well. Also - I wonder if the +optimiser could be made smart enough to push down the outer LIMIT and +OFFSET clauses into the subquery. + +Chris + + + +From pgsql-performance-owner@postgresql.org Sat Nov 15 06:21:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9BD1D1B507 + for ; + Sat, 15 Nov 2003 10:21:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94381-05 + for ; + Sat, 15 Nov 2003 06:21:19 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id BBA1FD1B502 + for ; + Sat, 15 Nov 2003 06:21:13 -0400 (AST) +Received: from zigo.dhs.org (zigo [127.0.0.1]) + by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id hAFAL9L2013906; + Sat, 15 Nov 2003 11:21:09 +0100 +Received: from localhost (db@localhost) + by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id hAFAL9MU013902; + Sat, 15 Nov 2003 11:21:09 +0100 +Date: Sat, 15 Nov 2003 11:21:09 +0100 (CET) +From: Dennis Bjorklund +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +In-Reply-To: <4987.1068842326@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/128 +X-Sequence-Number: 4688 + +On Fri, 14 Nov 2003, Tom Lane wrote: + +> I believe the previous discussion also agreed that we wanted to postpone +> the freezing of now(), which currently also happens at BEGIN rather than +> the first command after BEGIN. + +Or should that happen at the first call to now()? + +/me should ge back and try to find this previous discussion. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Sat Nov 15 09:14:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 49D28D1B50E + for ; + Sat, 15 Nov 2003 13:14:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12835-08 + for ; + Sat, 15 Nov 2003 09:13:38 -0400 (AST) +Received: from web80208.mail.yahoo.com (web80208.mail.yahoo.com + [66.218.79.43]) + by svr1.postgresql.org (Postfix) with SMTP id 36692D1B51A + for ; + Sat, 15 Nov 2003 09:13:35 -0400 (AST) +Message-ID: <20031115131338.90329.qmail@web80208.mail.yahoo.com> +Received: from [65.69.56.225] by web80208.mail.yahoo.com via HTTP; + Sat, 15 Nov 2003 05:13:38 PST +Date: Sat, 15 Nov 2003 05:13:38 -0800 (PST) +From: George Essig +Subject: Re: INSERT extremely slow with large data sets (fwd) +To: Slavisa Garic +Cc: Slavisa Garic , + pgsql-performance@postgresql.org +In-Reply-To: + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/129 +X-Sequence-Number: 4689 + + +--- Slavisa Garic wrote: +> Does VACUUM ANALYZE help with the analysis or it also speeds up the +> process. I know i could try that before I ask but experiment is running +> now and I am too curious to wait :), +> +> Anyway thanks for the hint, +> Slavisa +> + +VACUUM ANALYZE will reclaim disk space and update statistics used by the optimizer to help execute +queries faster. This could speed up your inserts. See +http://www.postgresql.org/docs/7.3/static/sql-vacuum.html. + +George Essig + +From pgsql-novice-owner@postgresql.org Sat Nov 15 10:53:18 2003 +X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1174AD1B51A; Sat, 15 Nov 2003 14:53:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38798-01; Sat, 15 Nov 2003 10:52:48 -0400 (AST) +Received: from smtp1.nodak.edu (smtp1.NoDak.edu [134.129.111.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id BF86BD1B4FC; Sat, 15 Nov 2003 10:52:42 -0400 (AST) +Received: from ndsu.nodak.edu (webmail1.ndsu.NoDak.edu [134.129.111.141]) + by smtp1.nodak.edu (8.11.6/8.11.6) with SMTP id hAFEqkB24187; + Sat, 15 Nov 2003 08:52:46 -0600 +Received: from 134.129.110.64 (SquirrelMail authenticated user radha.manohar) + by webmail.ndsu.nodak.edu with HTTP; + Sat, 15 Nov 2003 08:52:45 -0600 (CST) +Message-ID: <3152.134.129.110.64.1068907965.squirrel@webmail.ndsu.nodak.edu> +Date: Sat, 15 Nov 2003 08:52:45 -0600 (CST) +Subject: Re: Error in transaction processing +From: +To: , +X-Priority: 3 +Importance: Normal +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_30, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200311/108 +X-Sequence-Number: 8811 + +When I execute a transaction using embedded sql statements in a c program, +I get the error, + +Error in transaction processing. I could see from the documentation that +it means, "Postgres signalled to us that we cannot start, commit or +rollback the transaction" + +I don't find any mistakes in the transaction statements. + +What can I do to correct this error? + +Your response would be very much appreciated. + +Thanks and Regards, + +Radha + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Nov 15 16:21:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EEE4D1C92F + for ; + Sat, 15 Nov 2003 20:21:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83894-09 + for ; + Sat, 15 Nov 2003 16:20:54 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 252F1D1C93C + for ; + Sat, 15 Nov 2003 16:20:53 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 7D7A61EB0; Sat, 15 Nov 2003 15:20:45 -0500 (EST) +To: Tom Lane +Cc: Will LaShell , Hannu Krosing , + Christopher Browne , pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +From: Neil Conway +In-Reply-To: <4987.1068842326@sss.pgh.pa.us> (Tom Lane's message of "Fri, 14 + Nov 2003 15:38:46 -0500") +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> +Date: Sat, 15 Nov 2003 15:20:43 -0500 +Message-ID: <87isllbcys.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/131 +X-Sequence-Number: 4691 + +Tom Lane writes: +> (I believe the previous discussion also agreed that we wanted to +> postpone the freezing of now(), which currently also happens at +> BEGIN rather than the first command after BEGIN.) + +That doesn't make sense to me: from a user's perspective, the "start +of the transaction" is when the BEGIN is issued, regardless of any +tricks we may play in the backend. + +Making now() return the time the current transaction started is +reasonably logical; making now() return "the time when the first +command after the BEGIN in the current transaction was issued" makes a +lot less sense to me. + +-Neil + + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 07:58:56 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FEC6D1D20B + for ; + Sun, 16 Nov 2003 11:58:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26209-09 + for ; + Sun, 16 Nov 2003 07:58:26 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F79CD1E1A5 + for ; + Sun, 16 Nov 2003 07:58:22 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAGBwDJC017704; + Sun, 16 Nov 2003 13:58:13 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAGBwAO2017702; + Sun, 16 Nov 2003 13:58:10 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: start of transaction (was: Re: [PERFORM] Help with count(*)) +From: Hannu Krosing +To: Neil Conway +Cc: Tom Lane , Will LaShell , + Christopher Browne , + "pgsql-hackers@postgresql.org" +In-Reply-To: <87isllbcys.fsf@mailbox.samurai.com> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> + <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1068983887.17671.10.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sun, 16 Nov 2003 13:58:08 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/838 +X-Sequence-Number: 47126 + +Redirected to -hackers + +Neil Conway kirjutas L, 15.11.2003 kell 22:20: +> Tom Lane writes: +> > (I believe the previous discussion also agreed that we wanted to +> > postpone the freezing of now(), which currently also happens at +> > BEGIN rather than the first command after BEGIN.) +> +> That doesn't make sense to me: from a user's perspective, the "start +> of the transaction" is when the BEGIN is issued, regardless of any +> tricks we may play in the backend. + +For me, the "start of transaction" is not about time, but about grouping +a set of statements into one. So making the exact moment of "start" be +the first statement that actually does something with data seems +perfectly reasonable. If you really need to preserve time, do "select +current_timestamp" and use the result. + +> Making now() return the time the current transaction started is +> reasonably logical; making now() return "the time when the first +> command after the BEGIN in the current transaction was issued" makes a +> lot less sense to me. + +for me "the time the current transactuion is started" == "the time when +the first command after the BEGIN in the current transaction was issued" +and thus I see no conflict here ;) + +Delaying the locking effects of transactions as long as possible can +increase performance overall, not just for pathological clients that sit +on idle open transactions. + +Probably the latest time we can start the transaction is ath the start +of executor step after the first statement in a transaction is planned +and optimized. + +--------------- +Hannu + + + +From pgsql-performance-owner@postgresql.org Sun Nov 16 09:53:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1F81D1C952 + for ; + Sun, 16 Nov 2003 13:53:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51875-02 + for ; + Sun, 16 Nov 2003 09:52:50 -0400 (AST) +Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net + [207.217.120.49]) + by svr1.postgresql.org (Postfix) with ESMTP id BCD36D1B536 + for ; + Sun, 16 Nov 2003 09:52:46 -0400 (AST) +Received: from 0-1pool116-139.nas15.indianapolis1.in.us.da.qwest.net + ([65.128.116.139] helo=nick) + by scaup.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1ALNKV-0000R4-00; Sun, 16 Nov 2003 05:52:44 -0800 +Reply-To: +From: "Nick Fankhauser" +To: "Tom Lane" +Cc: "Pgsql-Performance@Postgresql. Org" , + "Ray Ontko" +Subject: Re: n_distinct way off, but following a pattern. +Date: Sun, 16 Nov 2003 08:52:29 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <5809.1068847947@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/132 +X-Sequence-Number: 4692 + + + +> It would be interesting to see exactly what inputs are going into this +> equation. Do you feel like adding some debug printouts into this code? +> Or just looking at the variables with a debugger? In 7.3 it's about +> line 1060 in src/backend/commands/analyze.c. + +Tom- + +I don't really have time to follow up at this moment, but I think this would +be interesting to look into, so I'll plan to dig into it over the +Thanksgiving Holiday when I'll have a little time free to follow up on some +fun projects. Your pointers should let me get into it pretty quickly. + +In the meantime, I'll just set up a cron job that runs behind my nightly +analyze to put the correct numbers into pg_statistic on the tables that this +affects. + +Thanks- + -Nick + + + + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 10:50:58 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66033D1B563 + for ; + Sun, 16 Nov 2003 14:50:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59708-05 + for ; + Sun, 16 Nov 2003 10:50:24 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 35F88D1D20B + for ; + Sun, 16 Nov 2003 10:50:15 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAGEoB19026135; + Sun, 16 Nov 2003 09:50:11 -0500 (EST) +To: Hannu Krosing +Cc: Neil Conway , Will LaShell , + Christopher Browne , + "pgsql-hackers@postgresql.org" +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +In-reply-to: <1068983887.17671.10.camel@fuji.krosing.net> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> + <87isllbcys.fsf@mailbox.samurai.com> + <1068983887.17671.10.camel@fuji.krosing.net> +Comments: In-reply-to Hannu Krosing + message dated "Sun, 16 Nov 2003 13:58:08 +0200" +Date: Sun, 16 Nov 2003 09:50:11 -0500 +Message-ID: <26134.1068994211@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/840 +X-Sequence-Number: 47128 + +Hannu Krosing writes: +> Probably the latest time we can start the transaction is ath the start +> of executor step after the first statement in a transaction is planned +> and optimized. + +The transaction has to exist before it can take locks, so the above +would not fly. + +A complete example of what we have to think about is: + + BEGIN; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + LOCK TABLE foo; + UPDATE foo ... -- or in general a SELECT/UPDATE/INSERT/DELETE query + ... etc ... + +The transaction snapshot *must* be set at the time of the first query +(here, the UPDATE). It obviously can't be later, and it cannot be +earlier either, because in this sort of example you need the requested +locks to be taken before the snapshot is set. + +The transaction must be created (as observed by other backends, in +particular VACUUM) not later than the LOCK statement, else there is +nothing that can own the lock. In principle though, the effects of +BEGIN and perhaps SET could be strictly local to the current backend, +and only when we hit a LOCK or query do we create the transaction +externally. + +In practice the problem we observe is clients that issue BEGIN and then +go to sleep (typically because of poorly-designed autocommit behavior in +interface libraries). Postponing externally-visible creation of the +transaction to the first command after BEGIN would be enough to get +around the real-world issues, and it would not require code changes +nearly as extensive as trying to let other stuff like SET happen +"before" the transaction starts. + +There isn't any compelling implementation reason when to freeze the +value of now(). Reasonable options are + 1. at BEGIN (current behavior) + 2. at transaction's external creation + 3. at freezing of transaction snapshot +#1 and #2 are actually the same at the moment, but could be decoupled +as sketched above, in which case the behavior of #2 would effectively +become "at first command afte BEGIN". + +In the previous thread: +http://archives.postgresql.org/pgsql-hackers/2003-03/msg01178.php +I argued that now() should be frozen at the time of the transaction +snapshot, and I still think that that's a defensible behavior. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Nov 16 11:23:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D0CA6D1E1A3 + for ; + Sun, 16 Nov 2003 15:23:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61560-04 + for ; + Sun, 16 Nov 2003 11:22:46 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id BE0C6D1E19C + for ; + Sun, 16 Nov 2003 11:22:41 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAGFMh19026339; + Sun, 16 Nov 2003 10:22:44 -0500 (EST) +To: Neil Conway +Cc: Will LaShell , Hannu Krosing , + Christopher Browne , pgsql-performance@postgresql.org +Subject: Re: Help with count(*) +In-reply-to: <87isllbcys.fsf@mailbox.samurai.com> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> + <87isllbcys.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Sat, 15 Nov 2003 15:20:43 -0500" +Date: Sun, 16 Nov 2003 10:22:43 -0500 +Message-ID: <26338.1068996163@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/133 +X-Sequence-Number: 4693 + +Neil Conway writes: +> Tom Lane writes: +>> (I believe the previous discussion also agreed that we wanted to +>> postpone the freezing of now(), which currently also happens at +>> BEGIN rather than the first command after BEGIN.) + +> That doesn't make sense to me: from a user's perspective, the "start +> of the transaction" is when the BEGIN is issued, regardless of any +> tricks we may play in the backend. + +That's defensible when the user issued the BEGIN himself. When the +BEGIN is coming from some interface library's autocommit logic, it's +a lot less defensible. If you consult the archives, you will find +actual user complaints about "why is now() returning a very old time?" +that we traced to use of interface layers that handle "commit()" by +issuing "COMMIT; BEGIN;". + +When BEGIN actually is issued by live application logic, I'd expect it +to be followed immediately by some kind of command --- so the user would +be unable to tell the difference in practice. + +Hannu moved this thread to -hackers, please follow up there if you want +to discuss it more. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 11:52:31 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 92623D1D207 + for ; + Sun, 16 Nov 2003 15:52:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69009-03 + for ; + Sun, 16 Nov 2003 11:51:59 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id C291CD1E1A8 + for ; + Sun, 16 Nov 2003 11:51:53 -0400 (AST) +Received: from zigo.dhs.org (zigo [127.0.0.1]) + by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id hAGFpoL2012182; + Sun, 16 Nov 2003 16:51:50 +0100 +Received: from localhost (db@localhost) + by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id hAGFpnhl012178; + Sun, 16 Nov 2003 16:51:49 +0100 +Date: Sun, 16 Nov 2003 16:51:49 +0100 (CET) +From: Dennis Bjorklund +To: Tom Lane +Cc: Hannu Krosing , Neil Conway , + Will LaShell , Christopher Browne , + "pgsql-hackers@postgresql.org" +Subject: Re: start of transaction (was: Re: [PERFORM] Help with +In-Reply-To: <26134.1068994211@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/841 +X-Sequence-Number: 47129 + +On Sun, 16 Nov 2003, Tom Lane wrote: + +> There isn't any compelling implementation reason when to freeze the +> value of now(). Reasonable options are +> 1. at BEGIN (current behavior) +> 2. at transaction's external creation +> 3. at freezing of transaction snapshot +> #1 and #2 are actually the same at the moment, but could be decoupled +> as sketched above, in which case the behavior of #2 would effectively +> become "at first command afte BEGIN". +> +> I argued that now() should be frozen at the time of the transaction +> snapshot, and I still think that that's a defensible behavior. + +Is it important exactly what value is returned as long as it's the same in +the whole transaction? I think not. + +To me it would be just as logical to fix it at the first call to now() in +the transaction. The first time you call it you get the actual time as it +is now and the next time you get the same as before since every operation +in the transaction logically happens at the same time. If you don't call +now() at all, the system time will not be fetched at all. + +-- +/Dennis + + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 18:56:22 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8BEED1E13E + for ; + Sun, 16 Nov 2003 22:56:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26154-08 + for ; + Sun, 16 Nov 2003 18:55:49 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id BCF0ED1B555 + for ; + Sun, 16 Nov 2003 18:55:46 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 4FDF71E37; Sun, 16 Nov 2003 17:55:42 -0500 (EST) +To: Hannu Krosing +Cc: Tom Lane , Will LaShell , + Christopher Browne , + "pgsql-hackers@postgresql.org" +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +From: Neil Conway +In-Reply-To: <1068983887.17671.10.camel@fuji.krosing.net> (Hannu Krosing's + message of "Sun, 16 Nov 2003 13:58:08 +0200") +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> + <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> + <1068983887.17671.10.camel@fuji.krosing.net> +Date: Sun, 16 Nov 2003 17:55:41 -0500 +Message-ID: <873ccnc49e.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/853 +X-Sequence-Number: 47141 + +Hannu Krosing writes: +> For me, the "start of transaction" is not about time, but about grouping +> a set of statements into one. So making the exact moment of "start" be +> the first statement that actually does something with data seems +> perfectly reasonable. + +This might be a perfectly logical change in semantics, but what +benefit does it provide over the old way of doing things? + +What does BEGIN actually do now, from a user's perspective? At +present, it "starts a transaction block", which is pretty simple. If +we adopted the proposed change, it would "change the state of the +system so that the next command is part of a new transaction". This is +naturally more complex; but more importantly, what benefit does it +ACTUALLY provide to the user? + +(I can't see one, but perhaps I'm missing something...) + +> Delaying the locking effects of transactions as long as possible can +> increase performance overall, not just for pathological clients that sit +> on idle open transactions. + +I agree, but this is irrelevant to the semantics of now(). + +-Neil + + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 19:18:40 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C682D1E13E + for ; + Sun, 16 Nov 2003 23:18:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35486-03 + for ; + Sun, 16 Nov 2003 19:18:04 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 13F2DD1E13B + for ; + Sun, 16 Nov 2003 19:18:02 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 418E51F73; Sun, 16 Nov 2003 18:18:03 -0500 (EST) +To: Tom Lane +Cc: Will LaShell , Hannu Krosing , + Christopher Browne , pgsql-hackers@postgresql.org +Subject: start of transaction (was: Re: [PERFORM] Help with count(*)) +From: Neil Conway +In-Reply-To: <26338.1068996163@sss.pgh.pa.us> (Tom Lane's message of "Sun, + 16 Nov 2003 10:22:43 -0500") +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> + <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> + <26338.1068996163@sss.pgh.pa.us> +Date: Sun, 16 Nov 2003 18:18:02 -0500 +Message-ID: <87n0avaonp.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/854 +X-Sequence-Number: 47142 + +Tom Lane writes: +> That's defensible when the user issued the BEGIN himself. When the +> BEGIN is coming from some interface library's autocommit logic, it's +> a lot less defensible. If you consult the archives, you will find +> actual user complaints about "why is now() returning a very old time?" +> that we traced to use of interface layers that handle "commit()" by +> issuing "COMMIT; BEGIN;". + +Hmmm... I agree this behavior isn't ideal, although I can see the case +for viewing this as a mistake by the application developer: they are +assuming that they know exactly when transactions begin, which is not +a feature provided by their language interface. They should be using +current_timestamp, and/or changing their language interface's +configuration. + +That said, I think this is a minor irritation at best. The dual +drawbacks of breaking backward compatibility and making the BEGIN +semantics more confusing is enough to leave me satisfies with the +status quo. + +If we do change this, I think Dennis' idea of making now() always +return the same value within a given transaction is interesting: that +might be a way to fix this problem without confusing the semantics of +BEGIN. + +-Neil + + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 20:09:07 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C27ED1E33C + for ; + Mon, 17 Nov 2003 00:09:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44500-06 + for ; + Sun, 16 Nov 2003 20:08:34 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DCDBFD1E33B + for ; + Sun, 16 Nov 2003 20:08:29 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAH08P19003799; + Sun, 16 Nov 2003 19:08:25 -0500 (EST) +To: Neil Conway +Cc: Will LaShell , Hannu Krosing , + Christopher Browne , pgsql-hackers@postgresql.org +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +In-reply-to: <87n0avaonp.fsf@mailbox.samurai.com> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> + <87isllbcys.fsf@mailbox.samurai.com> + <26338.1068996163@sss.pgh.pa.us> + <87n0avaonp.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Sun, 16 Nov 2003 18:18:02 -0500" +Date: Sun, 16 Nov 2003 19:08:24 -0500 +Message-ID: <3798.1069027704@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/855 +X-Sequence-Number: 47143 + +Neil Conway writes: +> Hmmm... I agree this behavior isn't ideal, although I can see the case +> for viewing this as a mistake by the application developer: they are +> assuming that they know exactly when transactions begin, which is not +> a feature provided by their language interface. + +Well, actually, it's a bug in the interface IMHO. But as I said in the +last thread, it's a fairly widespread bug. We've been taking the +position that the interface libraries should get fixed, and that's not +happening. It's probably time to look at a server-side fix. + +> If we do change this, I think Dennis' idea of making now() always +> return the same value within a given transaction is interesting: + +You mean the time of the first now() call? I thought that was an +interesting idea also, but it's probably not going to look so hot +when we complete the TODO item of adding access to +the start-of-current-statement time. Having start-of-transaction be +later than start-of-statement isn't gonna fly :-(. If we were willing +to abandon that TODO item then I'd be interested in defining now() as +Dennis suggested. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Sun Nov 16 20:32:06 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AF863D1E139 + for ; + Mon, 17 Nov 2003 00:32:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52446-01 + for ; + Sun, 16 Nov 2003 20:31:31 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B3E6D1B555 + for ; + Sun, 16 Nov 2003 20:31:27 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAH0VD328503; + Sun, 16 Nov 2003 19:31:13 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311170031.hAH0VD328503@candle.pha.pa.us> +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +In-Reply-To: <3798.1069027704@sss.pgh.pa.us> +To: Tom Lane +Date: Sun, 16 Nov 2003 19:31:13 -0500 (EST) +Cc: Neil Conway , Will LaShell , + Hannu Krosing , Christopher Browne , + pgsql-hackers@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/856 +X-Sequence-Number: 47144 + +Tom Lane wrote: +> Neil Conway writes: +> > Hmmm... I agree this behavior isn't ideal, although I can see the case +> > for viewing this as a mistake by the application developer: they are +> > assuming that they know exactly when transactions begin, which is not +> > a feature provided by their language interface. +> +> Well, actually, it's a bug in the interface IMHO. But as I said in the +> last thread, it's a fairly widespread bug. We've been taking the +> position that the interface libraries should get fixed, and that's not +> happening. It's probably time to look at a server-side fix. +> +> > If we do change this, I think Dennis' idea of making now() always +> > return the same value within a given transaction is interesting: +> +> You mean the time of the first now() call? I thought that was an +> interesting idea also, but it's probably not going to look so hot +> when we complete the TODO item of adding access to +> the start-of-current-statement time. Having start-of-transaction be +> later than start-of-statement isn't gonna fly :-(. If we were willing +> to abandon that TODO item then I'd be interested in defining now() as +> Dennis suggested. + +Defining now() as the first call seems pretty arbitrary to me. I can't +think of any time-based interface that has that API. And what if a +trigger called now() in an earlier query and you didn't even know about +it. + + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-hackers-owner@postgresql.org Mon Nov 17 02:12:32 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8DD7D1B57F + for ; + Mon, 17 Nov 2003 06:12:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03646-04 + for ; + Mon, 17 Nov 2003 02:11:59 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id D741AD1B53A + for ; + Mon, 17 Nov 2003 02:11:58 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id A1DAB36E39; Mon, 17 Nov 2003 01:11:53 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ALcc5-0000p5-00; Mon, 17 Nov 2003 01:11:53 -0500 +To: pgsql-hackers@postgresql.org +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> + <87isllbcys.fsf@mailbox.samurai.com> + <1068983887.17671.10.camel@fuji.krosing.net> + <873ccnc49e.fsf@mailbox.samurai.com> +In-Reply-To: <873ccnc49e.fsf@mailbox.samurai.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 17 Nov 2003 01:11:53 -0500 +Message-ID: <87he13a5hy.fsf@stark.dyndns.tv> +Lines: 29 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/858 +X-Sequence-Number: 47146 + + +Neil Conway writes: + +> What does BEGIN actually do now, from a user's perspective? + +I think you're thinking about this all wrong. BEGIN doesn't "do" anything. +It's not a procedural statement, it's a declaration. It declares that the +block of statements form a transaction so reads should be consistent and +failures should be handled in a particular way to preserve data integrity. + +Given that declaration and the guarantees it requires of the database it's +then up to the database to figure out what constraints that imposes on what +the database can do and still meet the guarantees the BEGIN declaration +requires. The more clever the database is about minimizing those restrictions +the better as it means the database can run more efficiently. + +For what it's worth, this is how Oracle handles things too. On the +command-line issuing a BEGIN following a COMMIT is just noise; you're _always_ +in a transaction. A COMMIT ends the previous the transaction and implicitly +starts the next transaction. But the snapshot isn't frozen until you first +read from a table. + +I'm not sure what other databases do, but I think this is why clients behave +like this. They think of BEGIN as a declaration and therefore initiating a +COMMIT;BEGIN; at the end of every request is perfectly logical, and works fine +in at least Oracle, and probably other databases. + +-- +greg + + +From pgsql-hackers-owner@postgresql.org Mon Nov 17 03:09:37 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 11CA3D1B95D + for ; + Mon, 17 Nov 2003 07:09:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04323-05 + for ; + Mon, 17 Nov 2003 03:09:06 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D644D1B53A + for ; + Mon, 17 Nov 2003 03:09:05 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 728923532D; Sun, 16 Nov 2003 23:09:05 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 710053532C; Sun, 16 Nov 2003 23:09:05 -0800 (PST) +Date: Sun, 16 Nov 2003 23:09:05 -0800 (PST) +From: Stephan Szabo +To: Greg Stark +Cc: pgsql-hackers@postgresql.org +Subject: Re: start of transaction (was: Re: [PERFORM] Help with +In-Reply-To: <87he13a5hy.fsf@stark.dyndns.tv> +Message-ID: <20031116230227.H82963@megazone.bigpanda.com> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> + <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> + <1068983887.17671.10.camel@fuji.krosing.net> + <873ccnc49e.fsf@mailbox.samurai.com> + <87he13a5hy.fsf@stark.dyndns.tv> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/859 +X-Sequence-Number: 47147 + +On Sun, 17 Nov 2003, Greg Stark wrote: + +> Neil Conway writes: +> +> > What does BEGIN actually do now, from a user's perspective? +> +> I think you're thinking about this all wrong. BEGIN doesn't "do" anything. +> It's not a procedural statement, it's a declaration. It declares that the +> block of statements form a transaction so reads should be consistent and +> failures should be handled in a particular way to preserve data integrity. +> +> Given that declaration and the guarantees it requires of the database it's +> then up to the database to figure out what constraints that imposes on what +> the database can do and still meet the guarantees the BEGIN declaration +> requires. The more clever the database is about minimizing those restrictions +> the better as it means the database can run more efficiently. +> +> For what it's worth, this is how Oracle handles things too. On the +> command-line issuing a BEGIN following a COMMIT is just noise; you're _always_ +> in a transaction. A COMMIT ends the previous the transaction and implicitly +> starts the next transaction. But the snapshot isn't frozen until you first +> read from a table. + +The earlier portion of the described behavior is AFAICS not complient to +SQL99 at least. COMMIT (without AND CHAIN) terminates a transaction and +does not begin a new one. The new transaction does not begin until a +transaction initiating command (for example START TRANSACTION, CREATE +TABLE, INSERT, ...) is executed. The set of things you can do that aren't +initiating is fairly small admittedly, but it's not a null set. + +From pgsql-hackers-owner@postgresql.org Mon Nov 17 06:17:10 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EDA0BD1B579 + for ; + Mon, 17 Nov 2003 10:17:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30431-08 + for ; + Mon, 17 Nov 2003 06:16:38 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 775F0D1B584 + for ; + Mon, 17 Nov 2003 06:16:19 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAHAGDJC020262; + Mon, 17 Nov 2003 12:16:13 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAHAG6M9020260; + Mon, 17 Nov 2003 12:16:06 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: start of transaction (was: Re: [PERFORM] Help with +From: Hannu Krosing +To: Tom Lane +Cc: Neil Conway , Will LaShell , + Christopher Browne , + "pgsql-hackers@postgresql.org" +In-Reply-To: <3798.1069027704@sss.pgh.pa.us> +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> + <4987.1068842326@sss.pgh.pa.us> <87isllbcys.fsf@mailbox.samurai.com> + <26338.1068996163@sss.pgh.pa.us> <87n0avaonp.fsf@mailbox.samurai.com> + <3798.1069027704@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1069064165.20092.20.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 17 Nov 2003 12:16:06 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/862 +X-Sequence-Number: 47150 + +Tom Lane kirjutas E, 17.11.2003 kell 02:08: +> Neil Conway writes: +> > Hmmm... I agree this behavior isn't ideal, although I can see the case +> > for viewing this as a mistake by the application developer: they are +> > assuming that they know exactly when transactions begin, which is not +> > a feature provided by their language interface. +> +> Well, actually, it's a bug in the interface IMHO. But as I said in the +> last thread, it's a fairly widespread bug. + +I'm not sure that it is a client-side bug. For example Oracle seems to +_always_ have a transaction going, i.e. you can't be "outside" of +transaction, and you use just COMMIT to commit old _and_start_new_ +transaction. + +IIRC the same is true for DB2. + +For these database the BEGIN TRANSACTION command is mainly used for +starting nested transactions, which we don't have. + +> We've been taking the +> position that the interface libraries should get fixed, and that's not +> happening. It's probably time to look at a server-side fix. + +Maybe "fixing" the interface libraries would make them incompatible with +*DBC's for all other databases in some subtle ways ? + +----------------- +Hannu + + +From pgsql-hackers-owner@postgresql.org Mon Nov 17 06:20:20 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01C36D1B584 + for ; + Mon, 17 Nov 2003 10:20:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43067-01 + for ; + Mon, 17 Nov 2003 06:19:50 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 41F7CD1B536 + for ; + Mon, 17 Nov 2003 06:19:47 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAHAJJJC020269; + Mon, 17 Nov 2003 12:19:19 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAHAJ6lF020266; + Mon, 17 Nov 2003 12:19:06 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: start of transaction (was: Re: [PERFORM] Help with +From: Hannu Krosing +To: Bruce Momjian +Cc: Tom Lane , Neil Conway , + Will LaShell , Christopher Browne , + "pgsql-hackers@postgresql.org" +In-Reply-To: <200311170031.hAH0VD328503@candle.pha.pa.us> +References: <200311170031.hAH0VD328503@candle.pha.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1069064346.20092.27.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 17 Nov 2003 12:19:06 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/863 +X-Sequence-Number: 47151 + +Bruce Momjian kirjutas E, 17.11.2003 kell 02:31: + +> Defining now() as the first call seems pretty arbitrary to me. I can't +> think of any time-based interface that has that API. And what if a +> trigger called now() in an earlier query and you didn't even know about +> it. + +That would be OK. The whole point of that previous discussion was to +have now() that returns the same value over the span of the whole +transaction. + +It would be even better to have now() that returns the time current +transaction is COMMITted as this is the time other backend become aware +of it ;) + +----------- +Hannu + + +From pgsql-hackers-owner@postgresql.org Tue Nov 18 16:16:08 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E48DD1B584 + for ; + Mon, 17 Nov 2003 10:44:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37760-05 + for ; + Mon, 17 Nov 2003 06:43:54 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EE16D1B536 + for ; + Mon, 17 Nov 2003 06:43:46 -0400 (AST) +Received: from persistent.co.in shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Mon, 17 Nov 2003 03:43:46 -0700 +Message-ID: <3FB8A650.9030603@persistent.co.in> +Date: Mon, 17 Nov 2003 16:13:28 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-hackers@postgresql.org" +Subject: Re: start of transaction +References: <200311141251.38786.mallah@trade-india.com> + + <1068831807.2540.44.camel@fuji.krosing.net> + <3FB52FA7.8060508@lashell.net> <4987.1068842326@sss.pgh.pa.us> + <87isllbcys.fsf@mailbox.samurai.com> + <26338.1068996163@sss.pgh.pa.us> + <87n0avaonp.fsf@mailbox.samurai.com> + <3798.1069027704@sss.pgh.pa.us> + <1069064165.20092.20.camel@fuji.krosing.net> +In-Reply-To: <1069064165.20092.20.camel@fuji.krosing.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1006 +X-Sequence-Number: 47294 + +Hannu Krosing wrote: + +> Tom Lane kirjutas E, 17.11.2003 kell 02:08: +> +>>Neil Conway writes: +>> +>>>Hmmm... I agree this behavior isn't ideal, although I can see the case +>>>for viewing this as a mistake by the application developer: they are +>>>assuming that they know exactly when transactions begin, which is not +>>>a feature provided by their language interface. +>> +>>Well, actually, it's a bug in the interface IMHO. But as I said in the +>>last thread, it's a fairly widespread bug. +> +> +> I'm not sure that it is a client-side bug. For example Oracle seems to +> _always_ have a transaction going, i.e. you can't be "outside" of +> transaction, and you use just COMMIT to commit old _and_start_new_ +> transaction. +> +> IIRC the same is true for DB2. + +Actually, in oracle a new transaction starts with first DDL after a commit. That +does not include DML BTW. + +And Damn.. Actually I recently fixed a "bug" where I had to force a start of +transaction in Pro*C, immediately after commit. Otherwise a real start of +transaction could be anywhere down the line, causing some weird concurrency +issues. Rather than fiddling with oracle support, I would hack my source code, +especially this is not the first oracle bug I have worked around....:-( + +The fact that I couldn't control exact transaction start was such a irritation +to put it mildly.. I sooooo missed 'exec sql begin work' in ecpg..:-) + +>>We've been taking the +>>position that the interface libraries should get fixed, and that's not +>>happening. It's probably time to look at a server-side fix. + +I hope that does not compramise transaction control I have with libpq/ecpg etc. + +And when we are talking about interface libraries, how many of them are within +PG control and how many are not? With languages maintenend by postgresql group, +it should behave correctly, right? E.g pl/perl,pl/python etc. + +And for other interface libraries, what are they exactly? php? Can't we just +send them a stinker/patch to get that damn thing right(Whatever wrong they are +doing. I have kinda lost thread on it..:-) Was it exact time of transaction +start v/s now()?) + + Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Nov 17 10:43:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88DFFD1DABB + for ; + Mon, 17 Nov 2003 14:43:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82740-04 + for ; + Mon, 17 Nov 2003 10:42:44 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D07AD1D8AE + for ; + Mon, 17 Nov 2003 10:42:40 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1ALkaS-0001jz-00 + for ; Mon, 17 Nov 2003 09:42:44 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 0063ACBB8; Mon, 17 Nov 2003 09:42:43 -0500 (EST) +Date: Mon, 17 Nov 2003 09:42:43 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: INSERT extremely slow with large data sets (fwd) +Message-ID: <20031117144243.GE1716@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: + + <20031115131338.90329.qmail@web80208.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031115131338.90329.qmail@web80208.mail.yahoo.com> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/134 +X-Sequence-Number: 4694 + +On Sat, Nov 15, 2003 at 05:13:38AM -0800, George Essig wrote: +> +> VACUUM ANALYZE will reclaim disk space and update statistics used + +Strictly speaking, it does not reclaim disk space. It merely marks +it as available, assuming you have enough room in your free space +map. VACUUM FULL reclaims disk space, i.e. it compacts the data +files and returns that space to the operating system. + +A +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Mon Nov 17 10:52:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 89F56D1B536 + for ; + Mon, 17 Nov 2003 14:51:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81735-07 + for ; + Mon, 17 Nov 2003 10:51:31 -0400 (AST) +Received: from jacobson.be (c20753a.mael.bostream.se [217.215.37.134]) + by svr1.postgresql.org (Postfix) with SMTP id 70E78D1B50C + for ; + Mon, 17 Nov 2003 10:51:26 -0400 (AST) +Received: (qmail 2433 invoked by uid 99); 17 Nov 2003 14:51:21 -0000 +Received: from dhcp-5.localdomain (dhcp-5.localdomain [192.168.0.5]) + by mail.jacobson.be (IMP) with HTTP + for ; Mon, 17 Nov 2003 15:51:20 +0100 +Message-ID: <1069080680.3fb8e068eb941@mail.jacobson.be> +Date: Mon, 17 Nov 2003 15:51:20 +0100 +From: Joel Jacobson +To: pgsql-performance@postgresql.org +Subject: Backup/restore of pg_statistics +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.2 +X-Originating-IP: 192.168.0.5 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/135 +X-Sequence-Number: 4695 + +Hi, + +I understand that it is not possible to occasionally re-plan the queries in a +PL/pgSQL function without dropping and re-creating the function. + +I think it would be useful if the queries in a PL/pgSQL function could be +re-planned on-the-fly. + +When a lot of data has been added/modified and ANALYZE is suitable to run, it +would also be a great idea to re-plan the queries used in PL/pgSQL functions. +I understand that this is not possible? +The only way would be to DROP/CREATE the functions or to use EXECUTE. +I don't think EXECUTE is an option, because preparing the queries every time the +function is called is in my case not necessary and just a waste of +performance. + +As a work-around, I am forced to, +1. populate the database with a lot of test data, +2. run ANALYZE, +3. and finally, create the PL/pgSQL functions +The prepared queries in the functions will now be sufficiently optimized. + +I don't think this is a nice solution. + +I also thought of a slightly better solution, but I don't know if it is +possible. +My idea was to populate the database once and then save the data in +pg_statistics generated by ANALYZE to a file. Every time the database needs to +be created, the statistics could then be restored thus making the planner +produce "future-optimized" queries when the PL/pgSQL functions are created, +even though the database is empty. + +I would greatly appreciate any help/comments. + +Thank you. + +Joel Jacobson + +From pgsql-performance-owner@postgresql.org Mon Nov 17 12:39:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5743FD1B537 + for ; + Mon, 17 Nov 2003 16:39:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04418-09 + for ; + Mon, 17 Nov 2003 12:38:43 -0400 (AST) +Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) + by svr1.postgresql.org (Postfix) with ESMTP id A9500D1B54C + for ; + Mon, 17 Nov 2003 12:38:42 -0400 (AST) +Received: (from mail@localhost) + by martin.sysdetect.com (8.11.4/8.11.3) id hAHGcg402482 + for ; Mon, 17 Nov 2003 16:38:42 GMT +Received: from winwood.sysdetect.com(172.16.1.1) + via SMTP by mail.sysdetect.com, id smtpdA26397; Mon Nov 17 16:38:38 2003 +Received: from sysd.com (thriller.sysdetect.com [172.16.1.33]) + by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id hAHGccb19973 + for ; Mon, 17 Nov 2003 11:38:38 -0500 +Message-ID: <3FB8F98D.1010707@sysd.com> +Date: Mon, 17 Nov 2003 11:38:37 -0500 +From: Rich Cullingford +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Top n queries and GROUP BY +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/136 +X-Sequence-Number: 4696 + +All, +This is a straight SQL question, maybe not appropriate for a performance +list, but... + +I have a simple stock holdings setup: + +=> select * from t1; + nam | co | num +-----+-----------+------ + joe | ibm | 600 + abe | ibm | 1500 + joe | cisco | 1200 + abe | cisco | 800 + joe | novell | 500 + joe | microsoft | 200 + +What I would like to see is a Top-n-holdings-by-name", e.g, for n=2: + + nam | co | num +----------+--------+----- + joe | cisco | 1200 + joe | ibm | 600 + abe | ibm | 1500 + abe | cisco | 800 + +I can get part of the way by using a LIMIT clause in a subquery, e.g, + +=> select 'abe', a.co, a.num from (select co, num from t1 where +nam='abe' order by num desc limit 2) as a; + ?column? | co | num +----------+-------+------ + abe | ibm | 1500 + abe | cisco | 800 + +but I can't figure out a correlated subquery (or GROUP BY arrangement or +anything else) that will cycle through the names. I vaguely remember +that these kinds or queries are hard to do in standard SQL, but I was +hoping that PG, with its extensions... + + Thanks, Rich Cullingford + rculling@sysd.com + + + +From pgsql-performance-owner@postgresql.org Mon Nov 17 13:57:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F11C5D1B50A + for ; + Mon, 17 Nov 2003 17:56:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17384-02 + for ; + Mon, 17 Nov 2003 13:56:27 -0400 (AST) +Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A757D1B8B9 + for ; + Mon, 17 Nov 2003 13:56:26 -0400 (AST) +Received: (from mail@localhost) + by martin.sysdetect.com (8.11.4/8.11.3) id hAHHuQ105024 + for ; Mon, 17 Nov 2003 17:56:26 GMT +Received: from winwood.sysdetect.com(172.16.1.1) + via SMTP by mail.sysdetect.com, id smtpdl10528; Mon Nov 17 17:56:23 2003 +Received: from sysd.com (thriller.sysdetect.com [172.16.1.33]) + by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id hAHHuNb22743; + Mon, 17 Nov 2003 12:56:23 -0500 +Message-ID: <3FB90BC7.5090602@sysd.com> +Date: Mon, 17 Nov 2003 12:56:23 -0500 +From: Rich Cullingford +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rich Cullingford +Cc: pgsql-performance@postgresql.org +Subject: Re: Top n queries and GROUP BY +References: <3FB8F98D.1010707@sysd.com> +In-Reply-To: <3FB8F98D.1010707@sysd.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/137 +X-Sequence-Number: 4697 + +Rich Cullingford wrote: +> All, +> This is a straight SQL question, maybe not appropriate for a performance +> list, but... +> +> I have a simple stock holdings setup: +> +> => select * from t1; +> nam | co | num +> -----+-----------+------ +> joe | ibm | 600 +> abe | ibm | 1500 +> joe | cisco | 1200 +> abe | cisco | 800 +> joe | novell | 500 +> joe | microsoft | 200 +> +> What I would like to see is a Top-n-holdings-by-name", e.g, for n=2: +> +> nam | co | num +> ----------+--------+----- +> joe | cisco | 1200 +> joe | ibm | 600 +> abe | ibm | 1500 +> abe | cisco | 800 +> +> I can get part of the way by using a LIMIT clause in a subquery, e.g, +> +> => select 'abe', a.co, a.num from (select co, num from t1 where +> nam='abe' order by num desc limit 2) as a; +> ?column? | co | num +> ----------+-------+------ +> abe | ibm | 1500 +> abe | cisco | 800 +> +> but I can't figure out a correlated subquery (or GROUP BY arrangement or +> anything else) that will cycle through the names. I vaguely remember +> that these kinds or queries are hard to do in standard SQL, but I was +> hoping that PG, with its extensions... + +I forgot about row subqueries; for n=3, for example: + +=> SELECT * FROM t1 + WHERE (nam,co,num) IN + (SELECT nam,co,num FROM t1 b + where b.nam=t1.nam + order by num desc limit 3) + order by nam, num desc; + + nam | co | num +-----+--------+------ + abe | ibm | 1500 + abe | cisco | 800 + joe | cisco | 1200 + joe | ibm | 600 + joe | novell | 500 +(5 rows) + +Seems to work... + Thanks all, Rich Cullingford + rculling@sysd.com + + +From pgsql-performance-owner@postgresql.org Mon Nov 17 18:22:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 23C1CD1C975 + for ; + Mon, 17 Nov 2003 22:22:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65292-09 + for ; + Mon, 17 Nov 2003 18:21:38 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id 4D5DDD1CA06 + for ; + Mon, 17 Nov 2003 18:21:14 -0400 (AST) +Received: (qmail 8003 invoked by uid 0); 17 Nov 2003 22:21:00 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 17 Nov 2003 22:21:00 -0000 +Received: (qmail 4818 invoked by uid 1000); 17 Nov 2003 22:20:59 -0000 +Date: Mon, 17 Nov 2003 23:20:58 +0100 +From: Ryszard Lach +To: pgsql-performance@postgresql.org +Subject: duration logging setting in 7.4 +Message-ID: <20031117222058.GD3248@siaco.id.pl> +Reply-To: Ryszard Lach +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/138 +X-Sequence-Number: 4698 + + +Hi. + +I'm trying to set run-time environment in pgsql7.4 so, that it prints +all statements with duration time, but I can't understand why setting +log_min_duration_statement to '0' causes printing to syslog plenty of +lines ending with 'duration: statement:', i.e. without any statement +string (except expected ones). Can anybody help me? + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-hackers-owner@postgresql.org Mon Nov 17 20:53:37 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C515D1C9B7 + for ; + Tue, 18 Nov 2003 00:53:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91875-04 + for ; + Mon, 17 Nov 2003 20:53:05 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id E3CB7D1B527 + for ; + Mon, 17 Nov 2003 20:53:00 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAI0qpw10716; + Mon, 17 Nov 2003 19:52:51 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311180052.hAI0qpw10716@candle.pha.pa.us> +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +In-Reply-To: <1069064346.20092.27.camel@fuji.krosing.net> +To: Hannu Krosing +Date: Mon, 17 Nov 2003 19:52:51 -0500 (EST) +Cc: Tom Lane , Neil Conway , + Will LaShell , Christopher Browne , + "pgsql-hackers@postgresql.org" +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/896 +X-Sequence-Number: 47184 + +Hannu Krosing wrote: +> Bruce Momjian kirjutas E, 17.11.2003 kell 02:31: +> +> > Defining now() as the first call seems pretty arbitrary to me. I can't +> > think of any time-based interface that has that API. And what if a +> > trigger called now() in an earlier query and you didn't even know about +> > it. +> +> That would be OK. The whole point of that previous discussion was to +> have now() that returns the same value over the span of the whole +> transaction. + +I think my issue is that there isn't any predictable way for a user to +know when the now() time is recorded. By using start of transaction, at +least we know for sure the point in time it is showing. + +> It would be even better to have now() that returns the time current +> transaction is COMMITted as this is the time other backend become aware +> of it ;) + +True, but implementing that would be very hard. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Mon Nov 17 22:38:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC552D1CA63 + for ; + Tue, 18 Nov 2003 02:38:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14682-04 + for ; + Mon, 17 Nov 2003 22:38:17 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 109B6D1CAD1 + for ; + Mon, 17 Nov 2003 22:37:05 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAI2b7s29417; + Mon, 17 Nov 2003 21:37:07 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311180237.hAI2b7s29417@candle.pha.pa.us> +Subject: Re: duration logging setting in 7.4 +In-Reply-To: <20031117222058.GD3248@siaco.id.pl> +To: Ryszard Lach +Date: Mon, 17 Nov 2003 21:37:07 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/139 +X-Sequence-Number: 4699 + +Ryszard Lach wrote: +> +> Hi. +> +> I'm trying to set run-time environment in pgsql7.4 so, that it prints +> all statements with duration time, but I can't understand why setting +> log_min_duration_statement to '0' causes printing to syslog plenty of +> lines ending with 'duration: statement:', i.e. without any statement +> string (except expected ones). Can anybody help me? + +Can you show us some of the log file? If I do: + + test=> set log_min_duration_statement = 0; + SET + test=> select 1; + ?column? + ---------- + 1 + (1 row) + +I get: + + LOG: duration: 0.861 ms statement: select 1; + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-hackers-owner@postgresql.org Tue Nov 18 03:35:43 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01AD4D1B575 + for ; + Tue, 18 Nov 2003 07:35:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72114-08 + for ; + Tue, 18 Nov 2003 03:35:11 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EB2BD1B50F + for ; + Tue, 18 Nov 2003 03:35:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAI7Yq19017647; + Tue, 18 Nov 2003 02:34:53 -0500 (EST) +To: Bruce Momjian +Cc: Hannu Krosing , Neil Conway , + Will LaShell , Christopher Browne , + "pgsql-hackers@postgresql.org" +Subject: Re: start of transaction (was: Re: [PERFORM] Help with count(*)) +In-reply-to: <200311180052.hAI0qpw10716@candle.pha.pa.us> +References: <200311180052.hAI0qpw10716@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Mon, 17 Nov 2003 19:52:51 -0500" +Date: Tue, 18 Nov 2003 02:34:52 -0500 +Message-ID: <17646.1069140892@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/952 +X-Sequence-Number: 47240 + +Bruce Momjian writes: +> Hannu Krosing wrote: +>> It would be even better to have now() that returns the time current +>> transaction is COMMITted as this is the time other backend become aware +>> of it ;) + +> True, but implementing that would be very hard. + +Son, that was a *joke* ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Nov 18 05:18:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E7427D1D80C + for ; + Tue, 18 Nov 2003 09:18:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86718-08 + for ; + Tue, 18 Nov 2003 05:18:09 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id 3617AD1B4E8 + for ; + Tue, 18 Nov 2003 05:18:04 -0400 (AST) +Received: (qmail 7469 invoked by uid 0); 18 Nov 2003 09:16:50 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 18 Nov 2003 09:16:50 -0000 +Received: (qmail 8615 invoked by uid 1000); 18 Nov 2003 09:16:46 -0000 +Date: Tue, 18 Nov 2003 10:16:46 +0100 +From: Ryszard Lach +To: pgsql-performance@postgresql.org +Cc: Bruce Momjian +Subject: Re: duration logging setting in 7.4 +Message-ID: <20031118091646.GA8223@siaco.id.pl> +Reply-To: Ryszard Lach +References: <20031117222058.GD3248@siaco.id.pl> + <200311180237.hAI2b7s29417@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <200311180237.hAI2b7s29417@candle.pha.pa.us> +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/140 +X-Sequence-Number: 4700 + +On Mon, Nov 17, 2003 at 09:37:07PM -0500, Bruce Momjian wrote: +> Ryszard Lach wrote: +> > +> > Hi. +> > +> > I'm trying to set run-time environment in pgsql7.4 so, that it prints +> > all statements with duration time, but I can't understand why setting +> > log_min_duration_statement to '0' causes printing to syslog plenty of +> > lines ending with 'duration: statement:', i.e. without any statement +> > string (except expected ones). Can anybody help me? +> +> Can you show us some of the log file? If I do: +> + +Sure. + +Nov 18 10:05:20 postgres[1348]: [318-1] LOG: duration: 0.297 ms statement: +Nov 18 10:05:20 postgres[1311]: [5477-1] LOG: duration: 0.617 ms statement: +Nov 18 10:05:20 postgres[1312]: [5134-1] LOG: duration: 0.477 ms statement: +Nov 18 10:05:20 postgres[1349]: [318-1] LOG: duration: 0.215 ms statement: +Nov 18 10:05:20 postgres[1313]: [5449-1] LOG: duration: 0.512 ms statement: +Nov 18 10:05:20 postgres[1314]: [5534-1] LOG: duration: 0.420 ms statement: +Nov 18 10:05:20 postgres[1330]: [772-1] LOG: duration: 1.386 ms statement: SELECT * FROM mytablemius WHERE id = 0; +Nov 18 10:05:20 postgres[1315]: [5757-1] LOG: duration: 0.417 ms statement: +Nov 18 10:05:20 postgres[1316]: [5885-1] LOG: duration: 0.315 ms statement: +Nov 18 10:05:20 postgres[1317]: [5914-1] LOG: duration: 0.301 ms statement: +Nov 18 10:05:20 postgres[1318]: [5990-1] LOG: duration: 0.293 ms statement: +Nov 18 10:05:20 postgres[1319]: [6009-1] LOG: duration: 0.211 ms statement: +Nov 18 10:05:20 postgres[1320]: [6039-1] LOG: duration: 0.188 ms statement: + + +this is with setting + +log_duration = false +log_statement = false +log_min_duration_statement = 0 + +The amount of lines containing statement string is nearly the same ase before +upgrade (from 7.3), all other lines are extra. + +I don't know if this can be a reason, this is on a pretty busy machine (ca. 100 +selects/second, but loadavg lower then 0.9), I'm logging postgres through syslog. + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Tue Nov 18 06:10:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 39DA7D1C9AB + for ; + Tue, 18 Nov 2003 10:10:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96375-06 + for ; + Tue, 18 Nov 2003 06:09:54 -0400 (AST) +Received: from stan.aopsys.com (m173.net81-64-15.noos.fr [81.64.15.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 58943D1B515 + for ; + Tue, 18 Nov 2003 06:09:51 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=news.nerim.net) + by stan.aopsys.com with esmtp (Exim 3.36 #1 (Debian)) + id 1AM2g8-00063z-00 + for ; Tue, 18 Nov 2003 11:01:48 +0100 +To: +Subject: Join on incompatible types +References: +From: Laurent Martelli +Date: Tue, 18 Nov 2003 11:01:48 +0100 +In-Reply-To: (scott + marlowe's message of "Wed, 29 Oct 2003 14:51:18 -0700 (MST)") +Message-ID: <87k75ym1v7.fsf@news.nerim.net> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/141 +X-Sequence-Number: 4701 + +>>>>> "scott" == scott marlowe writes: + +[...] + + scott> Note here: + + scott> Merge Join (cost=1788.68..4735.71 rows=1 width=85) (actual + scott> time=597.540..1340.526 rows=20153 loops=1) Merge Cond: + scott> ("outer".id = "inner".id) + + scott> This estimate is WAY off. Are both of those fields indexed + scott> and analyzed? Have you tried upping the statistics target on + scott> those two fields? I assume they are compatible types. + +Should I understand that a join on incompatible types (such as integer +and varchar) may lead to bad performances ? + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.aopsys.com + + +From pgsql-performance-owner@postgresql.org Tue Nov 18 06:46:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A56E9D1D803 + for ; + Tue, 18 Nov 2003 10:46:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03224-06 + for ; + Tue, 18 Nov 2003 06:45:55 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C673D1C9DA + for ; + Tue, 18 Nov 2003 06:45:52 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Tue, 18 Nov 2003 03:45:49 -0700 +Message-ID: <3FB9F855.7010905@myrealbox.com> +Date: Tue, 18 Nov 2003 16:15:41 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> +In-Reply-To: <87k75ym1v7.fsf@news.nerim.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/142 +X-Sequence-Number: 4702 + +Laurent Martelli wrote: + +>>>>>>"scott" == scott marlowe writes: +> +> +> [...] +> +> scott> Note here: +> +> scott> Merge Join (cost=1788.68..4735.71 rows=1 width=85) (actual +> scott> time=597.540..1340.526 rows=20153 loops=1) Merge Cond: +> scott> ("outer".id = "inner".id) +> +> scott> This estimate is WAY off. Are both of those fields indexed +> scott> and analyzed? Have you tried upping the statistics target on +> scott> those two fields? I assume they are compatible types. +> +> Should I understand that a join on incompatible types (such as integer +> and varchar) may lead to bad performances ? + +Conversely, you should enforce strict type compatibility in comparisons for +getting any good plans..:-) + + Shridhar + + +From pgsql-performance-owner@postgresql.org Tue Nov 18 15:47:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3037ED1CA92 + for ; + Tue, 18 Nov 2003 13:33:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33208-01 + for ; + Tue, 18 Nov 2003 09:32:59 -0400 (AST) +Received: from stan.aopsys.com (m173.net81-64-15.noos.fr [81.64.15.173]) + by svr1.postgresql.org (Postfix) with ESMTP id CC052D1D880 + for ; + Tue, 18 Nov 2003 09:32:54 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=news.nerim.net) + by stan.aopsys.com with esmtp (Exim 3.36 #1 (Debian)) + id 1AM5qe-0006H6-00; Tue, 18 Nov 2003 14:24:52 +0100 +To: Shridhar Daithankar +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> <3FB9F855.7010905@myrealbox.com> +From: Laurent Martelli +Date: Tue, 18 Nov 2003 14:24:51 +0100 +In-Reply-To: <3FB9F855.7010905@myrealbox.com> (Shridhar Daithankar's message + of "Tue, 18 Nov 2003 16:15:41 +0530") +Message-ID: <87oev9lsgs.fsf@news.nerim.net> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/145 +X-Sequence-Number: 4705 + +>>>>> "Shridhar" == Shridhar Daithankar writes: + + Shridhar> Laurent Martelli wrote: + +[...] + + >> Should I understand that a join on incompatible types (such as + >> integer and varchar) may lead to bad performances ? + + Shridhar> Conversely, you should enforce strict type compatibility + Shridhar> in comparisons for getting any good plans..:-) + +Ha ha, now I understand why a query of mine was so sluggish. + +Is there a chance I could achieve the good perfs without having he +same types ? I've tried a CAST in the query, but it's even a little +worse than without it. However, using a view to cast integers into +varchar gives acceptable results (see at the end). + +I'm using Postgresql 7.3.4. + +iprofil-jac=# EXPLAIN ANALYZE SELECT * from classes where exists (select value from lists where lists.id='16' and lists.value=classes.id); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------- + Seq Scan on classes (cost=0.00..5480289.75 rows=9610 width=25) (actual time=31.68..7321.56 rows=146 loops=1) + Filter: (subplan) + SubPlan + -> Index Scan using lists_id on lists (cost=0.00..285.12 rows=1 width=8) (actual time=0.38..0.38 rows=0 loops=19220) + Index Cond: (id = 16) + Filter: ((value)::text = ($0)::text) + Total runtime: 7321.72 msec + +iprofil-jac=# EXPLAIN ANALYZE SELECT * from classes2 where exists (select value from lists where lists.id='16' and lists.value=classes2.id); + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------- + Seq Scan on classes2 (cost=0.00..5923.87 rows=500 width=64) (actual time=0.76..148.20 rows=146 loops=1) + Filter: (subplan) + SubPlan + -> Index Scan using lists_value on lists (cost=0.00..5.90 rows=1 width=8) (actual time=0.01..0.01 rows=0 loops=19220) + Index Cond: ((id = 16) AND (value = $0)) + Total runtime: 148.34 msec + + +-- +-- Tables classes and classes2 are populated with the same data, they +-- only differ on the type of the "id" column. +-- + + +iprofil-jac=# \d classes + Table "public.classes" + Colonne | Type | Modifications +---------+-------------------+--------------- + id | integer | not null + classid | character varying | +Index: classes_pkey primary key btree (id) + +iprofil-jac=# \d classes2 + Table "public.classes2" + Colonne | Type | Modifications +---------+-------------------+--------------- + id | character varying | not null + classid | character varying | +Index: classes2_pkey primary key btree (id) + +iprofil-jac=# \d lists + Table "public.lists" + Colonne | Type | Modifications +---------+-------------------+--------------- + id | integer | not null + index | integer | not null + value | character varying | +Index: lists_index unique btree (id, "index"), + lists_id btree (id), + lists_value btree (id, value) + +-- +-- IT'S EVEN BETTER WITH A JOIN +-- + +iprofil-jac=# EXPLAIN ANALYZE SELECT * from lists join classes on classes.id=lists.value where lists.id='16'; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..90905.88 rows=298 width=41) (actual time=53.93..9327.87 rows=146 loops=1) + Join Filter: (("inner".id)::text = ("outer".value)::text) + -> Seq Scan on lists (cost=0.00..263.43 rows=146 width=16) (actual time=8.38..9.70 rows=146 loops=1) + Filter: (id = 16) + -> Seq Scan on classes (cost=0.00..333.20 rows=19220 width=25) (actual time=0.00..28.45 rows=19220 loops=146) + Total runtime: 9328.35 msec + + +iprofil-jac=# EXPLAIN ANALYZE SELECT * from lists join classes2 on classes2.id=lists.value where lists.id='16'; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------- + Merge Join (cost=268.67..324.09 rows=16 width=80) (actual time=9.59..65.55 rows=146 loops=1) + Merge Cond: ("outer".id = "inner".value) + -> Index Scan using classes2_pkey on classes2 (cost=0.00..52.00 rows=1000 width=64) (actual time=0.03..40.83 rows=18778 loops=1) + -> Sort (cost=268.67..269.03 rows=146 width=16) (actual time=9.50..9.56 rows=146 loops=1) + Sort Key: lists.value + -> Seq Scan on lists (cost=0.00..263.43 rows=146 width=16) (actual time=8.83..9.17 rows=146 loops=1) + Filter: (id = 16) + Total runtime: 65.73 msec + + +-- +-- CASTING IN THE QUERY IS NO GOOD +-- + +iprofil-jac=# EXPLAIN ANALYZE SELECT * from lists join classes on CAST(classes.id AS character varying)=lists.value where lists.id='16'; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..90905.88 rows=298 width=41) (actual time=69.03..10017.26 rows=146 loops=1) + Join Filter: ((("inner".id)::text)::character varying = "outer".value) + -> Seq Scan on lists (cost=0.00..263.43 rows=146 width=16) (actual time=20.64..22.03 rows=146 loops=1) + Filter: (id = 16) + -> Seq Scan on classes (cost=0.00..333.20 rows=19220 width=25) (actual time=0.00..30.45 rows=19220 loops=146) + Total runtime: 10017.72 msec + + +-- +-- CREATING A VIEW IS BETTER +-- + +iprofil-jac=# CREATE VIEW classes3 as SELECT CAST(id AS varchar), classid from classes; +iprofil-jac=# EXPLAIN ANALYZE SELECT * from classes3 where exists (select value from lists where lists.id='16' and lists.value=classes3.id); + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------- + Seq Scan on classes (cost=0.00..113853.60 rows=9610 width=25) (actual time=0.91..192.31 rows=146 loops=1) + Filter: (subplan) + SubPlan + -> Index Scan using lists_value on lists (cost=0.00..5.91 rows=1 width=8) (actual time=0.01..0.01 rows=0 loops=19220) + Index Cond: ((id = 16) AND (value = (($0)::text)::character varying)) + Total runtime: 192.47 msec + + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.aopsys.com + + +From pgsql-performance-owner@postgresql.org Tue Nov 18 11:08:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 74776D1CA01 + for ; + Tue, 18 Nov 2003 15:08:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45258-08 + for ; + Tue, 18 Nov 2003 11:07:56 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B9AED1B4EF + for ; + Tue, 18 Nov 2003 11:07:51 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAIF7mX04577; + Tue, 18 Nov 2003 10:07:48 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311181507.hAIF7mX04577@candle.pha.pa.us> +Subject: Re: duration logging setting in 7.4 +In-Reply-To: <20031118091646.GA8223@siaco.id.pl> +To: Ryszard Lach +Date: Tue, 18 Nov 2003 10:07:48 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/143 +X-Sequence-Number: 4703 + + +Wow, that is strange. If you don't use syslog, do you see the proper +output? If you turn on log_statement, do you see the statements? + +--------------------------------------------------------------------------- + +Ryszard Lach wrote: +> On Mon, Nov 17, 2003 at 09:37:07PM -0500, Bruce Momjian wrote: +> > Ryszard Lach wrote: +> > > +> > > Hi. +> > > +> > > I'm trying to set run-time environment in pgsql7.4 so, that it prints +> > > all statements with duration time, but I can't understand why setting +> > > log_min_duration_statement to '0' causes printing to syslog plenty of +> > > lines ending with 'duration: statement:', i.e. without any statement +> > > string (except expected ones). Can anybody help me? +> > +> > Can you show us some of the log file? If I do: +> > +> +> Sure. +> +> Nov 18 10:05:20 postgres[1348]: [318-1] LOG: duration: 0.297 ms statement: +> Nov 18 10:05:20 postgres[1311]: [5477-1] LOG: duration: 0.617 ms statement: +> Nov 18 10:05:20 postgres[1312]: [5134-1] LOG: duration: 0.477 ms statement: +> Nov 18 10:05:20 postgres[1349]: [318-1] LOG: duration: 0.215 ms statement: +> Nov 18 10:05:20 postgres[1313]: [5449-1] LOG: duration: 0.512 ms statement: +> Nov 18 10:05:20 postgres[1314]: [5534-1] LOG: duration: 0.420 ms statement: +> Nov 18 10:05:20 postgres[1330]: [772-1] LOG: duration: 1.386 ms statement: SELECT * FROM mytablemius WHERE id = 0; +> Nov 18 10:05:20 postgres[1315]: [5757-1] LOG: duration: 0.417 ms statement: +> Nov 18 10:05:20 postgres[1316]: [5885-1] LOG: duration: 0.315 ms statement: +> Nov 18 10:05:20 postgres[1317]: [5914-1] LOG: duration: 0.301 ms statement: +> Nov 18 10:05:20 postgres[1318]: [5990-1] LOG: duration: 0.293 ms statement: +> Nov 18 10:05:20 postgres[1319]: [6009-1] LOG: duration: 0.211 ms statement: +> Nov 18 10:05:20 postgres[1320]: [6039-1] LOG: duration: 0.188 ms statement: +> +> +> this is with setting +> +> log_duration = false +> log_statement = false +> log_min_duration_statement = 0 +> +> The amount of lines containing statement string is nearly the same ase before +> upgrade (from 7.3), all other lines are extra. +> +> I don't know if this can be a reason, this is on a pretty busy machine (ca. 100 +> selects/second, but loadavg lower then 0.9), I'm logging postgres through syslog. +> +> Richard. +> +> -- +> "First they ignore you. Then they laugh at you. Then they +> fight you. Then you win." - Mohandas Gandhi. +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Tue Nov 18 13:01:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E94AD1C915 + for ; + Tue, 18 Nov 2003 17:01:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64500-09 + for ; + Tue, 18 Nov 2003 13:01:17 -0400 (AST) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 41658D1B4E8 + for ; + Tue, 18 Nov 2003 13:01:16 -0400 (AST) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AM9E2-0002q6-00 + for ; Tue, 18 Nov 2003 18:01:14 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +Received: from sea.gmane.org ([80.91.224.252]) + by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) + id 1AM9E1-0002py-00 + for ; + Tue, 18 Nov 2003 18:01:13 +0100 +Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AM9E1-0003ID-00 + for ; + Tue, 18 Nov 2003 18:01:13 +0100 +From: Harald Fuchs +Subject: Re: Top n queries and GROUP BY +Date: 18 Nov 2003 18:01:13 +0100 +Organization: Linux Private Site +Lines: 50 +Message-ID: +References: <3FB8F98D.1010707@sysd.com> +Reply-To: hf99@protecting.net +Mime-Version: 1.0 (generated by tm-edit 7.90) +Content-Type: text/plain; charset=US-ASCII +X-Complaints-To: usenet@sea.gmane.org +X-No-Archive: yes +X-Newsreader: Gnus v5.7/Emacs 20.7 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/144 +X-Sequence-Number: 4704 + +In article <3FB8F98D.1010707@sysd.com>, +Rich Cullingford writes: + +> All, +> This is a straight SQL question, maybe not appropriate for a performance +> list, but... + +> I have a simple stock holdings setup: + +> => select * from t1; +> nam | co | num +> -----+-----------+------ +> joe | ibm | 600 +> abe | ibm | 1500 +> joe | cisco | 1200 +> abe | cisco | 800 +> joe | novell | 500 +> joe | microsoft | 200 + +> What I would like to see is a Top-n-holdings-by-name", e.g, for n=2: + +> nam | co | num +> ----------+--------+----- +> joe | cisco | 1200 +> joe | ibm | 600 +> abe | ibm | 1500 +> abe | cisco | 800 + +> I can get part of the way by using a LIMIT clause in a subquery, e.g, + +> => select 'abe', a.co, a.num from (select co, num from t1 where +> nam='abe' order by num desc limit 2) as a; +> ?column? | co | num +> ----------+-------+------ +> abe | ibm | 1500 +> abe | cisco | 800 + +> but I can't figure out a correlated subquery (or GROUP BY arrangement or +> anything else) that will cycle through the names. I vaguely remember +> that these kinds or queries are hard to do in standard SQL, but I was +> hoping that PG, with its extensions... + +How about an outer join? + + SELECT x1.nam, x1.co, x1.num + FROM t1 x1 + LEFT JOIN t1 x2 ON x2.nam = x1.nam AND x2.num > x1.num + GROUP BY x1.nam, x1.co, x1.num + HAVING count(*) < 2 + ORDER BY x1.nam, x1.num DESC + + +From pgsql-performance-owner@postgresql.org Tue Nov 18 20:01:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D5CDD1CA0F + for ; + Wed, 19 Nov 2003 00:01:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42378-03 + for ; + Tue, 18 Nov 2003 20:01:21 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 4213DD1B520 + for ; + Tue, 18 Nov 2003 20:01:18 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3941320; Tue, 18 Nov 2003 16:02:05 -0800 +Content-Type: text/plain; + charset="us-ascii" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Shridhar Daithankar +Subject: More detail on settings for pgavd? +Date: Tue, 18 Nov 2003 15:58:45 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311181558.45847.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/146 +X-Sequence-Number: 4706 + +Shridhar, + +I was looking at the -V/-v and -A/-a settings in pgavd, and really don't=20 +understand how the calculation works. According to the readme, if I set -= +v=20 +to 1000 and -V to 2 (the defaults) for a table with 10,000 rows, pgavd woul= +d=20 +only vacuum after 21,000 rows had been updated. This seems wrong. + +Can you clear this up a little? I'd like to tweak these settings but can'= +t=20 +without being better aquainted with the calculation. + +Also, you may want to reverse your default ratio for Vacuum/analyze frequen= +cy.=20=20 +True, analyze is a less expensive operation than Vacuum, but it's also need= +ed=20 +less often -- only when the *distribution* of data changes. I've seen=20 +databases where the optimal vacuum/analyze frequency was every 10 min/once= +=20 +per day. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Nov 18 21:20:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A2EAAD1D7BD + for ; + Wed, 19 Nov 2003 01:20:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52268-09 + for ; + Tue, 18 Nov 2003 21:20:20 -0400 (AST) +Received: from mail.viatornetworks.com (unknown [216.224.225.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 85822D1D674 + for ; + Tue, 18 Nov 2003 21:20:15 -0400 (AST) +Received: from [10.1.0.6] (216-224-225-54.phxinternet.net [216.224.225.54] + (may be forged)) + by mail.viatornetworks.com (8.9.3/8.9.3) with ESMTP id SAA09099 + for ; Tue, 18 Nov 2003 18:20:02 -0700 +Subject: High Processor consumption +From: Benjamin Bostow +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) +Date: 18 Nov 2003 18:19:14 -0700 +Message-Id: <1069204784.1955.16.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/147 +X-Sequence-Number: 4707 + + +I am running RH 7.3 running Apache 1.3.27-2 and PostgreSQL 7.2.3-5.73. +When having 100+ users connected to my server I notice that postmaster +consumes up wards of 90% of the processor and I hardly am higher than +10% idle. I did notice that when I kill apache and postmaster that my +idle processor percentage goes to 95% or higher. I am looking on ways +that I can find what connections are making the database processes run +so high. If this could also tell which program is accessing it, it would +be helpful. I have look through the documents on performance tuning +postgresql and have adjusted my memory with little effect. I have even +routed all traffic away from the Apache server so no load is on apache. +I do have C programs that run and access the database. Any help will be +greatly appreciated. + +Thanks in advance, +Ben + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 02:33:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CE4B2D1D5A4 + for ; + Wed, 19 Nov 2003 06:33:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05764-06 + for ; + Wed, 19 Nov 2003 02:32:38 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 98256D1B53A + for ; + Wed, 19 Nov 2003 02:32:36 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Tue, 18 Nov 2003 23:32:28 -0700 +Message-ID: <3FBB0E77.4020105@myrealbox.com> +Date: Wed, 19 Nov 2003 12:02:23 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: More detail on settings for pgavd? +References: <200311181558.45847.josh@agliodbs.com> +In-Reply-To: <200311181558.45847.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/149 +X-Sequence-Number: 4709 + +Josh Berkus wrote: + +> Shridhar, +> +> I was looking at the -V/-v and -A/-a settings in pgavd, and really don't +> understand how the calculation works. According to the readme, if I set -v +> to 1000 and -V to 2 (the defaults) for a table with 10,000 rows, pgavd would +> only vacuum after 21,000 rows had been updated. This seems wrong. +> +> Can you clear this up a little? I'd like to tweak these settings but can't +> without being better aquainted with the calculation. +> +> Also, you may want to reverse your default ratio for Vacuum/analyze frequency. +> True, analyze is a less expensive operation than Vacuum, but it's also needed +> less often -- only when the *distribution* of data changes. I've seen +> databases where the optimal vacuum/analyze frequency was every 10 min/once +> per day. + +Will look into it. Give me a day or so. I am planning couple of other patches as +well. May be over week end. + +Is this urgent? + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 02:34:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 87912D1B50A + for ; + Wed, 19 Nov 2003 06:34:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13715-06 + for ; + Wed, 19 Nov 2003 02:34:20 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 5468BD1C4EE + for ; + Wed, 19 Nov 2003 02:34:19 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Tue, 18 Nov 2003 23:34:19 -0700 +Message-ID: <3FBB0EE4.6010805@myrealbox.com> +Date: Wed, 19 Nov 2003 12:04:12 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Benjamin Bostow +Cc: pgsql-performance@postgresql.org +Subject: Re: High Processor consumption +References: <1069204784.1955.16.camel@localhost.localdomain> +In-Reply-To: <1069204784.1955.16.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/150 +X-Sequence-Number: 4710 + +Benjamin Bostow wrote: + +> I am running RH 7.3 running Apache 1.3.27-2 and PostgreSQL 7.2.3-5.73. +> When having 100+ users connected to my server I notice that postmaster +> consumes up wards of 90% of the processor and I hardly am higher than +> 10% idle. I did notice that when I kill apache and postmaster that my +> idle processor percentage goes to 95% or higher. I am looking on ways +> that I can find what connections are making the database processes run +> so high. If this could also tell which program is accessing it, it would +> be helpful. I have look through the documents on performance tuning +> postgresql and have adjusted my memory with little effect. I have even +> routed all traffic away from the Apache server so no load is on apache. +> I do have C programs that run and access the database. Any help will be +> greatly appreciated. + +Routinely the CPU load for postgresql translates to too much low shared buffers +setting for requirement. + +What are your postgresql.conf tunings? Could you please post them? + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 02:54:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3D8DD1D5AB + for ; + Wed, 19 Nov 2003 06:54:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14518-03 + for ; + Wed, 19 Nov 2003 02:54:13 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id C8C3DD1B4E6 + for ; + Wed, 19 Nov 2003 02:54:11 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Tue, 18 Nov 2003 23:54:10 -0700 +Message-ID: <3FBB138C.4090303@myrealbox.com> +Date: Wed, 19 Nov 2003 12:24:04 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> + <3FB9F855.7010905@myrealbox.com> <87oev9lsgs.fsf@news.nerim.net> +In-Reply-To: <87oev9lsgs.fsf@news.nerim.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/151 +X-Sequence-Number: 4711 + +Laurent Martelli wrote: + +>>>>>>"Shridhar" == Shridhar Daithankar writes: +> +> +> Shridhar> Laurent Martelli wrote: +> +> [...] +> +> >> Should I understand that a join on incompatible types (such as +> >> integer and varchar) may lead to bad performances ? +> +> Shridhar> Conversely, you should enforce strict type compatibility +> Shridhar> in comparisons for getting any good plans..:-) +> +> Ha ha, now I understand why a query of mine was so sluggish. +> +> Is there a chance I could achieve the good perfs without having he +> same types ? I've tried a CAST in the query, but it's even a little +> worse than without it. However, using a view to cast integers into +> varchar gives acceptable results (see at the end). +> +> I'm using Postgresql 7.3.4. + +I am stripping the analyze outputs and directly jumping to the end. + +Can you try following? + +1. Make all fields integer in all the table. +2. Try following query +EXPLAIN ANALYZE SELECT * from lists join classes on classes.id=lists.value where +lists.id='16'::integer; + +How does it affect the runtime? + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 05:18:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DCD24D1D612 + for ; + Wed, 19 Nov 2003 09:18:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32767-07 + for ; + Wed, 19 Nov 2003 05:18:23 -0400 (AST) +Received: from p15140235.pureserver.info (sql-info.de [217.160.166.164]) + by svr1.postgresql.org (Postfix) with ESMTP id B5F48D1C50F + for ; + Wed, 19 Nov 2003 05:18:21 -0400 (AST) +Received: by p15140235.pureserver.info (Postfix, from userid 639) + id 77036203A; Wed, 19 Nov 2003 10:18:23 +0100 (CET) +Received: from iwate.sql-info.de (pD9517DFE.dip.t-dialin.net [217.81.125.254]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by p15140235.pureserver.info (Postfix) with ESMTP id 5948CEA1 + for ; + Wed, 19 Nov 2003 10:18:22 +0100 (CET) +From: Ian Barwick +To: pgsql-performance@postgresql.org +Subject: TEXT column and indexing +Date: Wed, 19 Nov 2003 10:18:18 +0100 +User-Agent: KMail/1.5.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311191018.18492.barwick@gmx.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/152 +X-Sequence-Number: 4712 + + +I have this table: + +db=> \d object_property_value + Table "db.object_property_value" + Column | Type | Modifiers +-----------------------+------------------------+-------------------- + obj_property_value_id | integer | not null default nextval(... + obj_property_id | integer | not null + value | text | +Indexes: + "object_property_value_pkey" primary key, btree (obj_property_value_id) + "opv_obj_property_id_ix" btree (obj_property_id) + "opv_v_ix" btree (substr(value, 1, 128)) +Foreign-key constraints: + "object_property_fkey" FOREIGN KEY (obj_property_id) + REFERENCES object_property(obj_property_id) + ON UPDATE CASCADE ON DELETE CASCADE + +(long lines edited for readability). + +The table contains about 250,000 records and will grow at regular intervals. +The 'value' column contains text of various lengths. The table is VACUUMed +and ANALYZEd regularly and waxed on Sunday mornings. Database encoding is +Unicode. Server is 7.4RC1 or 7.4RC2 and will be 7.4 ASAP. + +I want to query this table to match a specific value along +the lines of: + +SELECT obj_property_id + FROM object_property_value opv + WHERE opv.value = 'foo' + +There will only be a few (at the moment 2 or 3) rows exactly matching +'foo'. This query will only be performed with values containing less +than around 100 characters, which account for ca. 10% of all rows in the +table. + +The performance is of course lousy: + +db=> EXPLAIN +db-> SELECT obj_property_id +db-> FROM object_property_value opv +db-> WHERE opv.value = 'foo'; + QUERY PLAN +----------------------------------------------------------------------------- + Seq Scan on object_property_value opv (cost=0.00..12258.26 rows=2 width=4) + Filter: (value = 'foo'::text) +(2 rows) + +However, if I create a VARCHAR field containing the first 128 characters of +the text field and index that, an index scan is used: + +db=> EXPLAIN +db-> SELECT obj_property_id +db-> FROM object_property_value opv +db-> WHERE opv.opv_vc = 'foo'; + QUERY PLAN +------------------------------------------------------------------------------------------- + Index Scan using opv_vc_ix on object_property_value opv (cost=0.00..6.84 +rows=2 width=4) + Index Cond: ((opv_vc)::text = 'foo'::text) + +The question is therefore: can I get an index to work on the TEXT column? It +is currently indexed with: + "opv_v_ix" btree (substr(value, 1, 128)) + +which doesn't appear to have any effect. I am probably missing something +obvious though. I can live with maintaining an extra VARCHAR column but +would like to keep the table as simple as possible. + +(For anyone wondering: yes, I can access the data using tsearch2 - via +a different table in this case - but this is not always appropriate). + + +Thanks for any hints. + + +Ian Barwick +barwick@gmx.net + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 06:01:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F20DED1D729 + for ; + Wed, 19 Nov 2003 10:01:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45224-01 + for ; + Wed, 19 Nov 2003 06:00:52 -0400 (AST) +Received: from stan.aopsys.com (m173.net81-64-15.noos.fr [81.64.15.173]) + by svr1.postgresql.org (Postfix) with ESMTP id A9B82D1D630 + for ; + Wed, 19 Nov 2003 06:00:43 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=news.nerim.net) + by stan.aopsys.com with esmtp (Exim 3.36 #1 (Debian)) + id 1AMP0t-0007ZF-00; Wed, 19 Nov 2003 10:52:43 +0100 +To: Shridhar Daithankar +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> <3FB9F855.7010905@myrealbox.com> + <87oev9lsgs.fsf@news.nerim.net> <3FBB138C.4090303@myrealbox.com> +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 19 Nov 2003 10:52:43 +0100 +In-Reply-To: <3FBB138C.4090303@myrealbox.com> (Shridhar Daithankar's message + of "Wed, 19 Nov 2003 12:24:04 +0530") +Message-ID: <87u150k7mc.fsf@news.nerim.net> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/153 +X-Sequence-Number: 4713 + +>>>>> "Shridhar" == Shridhar Daithankar writes: + + Shridhar> Laurent Martelli wrote: + >>>>>>> "Shridhar" == Shridhar Daithankar + >>>>>>> writes: + Shridhar> Laurent Martelli wrote: + >> [...] >> Should I understand that a join on incompatible types + >> (such as >> integer and varchar) may lead to bad performances ? + Shridhar> Conversely, you should enforce strict type compatibility + Shridhar> in comparisons for getting any good plans..:-) + >> Ha ha, now I understand why a query of mine was so sluggish. Is + >> there a chance I could achieve the good perfs without having he + >> same types ? I've tried a CAST in the query, but it's even a + >> little worse than without it. However, using a view to cast + >> integers into varchar gives acceptable results (see at the end). + >> I'm using Postgresql 7.3.4. + + Shridhar> I am stripping the analyze outputs and directly jumping to + Shridhar> the end. + + Shridhar> Can you try following? + + Shridhar> 1. Make all fields integer in all the table. + +I can't do this because lists.values contains non integer data which +do not refer to a classes.id value. It may sound weird. This is +because it's a generic schema for a transparent persistence framework. + +The solution for me would rather be to have varchar everywhere. + + Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists + Shridhar> join classes on classes.id=lists.value where + Shridhar> lists.id='16'::integer; + + + + Shridhar> How does it affect the runtime? + + Shridhar> Shridhar + + + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.aopsys.com + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 06:20:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32AE9D1D5CF + for ; + Wed, 19 Nov 2003 10:20:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40541-09 + for ; + Wed, 19 Nov 2003 06:19:35 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 86E61D1D80C + for ; + Wed, 19 Nov 2003 06:19:32 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 19 Nov 2003 03:19:30 -0700 +Message-ID: <3FBB43AB.30302@myrealbox.com> +Date: Wed, 19 Nov 2003 15:49:23 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> + <3FB9F855.7010905@myrealbox.com> <87oev9lsgs.fsf@news.nerim.net> + <3FBB138C.4090303@myrealbox.com> <87u150k7mc.fsf@news.nerim.net> +In-Reply-To: <87u150k7mc.fsf@news.nerim.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/154 +X-Sequence-Number: 4714 + +Laurent Martelli wrote: + +>>>>>>"Shridhar" == Shridhar Daithankar writes: +> Shridhar> I am stripping the analyze outputs and directly jumping to +> Shridhar> the end. +> +> Shridhar> Can you try following? +> +> Shridhar> 1. Make all fields integer in all the table. +> +> I can't do this because lists.values contains non integer data which +> do not refer to a classes.id value. It may sound weird. This is +> because it's a generic schema for a transparent persistence framework. + +Fine .I understand. So instead of using a field value, can you use integer +version of that field? (Was that one of your queries used that? I deleted the OP) + + +> The solution for me would rather be to have varchar everywhere. + +You need to cast every occurance of that varchar field appropriately, to start +with. The performance might suffer as well for numbers. + +> Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists +> Shridhar> join classes on classes.id=lists.value where +> Shridhar> lists.id='16'::integer; + +classes.id=lists.value::integer. + +Try that. + +The aim is absolute type compatibility. If types aren't exactly same, the plan +is effectively dead. + + +I would say postgresql enforces good habits in it's application developers, from +a cultural POV. + +Had C refused to compile without such strict type compatibility, we wouldn't +have to worry about 16bit/32bit and 64 bit software. Just upgrade the compiler +and everything is damn good..:-) + +I doubt if C would have so popular with such strict type checking but that is +another issue. I think pascal enforces such strict syntax.. Not sure though.. + + + Shridhar + + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 08:24:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FD49D1D80F + for ; + Wed, 19 Nov 2003 12:24:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59278-10 + for ; + Wed, 19 Nov 2003 08:24:08 -0400 (AST) +Received: from stan.aopsys.com (m173.net81-64-15.noos.fr [81.64.15.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 5999DD1D838 + for ; + Wed, 19 Nov 2003 08:24:05 -0400 (AST) +Received: from localhost ([127.0.0.1] helo=news.nerim.net) + by stan.aopsys.com with esmtp (Exim 3.36 #1 (Debian)) + id 1AMRFc-0007jT-00; Wed, 19 Nov 2003 13:16:04 +0100 +To: Shridhar Daithankar +Cc: pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> <3FB9F855.7010905@myrealbox.com> + <87oev9lsgs.fsf@news.nerim.net> <3FBB138C.4090303@myrealbox.com> + <87u150k7mc.fsf@news.nerim.net> <3FBB43AB.30302@myrealbox.com> +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 19 Nov 2003 13:16:03 +0100 +In-Reply-To: <3FBB43AB.30302@myrealbox.com> (Shridhar Daithankar's message + of "Wed, 19 Nov 2003 15:49:23 +0530") +Message-ID: <87ptfok0zg.fsf@news.nerim.net> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/155 +X-Sequence-Number: 4715 + +>>>>> "Shridhar" == Shridhar Daithankar writes: + +[...] + + Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists + Shridhar> join classes on classes.id=lists.value where + Shridhar> lists.id='16'::integer; + + Shridhar> classes.id=lists.value::integer. + +With classes.id of type integer and lists.value of type varchar, I get +"ERROR: Cannot cast type character varying to integer", which is not +such a surprise. + +Thanks for your help anyway. + + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.aopsys.com + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 08:32:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BDBCED1D838 + for ; + Wed, 19 Nov 2003 12:32:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61503-05 + for ; + Wed, 19 Nov 2003 08:31:56 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id BA29AD1D83B + for ; + Wed, 19 Nov 2003 08:31:52 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 19 Nov 2003 05:31:58 -0700 +Message-ID: <3FBB62B5.20507@myrealbox.com> +Date: Wed, 19 Nov 2003 18:01:49 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Laurent Martelli +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org +Subject: Re: Join on incompatible types +References: + <87k75ym1v7.fsf@news.nerim.net> + <3FB9F855.7010905@myrealbox.com> <87oev9lsgs.fsf@news.nerim.net> + <3FBB138C.4090303@myrealbox.com> <87u150k7mc.fsf@news.nerim.net> + <3FBB43AB.30302@myrealbox.com> <87ptfok0zg.fsf@news.nerim.net> +In-Reply-To: <87ptfok0zg.fsf@news.nerim.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/156 +X-Sequence-Number: 4716 + +Laurent Martelli wrote: + +>>>>>>"Shridhar" == Shridhar Daithankar writes: +> +> +> [...] +> +> Shridhar> 2. Try following query EXPLAIN ANALYZE SELECT * from lists +> Shridhar> join classes on classes.id=lists.value where +> Shridhar> lists.id='16'::integer; +> +> Shridhar> classes.id=lists.value::integer. +> +> With classes.id of type integer and lists.value of type varchar, I get +> "ERROR: Cannot cast type character varying to integer", which is not +> such a surprise. + +Try to_numbr function to get a number out of string. Then cast it to integer. + +http://developer.postgresql.org/docs/postgres/functions-formatting.html + +I hope that works. Don't have postgresql installation handy here.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 10:12:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9D3C2D1D861; Wed, 19 Nov 2003 14:11:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78780-09; Wed, 19 Nov 2003 10:10:53 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP + id 3B30BD1D859; Wed, 19 Nov 2003 10:10:49 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 19 Nov 2003 07:10:51 -0700 +Message-ID: <3FBB79E6.6040701@myrealbox.com> +Date: Wed, 19 Nov 2003 19:40:46 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: More detail on settings for pgavd? +References: <200311181558.45847.josh@agliodbs.com> +In-Reply-To: <200311181558.45847.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/157 +X-Sequence-Number: 4717 + +Josh Berkus wrote: + +> Shridhar, +> +> I was looking at the -V/-v and -A/-a settings in pgavd, and really don't +> understand how the calculation works. According to the readme, if I set -v +> to 1000 and -V to 2 (the defaults) for a table with 10,000 rows, pgavd would +> only vacuum after 21,000 rows had been updated. This seems wrong. + +No. that is correct. + +It is calculated as + +threshold = base + scale*numebr of current rows + +Which translates to + +21,000 = 1000 + 2*1000 + +However I do not agree with this logic entirely. It pegs the next vacuum w.r.t +current table size which is not always a good thing. + +I would rather vacuum the table at 2000 updates, which is what you probably want. + +Furthermore analyze threshold depends upon inserts+updates. I think it should +also depends upon deletes for obvious reasons. + +> Can you clear this up a little? I'd like to tweak these settings but can't +> without being better aquainted with the calculation. + +What did you expected in above example? It is not difficult to tweak +pg_autovacuum calculations. For testing we can play around. + +> Also, you may want to reverse your default ratio for Vacuum/analyze frequency. +> True, analyze is a less expensive operation than Vacuum, but it's also needed +> less often -- only when the *distribution* of data changes. I've seen +> databases where the optimal vacuum/analyze frequency was every 10 min/once +> per day. + +OK vacuum and analyze thresholds are calculated with same formula as shown above + but with different parameters as follows. + +vacthresh = vacbase + vacscale*ntuples +anathresh = anabase + anascale*ntuples + +What you are asking for is + +vacthresh = vacbase*vacscale +anathresh = anabase + anascale*ntuples + +Would that tilt the favour the way you want? i.e. an analyze is triggered when a +fixed *percentage* of table changes but a vacuum is triggered when a fixed +*number of rows* are changed. + +I am all for experimentation. If you have real life data to play with, I can +give you some patches to play around. + +And BTW, this is all brain child of Mathew O.Connor(Correct? I am not good at +either names or spellings). The way I wrote pgavd originally, each table got to +get separate threshold..:-). That was rather a brute force approach. + + Shridhar + + + + + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 12:09:37 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F7B9D1D58C + for ; + Wed, 19 Nov 2003 15:51:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00374-05 + for ; + Wed, 19 Nov 2003 11:51:15 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id A0341D1D587 + for ; + Wed, 19 Nov 2003 11:51:10 -0400 (AST) +Received: (qmail 19165 invoked by uid 500); 19 Nov 2003 15:49:59 -0000 +Date: Wed, 19 Nov 2003 09:49:59 -0600 +From: Bruno Wolff III +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: problem with select count(*) .. +Message-ID: <20031119154959.GA18327@wolff.to> +Mail-Followup-To: Rajesh Kumar Mallah , + pgsql-performance@postgresql.org +References: <3FBC1ADA.4040709@trade-india.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FBC1ADA.4040709@trade-india.com> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/160 +X-Sequence-Number: 4720 + +On Thu, Nov 20, 2003 at 07:07:30 +0530, + Rajesh Kumar Mallah wrote: +> +> If i dump and reload the performance improves and it takes < 1 sec. This +> is what i have been doing since the upgrade. But its not a solution. +> +> The Vacuum full is at the end of a loading batch SQL file which makes lot of +> insert , deletes and updates. + +If a dump and reload fixes your problem, most likely you have a lot of +dead tuples in the table. You might need to run vacuum more often. +You might have an open transaction that is preventing vacuum full +from cleaning up the table. + +From pgsql-performance-owner@postgresql.org Wed Nov 19 12:07:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CC482D1D837 + for ; + Wed, 19 Nov 2003 16:01:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99676-07 + for ; + Wed, 19 Nov 2003 12:00:46 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 570C1D1D59B + for ; + Wed, 19 Nov 2003 12:00:45 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3944212; Wed, 19 Nov 2003 08:01:15 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Shridhar Daithankar +Subject: Re: More detail on settings for pgavd? +Date: Wed, 19 Nov 2003 08:00:11 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: <200311181558.45847.josh@agliodbs.com> + <3FBB0E77.4020105@myrealbox.com> +In-Reply-To: <3FBB0E77.4020105@myrealbox.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311190800.11513.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/159 +X-Sequence-Number: 4719 + +Shridhar, + +> Will look into it. Give me a day or so. I am planning couple of other +> patches as well. May be over week end. + +Thanks, appreciated. As I said, I don't think the settings themselves are +wrong, I think the documentation is. + +What are you patching? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Nov 19 12:07:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31FA5D1D85C + for ; + Wed, 19 Nov 2003 16:07:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04794-04 + for ; + Wed, 19 Nov 2003 12:06:38 -0400 (AST) +Received: from mystic.root.hu (mystic.root.hu [62.68.166.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 7508BD1D8DE + for ; + Wed, 19 Nov 2003 12:05:55 -0400 (AST) +Received: from [213.163.10.103] (helo=fejleszt4) + by mystic.root.hu with asmtp (Exim 3.36 #1 (Debian)) + id 1AMUpr-0002ah-00 (authenticated sender: + 44b23a02ffc625b094b01917b5736f32) + for ; Wed, 19 Nov 2003 17:05:43 +0100 +Message-ID: <01e301c3aeb6$bff63350$0403a8c0@fejleszt4> +From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" +To: +References: <01a601c3aac1$281e72c0$0403a8c0@fejleszt4> + <5187.1068843554@sss.pgh.pa.us> +Subject: Re: constant vs function param differs in performance +Date: Wed, 19 Nov 2003 17:04:01 +0100 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Authenticated-Sender: 44b23a02ffc625b094b01917b5736f32 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/158 +X-Sequence-Number: 4718 + +Dear Tom, + +Thanks for your early response. + +An addition: the nastier difference increased by adding an index (it was an +essential index for this query): + + func with param improved from 2700ms to 2300ms + func with constant improved from 400ms to 31ms + inline query improved from 390ms to 2ms + +So am I reading correct and it is completely normal and can't be helped? +(couldn't have tried 7.4 yet) + +In case it reveals something: + +------------------------------- cut here ------------------------------- +SELECT field FROM +(SELECT field, sum(something)=0 AS boolvalue + FROM + (SELECT * FROM subselect1 NATURAL LEFT JOIN subselect2 + UNION + SELECT * FROM subselect3 NATURAL LEFT JOIN subselect4 + ) AS u + GROUP BY field) AS t +WHERE not boolvalue +ORDER BY simple_sql_func_returns_bool(field) DESC +LIMIT 1; +------------------------------- cut here ------------------------------- + +G. +----- Original Message ----- +From: "Tom Lane" +Sent: Friday, November 14, 2003 9:59 PM + + +> "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: +> > I have two SQL function that produce different times and I can't +understand +> > why. +> +> The planner often produces different plans when there are constants in +> WHERE clauses than when there are variables, because it can get more +> accurate ideas of how many rows will be retrieved. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 13:15:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07F96D1B510 + for ; + Wed, 19 Nov 2003 16:28:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06681-07 + for ; + Wed, 19 Nov 2003 12:28:03 -0400 (AST) +Received: from email03.aon.at (WARSL402PIP6.highway.telekom.at [195.3.96.93]) + by svr1.postgresql.org (Postfix) with SMTP id 6C82CD1D837 + for ; + Wed, 19 Nov 2003 12:28:02 -0400 (AST) +Received: (qmail 562334 invoked from network); 19 Nov 2003 16:27:46 -0000 +Received: from m160p013.dipool.highway.telekom.at (HELO cantor) + ([62.46.9.237]) (envelope-sender ) + by qmail3rs.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 19 Nov 2003 16:27:46 -0000 +From: Manfred Koizar +To: Ian Barwick +Cc: pgsql-performance@postgresql.org +Subject: Re: TEXT column and indexing +Date: Wed, 19 Nov 2003 17:26:01 +0100 +Message-ID: +References: <200311191018.18492.barwick@gmx.net> +In-Reply-To: <200311191018.18492.barwick@gmx.net> +X-Mailer: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/162 +X-Sequence-Number: 4722 + +On Wed, 19 Nov 2003 10:18:18 +0100, Ian Barwick +wrote: +>Indexes: +> [...] +> "opv_v_ix" btree (substr(value, 1, 128)) + +>SELECT obj_property_id +> FROM object_property_value opv +> WHERE opv.value = 'foo' + +Try + ... WHERE substr(opv.value, 1, 128) = 'foo' + +HTH. +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Wed Nov 19 13:12:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 91230D1B550 + for ; + Wed, 19 Nov 2003 16:35:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09672-06 + for ; + Wed, 19 Nov 2003 12:35:22 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id A155DD1D80F + for ; + Wed, 19 Nov 2003 12:35:21 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 9883A3547C; Wed, 19 Nov 2003 08:35:05 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 96FC935466; Wed, 19 Nov 2003 08:35:05 -0800 (PST) +Date: Wed, 19 Nov 2003 08:35:05 -0800 (PST) +From: Stephan Szabo +To: Ian Barwick +Cc: pgsql-performance@postgresql.org +Subject: Re: TEXT column and indexing +In-Reply-To: <200311191018.18492.barwick@gmx.net> +Message-ID: <20031119083025.R85482@megazone.bigpanda.com> +References: <200311191018.18492.barwick@gmx.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/161 +X-Sequence-Number: 4721 + + +On Wed, 19 Nov 2003, Ian Barwick wrote: + +> +> I have this table: +> +> db=> \d object_property_value +> Table "db.object_property_value" +> Column | Type | Modifiers +> -----------------------+------------------------+-------------------- +> obj_property_value_id | integer | not null default nextval(... +> obj_property_id | integer | not null +> value | text | +> Indexes: +> "object_property_value_pkey" primary key, btree (obj_property_value_id) +> "opv_obj_property_id_ix" btree (obj_property_id) +> "opv_v_ix" btree (substr(value, 1, 128)) +> Foreign-key constraints: +> "object_property_fkey" FOREIGN KEY (obj_property_id) +> REFERENCES object_property(obj_property_id) +> ON UPDATE CASCADE ON DELETE CASCADE +> I want to query this table to match a specific value along +> the lines of: +> +> SELECT obj_property_id +> FROM object_property_value opv +> WHERE opv.value = 'foo' +> +> The question is therefore: can I get an index to work on the TEXT column? It +> is currently indexed with: +> "opv_v_ix" btree (substr(value, 1, 128)) +> +> which doesn't appear to have any effect. I am probably missing something +> obvious though. I can live with maintaining an extra VARCHAR column but + +You probably need to be querying like: +WHERE substr(value,1,128)='foo'; +in order to use that index. + +While substr(txtcol, 1,128) happens to have the property that it would be +probably be useful in a search against a short constant string, that's an +internal property of that function. + +From pgsql-performance-owner@postgresql.org Wed Nov 19 13:28:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C1416D1B50F; Wed, 19 Nov 2003 17:08:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22433-01; Wed, 19 Nov 2003 13:07:58 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 75B53D1CB08; Wed, 19 Nov 2003 13:06:33 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3944461; Wed, 19 Nov 2003 09:07:20 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Shridhar Daithankar +Subject: Re: More detail on settings for pgavd? +Date: Wed, 19 Nov 2003 09:06:15 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <3FBB79E6.6040701@myrealbox.com> +In-Reply-To: <3FBB79E6.6040701@myrealbox.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311190906.15828.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/163 +X-Sequence-Number: 4723 + +Shridhar, + +> However I do not agree with this logic entirely. It pegs the next vacuum +> w.r.t current table size which is not always a good thing. + +No, I think the logic's fine, it's the numbers which are wrong. We want to +vacuum when updates reach between 5% and 15% of total rows. NOT when +updates reach 110% of total rows ... that's much too late. + +Hmmm ... I also think the threshold level needs to be lowered; I guess the +purpose was to prevent continuous re-vacuuuming of small tables? +Unfortunately, in the current implementation, the result is tha small tables +never get vacuumed at all. + +So for defaults, I would peg -V at 0.1 and -v at 100, so our default +calculation for a table with 10,000 rows is: + +100 + ( 0.1 * 10,000 ) = 1100 rows. + +> I would rather vacuum the table at 2000 updates, which is what you probably +> want. + +Not necessarily. This would be painful if the table has 10,000,000 rows. It +*should* be based on a % of rows. + +> Furthermore analyze threshold depends upon inserts+updates. I think it +> should also depends upon deletes for obvious reasons. + +Yes. Vacuum threshold is counting deletes, I hope? + +> What did you expected in above example? It is not difficult to tweak +> pg_autovacuum calculations. For testing we can play around. + +Can I set the settings to decimals, or are they integers? + +> vacthresh = vacbase*vacscale +> anathresh = anabase + anascale*ntuples + +Nope, see above. + +My comment about the frequency of vacuums vs. analyze is that currently the +*default* is to analyze twice as often as you vacuum. Based on my +experiece as a PG admin on a variety of databases, I believe that the default +should be to analyze half as often as you vacuum. + +> I am all for experimentation. If you have real life data to play with, I +> can give you some patches to play around. + +I will have real data very soon ..... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Nov 19 15:26:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 020C5D1C50F + for ; + Wed, 19 Nov 2003 18:39:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35921-04 + for ; + Wed, 19 Nov 2003 14:38:47 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id 218FED1B578 + for ; + Wed, 19 Nov 2003 14:38:44 -0400 (AST) +Received: (qmail 26079 invoked by uid 0); 19 Nov 2003 18:38:28 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 19 Nov 2003 18:38:28 -0000 +Received: (qmail 19544 invoked by uid 1000); 19 Nov 2003 18:38:24 -0000 +Date: Wed, 19 Nov 2003 19:38:24 +0100 +From: Ryszard Lach +To: Bruce Momjian +Cc: pgsql-performance@postgresql.org +Subject: Re: duration logging setting in 7.4 +Message-ID: <20031119183824.GL18018@siaco.id.pl> +Reply-To: Ryszard Lach +References: <20031118091646.GA8223@siaco.id.pl> + <200311181507.hAIF7mX04577@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <200311181507.hAIF7mX04577@candle.pha.pa.us> +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/167 +X-Sequence-Number: 4727 + +On Tue, Nov 18, 2003 at 10:07:48AM -0500, Bruce Momjian wrote: +> +> Wow, that is strange. If you don't use syslog, do you see the proper +> output? + +I've just checked this. It behaves exactly the same way. + + +> If you turn on log_statement, do you see the statements? + +If I turn on log_min_duration_statement (i.e. set to 0), log_statement and +log_duration, then I receive something like that + +Nov 17 22:33:27 postgres[22945]: [29231-1] LOG: statement: +Nov 17 22:33:27 postgres[22945]: [29232-1] LOG: duration: 0.198 ms +Nov 17 22:33:27 postgres[22945]: [29233-1] LOG: duration: 0.198 ms statement: +Nov 17 22:33:27 postgres[22946]: [29231-1] LOG: statement: +Nov 17 22:33:27 postgres[22946]: [29232-1] LOG: duration: 0.191 ms +Nov 17 22:33:27 postgres[22946]: [29233-1] LOG: duration: 0.191 ms statement: +Nov 17 22:33:27 postgres[22678]: [147134-1] LOG: statement: select * from cms where id=1465 +Nov 17 22:33:27 postgres[22679]: [154907-1] LOG: statement: +Nov 17 22:33:27 postgres[22679]: [154908-1] LOG: duration: 0.867 ms +Nov 17 22:33:27 postgres[22679]: [154909-1] LOG: duration: 0.867 ms statement: +Nov 17 22:33:27 postgres[22678]: [147135-1] LOG: duration: 1.458 ms +Nov 17 22:33:27 postgres[22678]: [147136-1] LOG: duration: 1.458 ms statement: select * from cms where id=1465 +Nov 17 22:33:27 postgres[22680]: [158366-1] LOG: statement: +Nov 17 22:33:27 postgres[22680]: [158367-1] LOG: duration: 0.620 ms +Nov 17 22:33:27 postgres[22680]: [158368-1] LOG: duration: 0.620 ms statement: +Nov 17 22:33:27 postgres[22681]: [161294-1] LOG: statement: +Nov 17 22:33:27 postgres[22681]: [161295-1] LOG: duration: 0.650 ms + +It seems, that log_duration is responsible only for "duration:" lines, +log_statement - for "statement:" ones, and "log_min_duration_statement" - for +"duration: .* statement:". I think, that the above output should exclude losing +of data by syslog from further delibarations. Do you thing that could be +a bug? + +There is another one thing: logs from the same database running on 7.3 and the same +application contained lines like 'select getdatabaseencoding()', 'select +datestyle()' and similar (not used by application explicite, probably +added by JDBC driver), now they are missed - maybe this is the +problem? + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Wed Nov 19 14:59:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EBE4DD1B57C + for ; + Wed, 19 Nov 2003 18:59:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38736-06 + for ; + Wed, 19 Nov 2003 14:58:32 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 716DFD1BB42 + for ; + Wed, 19 Nov 2003 14:58:29 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAJIwR810214; + Wed, 19 Nov 2003 13:58:27 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311191858.hAJIwR810214@candle.pha.pa.us> +Subject: Re: duration logging setting in 7.4 +In-Reply-To: <20031119183824.GL18018@siaco.id.pl> +To: Ryszard Lach +Date: Wed, 19 Nov 2003 13:58:27 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/164 +X-Sequence-Number: 4724 + +Ryszard Lach wrote: +> If I turn on log_min_duration_statement (i.e. set to 0), log_statement and +> log_duration, then I receive something like that +> +> Nov 17 22:33:27 postgres[22945]: [29231-1] LOG: statement: +> Nov 17 22:33:27 postgres[22945]: [29232-1] LOG: duration: 0.198 ms +> Nov 17 22:33:27 postgres[22945]: [29233-1] LOG: duration: 0.198 ms statement: +> Nov 17 22:33:27 postgres[22946]: [29231-1] LOG: statement: +> Nov 17 22:33:27 postgres[22946]: [29232-1] LOG: duration: 0.191 ms +> Nov 17 22:33:27 postgres[22946]: [29233-1] LOG: duration: 0.191 ms statement: +> Nov 17 22:33:27 postgres[22678]: [147134-1] LOG: statement: select * from cms where id=1465 +> Nov 17 22:33:27 postgres[22679]: [154907-1] LOG: statement: +> Nov 17 22:33:27 postgres[22679]: [154908-1] LOG: duration: 0.867 ms +> Nov 17 22:33:27 postgres[22679]: [154909-1] LOG: duration: 0.867 ms statement: +> Nov 17 22:33:27 postgres[22678]: [147135-1] LOG: duration: 1.458 ms +> Nov 17 22:33:27 postgres[22678]: [147136-1] LOG: duration: 1.458 ms statement: select * from cms where id=1465 +> Nov 17 22:33:27 postgres[22680]: [158366-1] LOG: statement: +> Nov 17 22:33:27 postgres[22680]: [158367-1] LOG: duration: 0.620 ms +> Nov 17 22:33:27 postgres[22680]: [158368-1] LOG: duration: 0.620 ms statement: +> Nov 17 22:33:27 postgres[22681]: [161294-1] LOG: statement: +> Nov 17 22:33:27 postgres[22681]: [161295-1] LOG: duration: 0.650 ms +> +> It seems, that log_duration is responsible only for "duration:" lines, +> log_statement - for "statement:" ones, and "log_min_duration_statement" - for +> "duration: .* statement:". I think, that the above output should exclude losing +> of data by syslog from further delibarations. Do you thing that could be +> a bug? + +Yes, the problem is not related to syslog. Are you using prepared +queries, perhaps? I don't think those show the query, but it seems we +should display something better than blanks. + +> There is another one thing: logs from the same database running on 7.3 and the same +> application contained lines like 'select getdatabaseencoding()', 'select +> datestyle()' and similar (not used by application explicite, probably +> added by JDBC driver), now they are missed - maybe this is the +> problem? + +No, those are missing because the new 7.4 wire protocol doesn't require +those queries anymore --- the data is send automatically. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Nov 19 15:15:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5FC6D1CCAC + for ; + Wed, 19 Nov 2003 19:15:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45719-03 + for ; + Wed, 19 Nov 2003 15:14:53 -0400 (AST) +Received: from p15140235.pureserver.info (sql-info.de [217.160.166.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 11F0DD1BB13 + for ; + Wed, 19 Nov 2003 15:14:52 -0400 (AST) +Received: by p15140235.pureserver.info (Postfix, from userid 639) + id E38EA203A; Wed, 19 Nov 2003 20:14:50 +0100 (CET) +Received: from iwate.sql-info.de (pD9517DFE.dip.t-dialin.net [217.81.125.254]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by p15140235.pureserver.info (Postfix) with ESMTP + id 03C1CEA1; Wed, 19 Nov 2003 20:14:49 +0100 (CET) +From: Ian Barwick +To: Stephan Szabo +Subject: Re: TEXT column and indexing +Date: Wed, 19 Nov 2003 20:13:42 +0100 +User-Agent: KMail/1.5.1 +Cc: pgsql-performance@postgresql.org +References: <200311191018.18492.barwick@gmx.net> + <20031119083025.R85482@megazone.bigpanda.com> +In-Reply-To: <20031119083025.R85482@megazone.bigpanda.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311192013.42574.barwick@gmx.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/165 +X-Sequence-Number: 4725 + +On Wednesday 19 November 2003 17:35, Stephan Szabo wrote: +> On Wed, 19 Nov 2003, Ian Barwick wrote: +> > I have this table: +(...) +> +> You probably need to be querying like: +> WHERE substr(value,1,128)='foo'; +> in order to use that index. +> +> While substr(txtcol, 1,128) happens to have the property that it would be +> probably be useful in a search against a short constant string, that's an +> internal property of that function. + +That's the one :-). Thanks! + +Ian Barwick +barwick@gmx.net + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 15:17:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E595DD1CCDE + for ; + Wed, 19 Nov 2003 19:17:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38718-08 + for ; + Wed, 19 Nov 2003 15:16:52 -0400 (AST) +Received: from p15140235.pureserver.info (sql-info.de [217.160.166.164]) + by svr1.postgresql.org (Postfix) with ESMTP id 16D3DD1B53A + for ; + Wed, 19 Nov 2003 15:16:51 -0400 (AST) +Received: by p15140235.pureserver.info (Postfix, from userid 639) + id DA3BF203A; Wed, 19 Nov 2003 20:16:51 +0100 (CET) +Received: from iwate.sql-info.de (pD9517DFE.dip.t-dialin.net [217.81.125.254]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by p15140235.pureserver.info (Postfix) with ESMTP + id AD4EEEA1; Wed, 19 Nov 2003 20:16:50 +0100 (CET) +From: Ian Barwick +To: Manfred Koizar +Subject: Re: TEXT column and indexing +Date: Wed, 19 Nov 2003 20:16:48 +0100 +User-Agent: KMail/1.5.1 +References: <200311191018.18492.barwick@gmx.net> + +In-Reply-To: +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311192016.48447.barwick@gmx.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/166 +X-Sequence-Number: 4726 + +On Wednesday 19 November 2003 17:26, you wrote: +> On Wed, 19 Nov 2003 10:18:18 +0100, Ian Barwick +> +> wrote: +> >Indexes: +> > [...] +> > "opv_v_ix" btree (substr(value, 1, 128)) +> > +> >SELECT obj_property_id +> > FROM object_property_value opv +> > WHERE opv.value = 'foo' +> +> Try +> ... WHERE substr(opv.value, 1, 128) = 'foo' +> +> HTH. + +Yup: +db=> explain +db-> SELECT obj_property_id +db-> FROM object_property_value opv +db-> WHERE substr(opv.value,1,128) = 'foo'; + QUERY PLAN +------------------------------------------------------------------------------------------------ + Index Scan using opv_v_ix on object_property_value opv (cost=0.00..4185.78 +rows=1101 width=4) + Index Cond: (substr(value, 1, 128) = 'foo'::text) +(2 rows) + +Many thanks + +Ian Barwick +barwick@gmx.net + + +From pgsql-performance-owner@postgresql.org Wed Nov 19 15:34:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 412B5D1B523 + for ; + Wed, 19 Nov 2003 19:29:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47470-02 + for ; + Wed, 19 Nov 2003 15:29:01 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id 53390D1C96A + for ; + Wed, 19 Nov 2003 15:28:59 -0400 (AST) +Received: (qmail 8593 invoked by uid 0); 19 Nov 2003 19:28:59 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 19 Nov 2003 19:28:59 -0000 +Received: (qmail 19907 invoked by uid 1000); 19 Nov 2003 19:28:55 -0000 +Date: Wed, 19 Nov 2003 20:28:55 +0100 +From: Ryszard Lach +To: Bruce Momjian +Cc: pgsql-performance@postgresql.org +Subject: Re: duration logging setting in 7.4 +Message-ID: <20031119192855.GO18018@siaco.id.pl> +Reply-To: Ryszard Lach +References: <20031119183824.GL18018@siaco.id.pl> + <200311191858.hAJIwR810214@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <200311191858.hAJIwR810214@candle.pha.pa.us> +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/168 +X-Sequence-Number: 4728 + +On Wed, Nov 19, 2003 at 01:58:27PM -0500, Bruce Momjian wrote: +> Ryszard Lach wrote: +> +> > There is another one thing: logs from the same database running on 7.3 and the same +> > application contained lines like 'select getdatabaseencoding()', 'select +> > datestyle()' and similar (not used by application explicite, probably +> > added by JDBC driver), now they are missed - maybe this is the +> > problem? +> +> No, those are missing because the new 7.4 wire protocol doesn't require +> those queries anymore --- the data is send automatically. +> + +Mayby this is a solution? Because of some +charset-related problems we are still using an old (AFAiR modified) +version of JDBC driver. I'm not a programmer, but I think and don't know +what JDBC driver does, but maybe it sends from client side those queries +and server doesn't know what to do with them? I'll ask our programmers +to try with 7.4 driver and tell you about results. + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Wed Nov 19 15:45:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 22E74D1C96A + for ; + Wed, 19 Nov 2003 19:42:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48862-05 + for ; + Wed, 19 Nov 2003 15:42:27 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 454BFD1D279 + for ; + Wed, 19 Nov 2003 15:42:25 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hAJJgKR15032; + Wed, 19 Nov 2003 14:42:20 -0500 (EST) +From: Bruce Momjian +Message-Id: <200311191942.hAJJgKR15032@candle.pha.pa.us> +Subject: Re: duration logging setting in 7.4 +In-Reply-To: <20031119192855.GO18018@siaco.id.pl> +To: Ryszard Lach +Date: Wed, 19 Nov 2003 14:42:20 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/169 +X-Sequence-Number: 4729 + +Ryszard Lach wrote: +> On Wed, Nov 19, 2003 at 01:58:27PM -0500, Bruce Momjian wrote: +> > Ryszard Lach wrote: +> > +> > > There is another one thing: logs from the same database running on 7.3 and the same +> > > application contained lines like 'select getdatabaseencoding()', 'select +> > > datestyle()' and similar (not used by application explicite, probably +> > > added by JDBC driver), now they are missed - maybe this is the +> > > problem? +> > +> > No, those are missing because the new 7.4 wire protocol doesn't require +> > those queries anymore --- the data is send automatically. +> > +> +> Mayby this is a solution? Because of some +> charset-related problems we are still using an old (AFAiR modified) +> version of JDBC driver. I'm not a programmer, but I think and don't know +> what JDBC driver does, but maybe it sends from client side those queries +> and server doesn't know what to do with them? I'll ask our programmers +> to try with 7.4 driver and tell you about results. + +Also, try plain psql and issue a query and see if it appears. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Tue Nov 18 21:37:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4D84D1D84D + for ; + Wed, 19 Nov 2003 01:37:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60988-05 + for ; + Tue, 18 Nov 2003 21:37:12 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id A6370D1D630 + for ; + Tue, 18 Nov 2003 21:36:58 -0400 (AST) +Received: (qmail 18951 invoked from network); 19 Nov 2003 01:38:05 -0000 +Received: from unknown (HELO trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 19 Nov 2003 01:38:05 -0000 +Message-ID: <3FBC1ADA.4040709@trade-india.com> +Date: Thu, 20 Nov 2003 07:07:30 +0530 +From: Rajesh Kumar Mallah +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: problem with select count(*) .. +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/148 +X-Sequence-Number: 4708 + + +Ever Since i upgraded to 7.4RC2 i am facing problem +with select count(*) . In 7.3 the problem was not there +select count(*) from data_bank.profiles used to return almost +instantly , but in 7.4 + +explain analyze SELECT count(*) from data_bank.profiles; + QUERY PLAN +--------------------------------------------------------------------------- + Aggregate (cost=48361.30..48361.30 rows=1 width=0) (actual time=23456.870..23456.871 rows=1 loops=1) + -> Seq Scan on profiles (cost=0.00..47431.84 rows=371784 width=0) (actual time=12174.999..23262.823 rows=123928 loops=1) + Total runtime: 23458.460 ms +(3 rows) + +tradein_clients=# + +If i dump and reload the performance improves and it takes < 1 sec. This +is what i have been doing since the upgrade. But its not a solution. + +The Vacuum full is at the end of a loading batch SQL file which makes lot of +insert , deletes and updates. + +Regds +Mallah. + + + + + + +VACUUM FULL VERBOSE ANALYZE data_bank.profiles; + INFO: vacuuming "data_bank.profiles" + INFO: "profiles": found 430524 removable, 371784 nonremovable row versions in 43714 pages + INFO: index "profiles_pincode" now contains 371784 row versions in 3419 pages + INFO: index "profiles_city" now contains 371784 row versions in 3471 pages + INFO: index "profiles_branch" now contains 371784 row versions in 2237 pages + INFO: index "profiles_area_code" now contains 371784 row versions in 2611 pages + INFO: index "profiles_source" now contains 371784 row versions in 3165 pages + INFO: index "co_name_index_idx" now contains 371325 row versions in 3933 pages + INFO: index "address_index_idx" now contains 371490 row versions in 4883 pages + INFO: index "profiles_exp_cat" now contains 154836 row versions in 2181 pages + INFO: index "profiles_imp_cat" now contains 73678 row versions in 1043 pages + INFO: index "profiles_manu_cat" now contains 87124 row versions in 1201 pages + INFO: index "profiles_serv_cat" now contains 19340 row versions in 269 pages + INFO: index "profiles_pid" now contains 371784 row versions in 817 pages + INFO: index "profiles_pending_branch_id" now contains 0 row versions in 1 pages + INFO: "profiles": moved 0 row versions, truncated 43714 to 43714 pages + INFO: vacuuming "pg_toast.pg_toast_67748379" + INFO: "pg_toast_67748379": found 0 removable, 74 nonremovable row versions in 17 pages + INFO: index "pg_toast_67748379_index" now contains 74 row versions in 2 pages + INFO: "pg_toast_67748379": moved 1 row versions, truncated 17 to 17 pages + INFO: index "pg_toast_67748379_index" now contains 74 row versions in 2 pages + INFO: analyzing "data_bank.profiles" + INFO: "profiles": 43714 pages, 3000 rows sampled, 3634 estimated total rows +VACUUM +Time: 1001525.19 ms + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 00:40:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DD402D1B506 + for ; + Thu, 20 Nov 2003 04:40:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37911-08 + for ; + Thu, 20 Nov 2003 00:39:55 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B510D1B4F6 + for ; + Thu, 20 Nov 2003 00:39:54 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAK4dl19001172; + Wed, 19 Nov 2003 23:39:47 -0500 (EST) +To: Joel Jacobson +Cc: pgsql-performance@postgresql.org +Subject: Re: Backup/restore of pg_statistics +In-reply-to: <1069080680.3fb8e068eb941@mail.jacobson.be> +References: <1069080680.3fb8e068eb941@mail.jacobson.be> +Comments: In-reply-to Joel Jacobson + message dated "Mon, 17 Nov 2003 15:51:20 +0100" +Date: Wed, 19 Nov 2003 23:39:47 -0500 +Message-ID: <1171.1069303187@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/170 +X-Sequence-Number: 4730 + +Joel Jacobson writes: +> I understand that it is not possible to occasionally re-plan the queries in a +> PL/pgSQL function without dropping and re-creating the function. + +Huh? You only need to start a fresh connection. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 20 01:58:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 20B42D1CA63 + for ; + Thu, 20 Nov 2003 05:58:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59838-01 + for ; + Thu, 20 Nov 2003 01:58:20 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id E1F9DD1B592 + for ; + Thu, 20 Nov 2003 01:58:18 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 19 Nov 2003 22:58:19 -0700 +Message-ID: <3FBC57F5.8070705@myrealbox.com> +Date: Thu, 20 Nov 2003 11:28:13 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Benjamin Bostow , + Performance +Subject: Re: High Processor consumption +References: <1069204784.1955.16.camel@localhost.localdomain> + <3FBB0EE4.6010805@myrealbox.com> + <1069264247.1955.25.camel@localhost.localdomain> +In-Reply-To: <1069264247.1955.25.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/171 +X-Sequence-Number: 4731 + +Benjamin Bostow wrote: + +> I haven't modified any of the setting. I did try changing shmmax from +> 32MB to 256MB but didn't see much change in the processor usage. The +> init script that runs to start the server uses the following: +> su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p +> /usr/bin/postmaster -o \"-i -N 128 -B 256\" start > /dev/null 2>&1" < +> /dev/null + +Lol.. -B 256 does not mean 256MB of buffers. It means 2MB of buffers. Each +buffer is of 8K. Try upping it to a 1000 or 2000 +> +> I haven't modified postgresql.conf yet but am going through a book on +> performance tuning the server. If you can provide any suggestions or +> help as I am new to postgres it would be appreciated. + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + + HTH + + Shridhar + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 03:24:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 520C1D1C9C0; Thu, 20 Nov 2003 07:24:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76556-01; Thu, 20 Nov 2003 03:23:36 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP + id 75C9DD1C9E5; Thu, 20 Nov 2003 03:23:33 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Thu, 20 Nov 2003 00:23:33 -0700 +Message-ID: <3FBC6BED.9090809@myrealbox.com> +Date: Thu, 20 Nov 2003 12:53:25 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: More detail on settings for pgavd? +References: <200311181558.45847.josh@agliodbs.com> + <3FBB79E6.6040701@myrealbox.com> + <200311190906.15828.josh@agliodbs.com> +In-Reply-To: <200311190906.15828.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/172 +X-Sequence-Number: 4732 + +Josh Berkus wrote: + +> Shridhar, + >>However I do not agree with this logic entirely. It pegs the next vacuum +>>w.r.t current table size which is not always a good thing. +> +> +> No, I think the logic's fine, it's the numbers which are wrong. We want to +> vacuum when updates reach between 5% and 15% of total rows. NOT when +> updates reach 110% of total rows ... that's much too late. + +Well, looks like thresholds below 1 should be norm rather than exception. + +> Hmmm ... I also think the threshold level needs to be lowered; I guess the +> purpose was to prevent continuous re-vacuuuming of small tables? +> Unfortunately, in the current implementation, the result is tha small tables +> never get vacuumed at all. +> +> So for defaults, I would peg -V at 0.1 and -v at 100, so our default +> calculation for a table with 10,000 rows is: +> +> 100 + ( 0.1 * 10,000 ) = 1100 rows. + +I would say -V 0.2-0.4 could be great as well. Fact to emphasize is that +thresholds less than 1 should be used. + +>>Furthermore analyze threshold depends upon inserts+updates. I think it +>>should also depends upon deletes for obvious reasons. +> Yes. Vacuum threshold is counting deletes, I hope? + +It does. + +> My comment about the frequency of vacuums vs. analyze is that currently the +> *default* is to analyze twice as often as you vacuum. Based on my +> experiece as a PG admin on a variety of databases, I believe that the default +> should be to analyze half as often as you vacuum. + +OK. + +>>I am all for experimentation. If you have real life data to play with, I +>>can give you some patches to play around. +> I will have real data very soon ..... + +I will submit a patch that would account deletes in analyze threshold. Since you +want to delay the analyze, I would calculate analyze count as + +n=updates + inserts *-* deletes + +Rather than current "n = updates + inserts". Also update readme about examples +and analyze frequency. + +What does statistics gather BTW? Just number of rows or something else as well? +I think I would put that on Hackers separately. + +I am still wary of inverting vacuum analyze frequency. You think it is better to +set inverted default rather than documenting it? + + Shridhar + + +From pgsql-hackers-owner@postgresql.org Thu Nov 20 10:31:58 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3A209D1B506; Thu, 20 Nov 2003 14:31:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42543-02; Thu, 20 Nov 2003 10:31:22 -0400 (AST) +Received: from mta7.srv.hcvlny.cv.net (mta7.srv.hcvlny.cv.net [167.206.5.74]) + by svr1.postgresql.org (Postfix) with ESMTP + id 870C2D1B520; Thu, 20 Nov 2003 10:31:12 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta7.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HON00ERTMZ3G2@mta7.srv.hcvlny.cv.net>; Thu, + 20 Nov 2003 09:30:42 -0500 (EST) +Date: Thu, 20 Nov 2003 09:30:43 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [PERFORM] More detail on settings for pgavd? +In-reply-to: <3FBC6BED.9090809@myrealbox.com> +To: Shridhar Daithankar +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBCD013.3030402@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <3FBB79E6.6040701@myrealbox.com> <200311190906.15828.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1117 +X-Sequence-Number: 47405 + +Shridhar Daithankar wrote: + +> Josh Berkus wrote: +> +>> Shridhar, +> +> >>However I do not agree with this logic entirely. It pegs the next +> vacuum +> +>>> w.r.t current table size which is not always a good thing. +>> +Ok, what do you recommend? The point of two separate variables allows +you to specify if you want vacuum based on a fixed number, based on +table size or something inbetween. + +>> +>> No, I think the logic's fine, it's the numbers which are wrong. We +>> want to vacuum when updates reach between 5% and 15% of total rows. +>> NOT when updates reach 110% of total rows ... that's much too late. +> +For small tables, you don't need to vacuum too often. In the testing I +did a small table ~100 rows, didn't really show significant performance +degredation until it had close to 1000 updates. For large tables, +vacuum is so expensive, that you don't want to do it very often, and +scanning the whole table when there is only 5% wasted space is not very +helpful. + +>> Hmmm ... I also think the threshold level needs to be lowered; I +>> guess the purpose was to prevent continuous re-vacuuuming of small +>> tables? Unfortunately, in the current implementation, the result is +>> tha small tables never get vacuumed at all. +>> +>> So for defaults, I would peg -V at 0.1 and -v at 100, so our default +>> calculation for a table with 10,000 rows is: +>> +>> 100 + ( 0.1 * 10,000 ) = 1100 rows. +> +Yes, the I set the defaults a little high perhaps so as to err on the +side of caution. I didn't want people to say pg_autovacuum kills the +performance of my server. A small table will get vacuumed, just not +until it has reached the threshold. So a table with 100 rows, will get +vacuumed after 1200 updates / deletes. In my testing it showed that +there was no major performance problems until you reached several +thousand updates / deletes. + +>>> Furthermore analyze threshold depends upon inserts+updates. I think it +>>> should also depends upon deletes for obvious reasons. +>> +>> Yes. Vacuum threshold is counting deletes, I hope? +> +> It does. +> +>> My comment about the frequency of vacuums vs. analyze is that +>> currently the *default* is to analyze twice as often as you +>> vacuum. Based on my experiece as a PG admin on a variety of +>> databases, I believe that the default should be to analyze half as +>> often as you vacuum. +> +HUH? analyze is very very cheap compared to vacuum. Why not do it more +often? + +>>> I am all for experimentation. If you have real life data to play +>>> with, I +>>> can give you some patches to play around. +>> +>> I will have real data very soon ..... +> +> I will submit a patch that would account deletes in analyze threshold. +> Since you want to delay the analyze, I would calculate analyze count as + +deletes are already accounted for in the analyze threshold. + +> I am still wary of inverting vacuum analyze frequency. You think it is +> better to set inverted default rather than documenting it? + +I think inverting the vacuum and analyze frequency is wrong. + +What I think I am hearing is that people would like very much to be able +to tweak the settings of pg_autovacuum for individual tables / databases +etc. So that you could set certain tables to be vacuumed more +agressivly than others. I agree this would be a good and welcome +addition. I hope have time to work on this at some point, but in the +near future I won't. + +Matthew + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 11:00:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 805E0D1B4E6; Thu, 20 Nov 2003 15:00:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42189-09; Thu, 20 Nov 2003 11:00:24 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP + id 99A8BD1B50A; Thu, 20 Nov 2003 11:00:20 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Thu, 20 Nov 2003 08:00:08 -0700 +From: Shridhar Daithankar +To: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Thu, 20 Nov 2003 20:29:47 +0530 +User-Agent: KMail/1.5.4 +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> +In-Reply-To: <3FBCD013.3030402@zeut.net> +MIME-Version: 1.0 +Content-Type: Multipart/Mixed; + boundary="Boundary-00=_jbNv/4RC6mqXtJy" +Message-Id: <200311202029.47351.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/173 +X-Sequence-Number: 4733 + +--Boundary-00=_jbNv/4RC6mqXtJy +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +On Thursday 20 November 2003 20:00, Matthew T. O'Connor wrote: +> Shridhar Daithankar wrote: +> > I will submit a patch that would account deletes in analyze threshold. +> > Since you want to delay the analyze, I would calculate analyze count as +> +> deletes are already accounted for in the analyze threshold. + +Yes. My bad. Deletes are not accounted in initializing analyze count but later +they are used. + +> > I am still wary of inverting vacuum analyze frequency. You think it is +> > better to set inverted default rather than documenting it? +> +> I think inverting the vacuum and analyze frequency is wrong. + +Me. Too. ATM all I can think of this patch attached. Josh, is it sufficient +for you?..:-) + +Matthew, I am confyused about one thing. Why would autovacuum count updates +while checking for analyze threshold? Analyze does not change statistics +right? ( w.r.t line 1072, pg_autovacuum.c). For updating statistics, only +inserts+deletes should suffice, isn't it? + +Other than that, I think autovacuum does everything it can. + +Comments? + + Shridhar + +--Boundary-00=_jbNv/4RC6mqXtJy +Content-Type: text/x-diff; + charset="iso-8859-1"; + name="difffile" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="difffile" + +*** README.pg_autovacuum.orig Thu Nov 20 19:58:29 2003 +--- README.pg_autovacuum Thu Nov 20 20:26:39 2003 +*************** +*** 141,150 **** + depending on the mixture of table activity (insert, update, or + delete): + +! - If the number of (inserts + updates + deletes) > AnalyzeThreshold, then + only an analyze is performed. + +! - If the number of (deletes + updates) > VacuumThreshold, then a + vacuum analyze is performed. + + VacuumThreshold is equal to: +--- 141,150 ---- + depending on the mixture of table activity (insert, update, or + delete): + +! - If the number of (inserts + updates + deletes) >= AnalyzeThreshold, then + only an analyze is performed. + +! - If the number of (deletes + updates) >= VacuumThreshold, then a + vacuum analyze is performed. + + VacuumThreshold is equal to: +*************** +*** 158,163 **** +--- 158,186 ---- + and running ANALYZE more often should not substantially degrade system + performance. + ++ Examples: ++ ++ Following table shows typical usage of pg_autovacuum settings. ++ These are put here so that a DBA can have some starting point while ++ tuning pg_autovacuum. ++ ++ Vacuum is triggered by updates and deletes. So in case of vacuum, ++ last column indicates total of updates and deletes required ++ to trigger vacuum. In case of analyze, the operations would count total ++ number of inserts, updates and deletes. ++ ++ Threshold Scaling factor Records No. of Operations ++ 1,000 1 10,000 11,000 ++ 1,000 2 10,000 21,000 ++ 1,000 0.5 10,000 6,000 ++ 1,000 0.1 10,000 2,000 ++ ++ Although analyze is cheaper operation compared to vacuum, ++ it might be needed less often. The default is to analyze twice as much as ++ vacuum but that might be too aggressive for some installations. It is advised that ++ such installation tune their analyze threshold separately, rather than relying upon ++ the default behaviour. ++ + Sleeping: + --------- + + +--Boundary-00=_jbNv/4RC6mqXtJy-- + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 11:08:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 420D2D1B510; Thu, 20 Nov 2003 15:08:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43766-09; Thu, 20 Nov 2003 11:07:35 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP + id DC390D1B4F4; Thu, 20 Nov 2003 11:07:30 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Thu, 20 Nov 2003 08:07:33 -0700 +From: Shridhar Daithankar +To: Shridhar Daithankar , + "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Thu, 20 Nov 2003 20:37:13 +0530 +User-Agent: KMail/1.5.4 +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> <3FBCD013.3030402@zeut.net> + <200311202029.47351.shridhar_daithankar@myrealbox.com> +In-Reply-To: <200311202029.47351.shridhar_daithankar@myrealbox.com> +MIME-Version: 1.0 +Content-Type: Multipart/Mixed; + boundary="Boundary-00=_hiNv//Rg/H4BNFT" +Message-Id: <200311202037.13091.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/174 +X-Sequence-Number: 4734 + +--Boundary-00=_hiNv//Rg/H4BNFT +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +On Thursday 20 November 2003 20:29, Shridhar Daithankar wrote: +> On Thursday 20 November 2003 20:00, Matthew T. O'Connor wrote: +> > Shridhar Daithankar wrote: +> > > I will submit a patch that would account deletes in analyze threshold. +> > > Since you want to delay the analyze, I would calculate analyze count as +> > +> > deletes are already accounted for in the analyze threshold. +> +> Yes. My bad. Deletes are not accounted in initializing analyze count but +> later they are used. +> +> > > I am still wary of inverting vacuum analyze frequency. You think it is +> > > better to set inverted default rather than documenting it? +> > +> > I think inverting the vacuum and analyze frequency is wrong. +> +> Me. Too. ATM all I can think of this patch attached. Josh, is it sufficient +> for you?..:-) + +use this one. A warning added for too aggressive vacuumming. If it is OK by +everybody, we can send it to patches list. + + Shridhar + +--Boundary-00=_hiNv//Rg/H4BNFT +Content-Type: text/x-diff; + charset="iso-8859-1"; + name="difffile" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="difffile" + +*** README.pg_autovacuum.orig Thu Nov 20 19:58:29 2003 +--- README.pg_autovacuum Thu Nov 20 20:35:34 2003 +*************** +*** 141,163 **** + depending on the mixture of table activity (insert, update, or + delete): + +! - If the number of (inserts + updates + deletes) > AnalyzeThreshold, then + only an analyze is performed. + +! - If the number of (deletes + updates) > VacuumThreshold, then a + vacuum analyze is performed. + + VacuumThreshold is equal to: +! vacuum_base_value + (vacuum_scaling_factor * "number of tuples in the table") +! + AnalyzeThreshold is equal to: +! analyze_base_value + (analyze_scaling_factor * "number of tuples in the table") +! + The AnalyzeThreshold defaults to half of the VacuumThreshold since it + represents a much less expensive operation (approx 5%-10% of vacuum), + and running ANALYZE more often should not substantially degrade system + performance. + + Sleeping: + --------- + +--- 141,191 ---- + depending on the mixture of table activity (insert, update, or + delete): + +! - If the number of (inserts + updates + deletes) >= AnalyzeThreshold, then + only an analyze is performed. + +! - If the number of (deletes + updates) >= VacuumThreshold, then a + vacuum analyze is performed. + + VacuumThreshold is equal to: +! vacuum_base_value + (vacuum_scaling_factor * "number of tuples in the +! table") + AnalyzeThreshold is equal to: +! analyze_base_value + (analyze_scaling_factor * "number of tuples in the +! table") + The AnalyzeThreshold defaults to half of the VacuumThreshold since it + represents a much less expensive operation (approx 5%-10% of vacuum), + and running ANALYZE more often should not substantially degrade system + performance. + ++ Examples: ++ ++ Following table shows typical usage of pg_autovacuum settings. ++ These are put here so that a DBA can have some starting point while ++ tuning pg_autovacuum. ++ ++ Vacuum is triggered by updates and deletes. So in case of vacuum, ++ last column indicates total of updates and deletes required ++ to trigger vacuum. In case of analyze, the operations would count total ++ number of inserts, updates and deletes. ++ ++ Base Scaling factor Records No. of Operations ++ 1,000 1 10,000 11,000 ++ 1,000 2 10,000 21,000 ++ 1,000 0.5 10,000 6,000 ++ 1,000 0.1 10,000 2,000 ++ ++ Although analyze is cheaper operation compared to vacuum, ++ it might be needed less often. The default is to analyze twice as much as ++ vacuum but that might be too aggressive for some installations. It is advised ++ thatsuch installation tune their analyze threshold separately, rather than ++ relying upon the default behaviour. ++ ++ Furthermore, for aggressive vacuum/analyze behaviour, it is recommended that ++ scaling factor is set to less than 1. However too aggresive operation can affect ++ performance of normal database operations adversely. Do not apply such setting ++ to production databases without prior testing. ++ + Sleeping: + --------- + + +--Boundary-00=_hiNv//Rg/H4BNFT-- + + +From pgsql-hackers-owner@postgresql.org Thu Nov 20 12:33:46 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id DC2D3D1CA5C; Thu, 20 Nov 2003 16:33:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64936-02; Thu, 20 Nov 2003 12:32:57 -0400 (AST) +Received: from mta9.srv.hcvlny.cv.net (mta9.srv.hcvlny.cv.net [167.206.5.42]) + by svr1.postgresql.org (Postfix) with ESMTP + id 84379D1C991; Thu, 20 Nov 2003 12:32:38 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta9.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HON00D7QSLWVA@mta9.srv.hcvlny.cv.net>; Thu, + 20 Nov 2003 11:32:22 -0500 (EST) +Date: Thu, 20 Nov 2003 11:32:24 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [PERFORM] More detail on settings for pgavd? +In-reply-to: <200311202029.47351.shridhar_daithankar@myrealbox.com> +To: Shridhar Daithankar +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBCEC98.4080309@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> + <200311202029.47351.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1130 +X-Sequence-Number: 47418 + +Shridhar Daithankar wrote: + +>On Thursday 20 November 2003 20:00, Matthew T. O'Connor wrote: +> +> +>>Shridhar Daithankar wrote: +>> +>> +>>>I am still wary of inverting vacuum analyze frequency. You think it is +>>>better to set inverted default rather than documenting it? +>>> +>>> +>>I think inverting the vacuum and analyze frequency is wrong. +>> +>> +>Me. Too. ATM all I can think of this patch attached. Josh, is it sufficient +>for you?..:-) +> +> +The patch just adds an example to the README, this looks ok to me. + +>Matthew, I am confyused about one thing. Why would autovacuum count updates +>while checking for analyze threshold? Analyze does not change statistics +>right? ( w.r.t line 1072, pg_autovacuum.c). For updating statistics, only +>inserts+deletes should suffice, isn't it? +> +> +An update is the equivelant of an insert and a delete, so it counts +towards the analyze count as much as an insert. + +>Other than that, I think autovacuum does everything it can. +> +> +It could be more customizable. + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 13:19:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 20DEAD1B578; Thu, 20 Nov 2003 17:19:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66727-10; Thu, 20 Nov 2003 13:19:12 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 4B4B1D1C9DE; Thu, 20 Nov 2003 13:19:11 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3950080; Thu, 20 Nov 2003 09:19:41 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Matthew T. O'Connor" , + Shridhar Daithankar +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Thu, 20 Nov 2003 09:18:30 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> +In-Reply-To: <3FBCD013.3030402@zeut.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311200918.30838.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/175 +X-Sequence-Number: 4735 + +Matthew, + +> For small tables, you don't need to vacuum too often. In the testing I +> did a small table ~100 rows, didn't really show significant performance +> degredation until it had close to 1000 updates. + +This is accounted for by using the "threshold" value. That way small tables +get vacuumed less often. However, the way large tables work is very different +and I think your strategy shows a lack of testing on large active tables. + +> For large tables, +> vacuum is so expensive, that you don't want to do it very often, and +> scanning the whole table when there is only 5% wasted space is not very +> helpful. + +5% is probably too low, you're right ... in my experience, performance +degredation starts to set in a 10-15% updates to, for example, a 1.1 million +row table, particularly since users tend to request the most recently updated +rows. As long as we have the I/O issues that Background Writer and ARC are +intended to solve, though, I can see being less agressive on the defaults; +perhaps 20% or 25%. If you wait until 110% of a 1.1 million row table is +updated, though, that vaccuum will take an hour or more. + +Additionally, you are not thinking of this in terms of an overall database +maintanence strategy. Lazy Vacuum needs to stay below the threshold of the +Free Space Map (max_fsm_pages) to prevent creeping bloat from setting in to +your databases. With proper configuration of pg_avd, vacuum_mem and FSM +values, it should be possible to never run a VACUUM FULL again, and as of 7.4 +never run an REINDEX again either. + +But this means running vacuum frequently enough that your max_fsm_pages +threshold is never reached. Which for a large database is going to have to +be more frequently than 110% updates, because setting 20,000,000 +max_fsm_pages will eat your RAM. + +> Yes, the I set the defaults a little high perhaps so as to err on the +> side of caution. I didn't want people to say pg_autovacuum kills the +> performance of my server. A small table will get vacuumed, just not +> until it has reached the threshold. So a table with 100 rows, will get +> vacuumed after 1200 updates / deletes. + +Ok, I can see that for small tables. + +> In my testing it showed that +> there was no major performance problems until you reached several +> thousand updates / deletes. + +Sure. But several thousand updates can be only 2% of a very large table. + +> HUH? analyze is very very cheap compared to vacuum. Why not do it more +> often? + +Because nothing is cheap if it's not needed. + +Analyze is needed only as often as the *aggregate distribution* of data in the +tables changes. Depending on the application, this could be frequently, but +far more often (in my experience running multiple databases for several +clients) the data distribution of very large tables changes very slowly over +time. + +One client's database, for example, that I have running VACUUM on chron +scripts runs on this schedule for the main tables: +VACUUM only: twice per hour +VACUUM ANALYZE: twice per day + +On the other hand, I've another client's database where most activity involves +updates to entire classes of records. They run ANALYZE at the end of every +transaction. + +So if you're going to have a seperate ANALYZE schedule at all, it should be +slightly less frequent than VACUUM for large tables. Either that, or drop +the idea, and simplify pg_avd by running VACUUM ANALYZE all the time instead +of having 2 seperate schedules. + +BUT .... now I see how you arrived at the logic you did. If you're testing +only on small tables, and not vacuuming them until they reach 110% updates, +then you *would* need to analyze more frequently. This is because of your +threshold value ... you'd want to analyze the small table as soon as even 30% +of its rows changed. + +So the answer is to dramatically lower the threshold for the small tables. + +> What I think I am hearing is that people would like very much to be able +> to tweak the settings of pg_autovacuum for individual tables / databases +> etc. + +Not from me you're not. Though that would be nice, too. + +So, my suggested defaults based on our conversation above: + +Vacuum threshold: 1000 records +Vacuum scale factor: 0.2 +Analyze threshold: 50 records +Analyze scale factor: 0.3 + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Nov 20 14:01:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 79B0ED1B545; Thu, 20 Nov 2003 18:01:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78548-04; Thu, 20 Nov 2003 14:01:01 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 1BCAFD1C9E5; Thu, 20 Nov 2003 14:01:00 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3950317; Thu, 20 Nov 2003 10:01:45 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Shridhar Daithankar +Subject: Re: More detail on settings for pgavd? +Date: Thu, 20 Nov 2003 10:00:34 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <200311190906.15828.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> +In-Reply-To: <3FBC6BED.9090809@myrealbox.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311201000.34694.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/176 +X-Sequence-Number: 4736 + +Shridhar, + +> I would say -V 0.2-0.4 could be great as well. Fact to emphasize is that +> thresholds less than 1 should be used. + +Yes, but not thresholds, scale factors of less than 1.0. Thresholds should +still be in the range of 100 to 1000. + +> I will submit a patch that would account deletes in analyze threshold. +> Since you want to delay the analyze, I would calculate analyze count as +> +> n=updates + inserts *-* deletes + +I'm not clear on how this is a benefit. Deletes affect the statistics, too. + +> What does statistics gather BTW? Just number of rows or something else as +> well? I think I would put that on Hackers separately. + +Number of tuples, degree of uniqueness, some sample values, and high/low +values. Just query your pg_statistics view for an example. + +> I am still wary of inverting vacuum analyze frequency. You think it is +> better to set inverted default rather than documenting it? + +See my post to Matthew. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Nov 20 14:49:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C7CD9D1B584; Thu, 20 Nov 2003 18:49:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88664-02; Thu, 20 Nov 2003 14:48:39 -0400 (AST) +Received: from arbor.net (division.aa.arbor.net [204.181.64.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5DA0BD1B4F4; Thu, 20 Nov 2003 14:48:37 -0400 (AST) +Received: by arbor.net (Postfix, from userid 1065) + id A03442A891; Thu, 20 Nov 2003 13:48:21 -0500 (EST) +Received: from localhost (localhost [127.0.0.1]) + by arbor.net (Postfix) with ESMTP + id 93DF12A88C; Thu, 20 Nov 2003 13:48:21 -0500 (EST) +Date: Thu, 20 Nov 2003 13:48:21 -0500 (EST) +From: Chester Kustarz +To: Josh Berkus +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-Reply-To: <200311200918.30838.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/177 +X-Sequence-Number: 4737 + +On Thu, 20 Nov 2003, Josh Berkus wrote: +> Additionally, you are not thinking of this in terms of an overall database +> maintanence strategy. Lazy Vacuum needs to stay below the threshold of the +> Free Space Map (max_fsm_pages) to prevent creeping bloat from setting in to +> your databases. With proper configuration of pg_avd, vacuum_mem and FSM +> values, it should be possible to never run a VACUUM FULL again, and as of 7.4 +> never run an REINDEX again either. + +is there any command you can run to see how much of the FSM is filled? is +there any way to tell which tables are filling it? + +> Analyze is needed only as often as the *aggregate distribution* of data in the +> tables changes. Depending on the application, this could be frequently, but +> far more often (in my experience running multiple databases for several +> clients) the data distribution of very large tables changes very slowly over +> time. + +analyze does 2 things for me: +1. gets reasonable aggregate statistics +2. generates STATISTICS # of bins for the most frequent hitters + +(2) is very important for me. my values typically seem to have power-law +like distributions. i need enough bins to reach a "cross-over" point where +the last bin is frequent enough to make an index scan useful. also, +i want enough bins so that the planner can choose index a or b for: + select * from foo where a=n and b=m; + +the selectivity of either index depends not only on the average selectivity +of index a or index b, but on n and m as well. for example, 1M row table: + +value % of rows +v1 23 +v2 12 +v3 4.5 +v4 4 +v5 3.5 +... + +you can see that picking an index for =v1 would be poor. picking the +20th most common value would be 0.5% selective. much better. of course +this breaks down for more complex operators, but = is fairly common. + +> So if you're going to have a seperate ANALYZE schedule at all, it should be +> slightly less frequent than VACUUM for large tables. Either that, or drop +> the idea, and simplify pg_avd by running VACUUM ANALYZE all the time instead +> of having 2 seperate schedules. + +i have some tables which are insert only. i do not want to vacuum them +because there are never any dead tuples in them and the vacuum grows the +indexes. plus it is very expensive (they tables grow rather large.) after they +expire i drop the whole table to make room for a newer one (making sort +of a rolling log with many large tables.) + +i need to analyze them every so often so that the planner knows that +there is 1 row, 100 rows, 100k rows, 1M. the funny thing is +that because i never vacuum the tables, the relpages on the index never +grows. don't know if this affects anything (this is on 7.2.3). + +vacuum is to reclaim dead tuples. this means it depends on update and +delete. analyze depends on data values/distribution. this means it depends on +insert, update, and delete. thus the dependencies are slightly different +between the 2 operations, an so you can come up with use-cases that +justify running either more frequently. + +i am not sure how failed transactions fit into this though, not that i think +anybody ever has very many. maybe big rollbacks during testing? + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 15:21:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id A7C53D1CCE0; Thu, 20 Nov 2003 19:21:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95691-05; Thu, 20 Nov 2003 15:21:16 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 08848D1D163; Thu, 20 Nov 2003 15:20:59 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAKJKO19006001; + Thu, 20 Nov 2003 14:20:24 -0500 (EST) +To: Chester Kustarz +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: +References: +Comments: In-reply-to Chester Kustarz + message dated "Thu, 20 Nov 2003 13:48:21 -0500" +Date: Thu, 20 Nov 2003 14:20:24 -0500 +Message-ID: <6000.1069356024@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/178 +X-Sequence-Number: 4738 + +Chester Kustarz writes: +> i have some tables which are insert only. i do not want to vacuum them +> because there are never any dead tuples in them and the vacuum grows the +> indexes. + +Those claims cannot both be true. In any case, plain vacuum cannot grow +the indexes --- only a VACUUM FULL that moves a significant number of +rows could cause index growth. + +> vacuum is to reclaim dead tuples. this means it depends on update and +> delete. analyze depends on data values/distribution. this means it depends on +> insert, update, and delete. thus the dependencies are slightly different +> between the 2 operations, an so you can come up with use-cases that +> justify running either more frequently. + +Agreed. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Nov 20 16:55:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id A26CAD1C969; Thu, 20 Nov 2003 20:55:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08196-09; Thu, 20 Nov 2003 16:54:40 -0400 (AST) +Received: from arbor.net (division.aa.arbor.net [204.181.64.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C9A6DD1B55F; Thu, 20 Nov 2003 16:54:38 -0400 (AST) +Received: by arbor.net (Postfix, from userid 1065) + id 9E3EE2A891; Thu, 20 Nov 2003 15:54:24 -0500 (EST) +Received: from localhost (localhost [127.0.0.1]) + by arbor.net (Postfix) with ESMTP + id 913352A88C; Thu, 20 Nov 2003 15:54:24 -0500 (EST) +Date: Thu, 20 Nov 2003 15:54:24 -0500 (EST) +From: Chester Kustarz +To: Tom Lane +Cc: Josh Berkus , , + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-Reply-To: <6000.1069356024@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/179 +X-Sequence-Number: 4739 + +On Thu, 20 Nov 2003, Tom Lane wrote: +> Those claims cannot both be true. In any case, plain vacuum cannot grow +> the indexes --- only a VACUUM FULL that moves a significant number of +> rows could cause index growth. + +er, yeah. you're right of course. having flashbacks of vacuum full. + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:56:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E8001D1D4BE + for ; + Thu, 20 Nov 2003 21:05:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09813-06 + for ; + Thu, 20 Nov 2003 17:04:30 -0400 (AST) +Received: from almaden.ibm.com (p1.almaden.ibm.com [198.4.83.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EADFD1C950 + for ; + Thu, 20 Nov 2003 17:04:28 -0400 (AST) +Received: from user.almaden.ibm.com (user.almaden.ibm.com [9.1.25.220]) + by almaden.ibm.com (AIX4.3/8.9.3p2/8.9.3) with ESMTP id NAA32396 + for ; Thu, 20 Nov 2003 13:04:29 -0800 +Received: from almaden.ibm.com (sfarrell@yoyo.almaden.ibm.com [9.1.24.63]) + by user.almaden.ibm.com (8.12.3/8.12.3/Debian -4) with ESMTP id + hAKL4TlZ023952 + for ; Thu, 20 Nov 2003 13:04:29 -0800 +Message-ID: <3FBD2C5D.8000706@almaden.ibm.com> +Date: Thu, 20 Nov 2003 13:04:29 -0800 +From: stephen farrell +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.5) Gecko/20031030 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Problem with insert into select... +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/221 +X-Sequence-Number: 4781 + +I'm having a problem with a queyr like: INSERT INTO FACT (x,x,x,x,x,x) +SELECT a.key,b.key,c.key,d.key,e.key,f.key from x,a,b,c,d,e,f where x=a +and x=b .... -- postgres7.4 is running out of memory. I'm not sure +why this would happen -- does it buffer the subselect before doing the +insert? + +Things are pretty big scale: 3gb ram, 32768 shared buffers, 700gb disk, +millions of rows in the tables. + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 17:10:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C393D1D570 + for ; + Thu, 20 Nov 2003 21:10:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09813-08 + for ; + Thu, 20 Nov 2003 17:09:35 -0400 (AST) +Received: from almaden.ibm.com (p1.almaden.ibm.com [198.4.83.52]) + by svr1.postgresql.org (Postfix) with ESMTP id C61DDD1D4CE + for ; + Thu, 20 Nov 2003 17:09:30 -0400 (AST) +Received: from user.almaden.ibm.com (user.almaden.ibm.com [9.1.25.220]) + by almaden.ibm.com (AIX4.3/8.9.3p2/8.9.3) with ESMTP id NAA50960 + for ; Thu, 20 Nov 2003 13:09:31 -0800 +Received: from almaden.ibm.com (sfarrell@yoyo.almaden.ibm.com [9.1.24.63]) + by user.almaden.ibm.com (8.12.3/8.12.3/Debian -4) with ESMTP id + hAKL9VlZ024046 + for ; Thu, 20 Nov 2003 13:09:31 -0800 +Message-ID: <3FBD2D8B.8020509@almaden.ibm.com> +Date: Thu, 20 Nov 2003 13:09:31 -0800 +From: stephen farrell +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.5) Gecko/20031030 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Problem with insert into select... +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/180 +X-Sequence-Number: 4740 + +I'm having a problem with a queyr like: INSERT INTO FACT (x,x,x,x,x,x) +SELECT a.key,b.key,c.key,d.key,e.key,f.key from x,a,b,c,d,e,f where x=a +and x=b .... -- postgres7.4 is running out of memory. I'm not sure +why this would happen -- does it buffer the subselect before doing the +insert? + +Things are pretty big scale: 3gb ram, 32768 shared buffers, 700gb disk, +millions of rows in the tables. + + + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 18:59:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA1C2D1B4E6 + for ; + Thu, 20 Nov 2003 22:59:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30763-01 + for ; + Thu, 20 Nov 2003 18:58:48 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id F20CED1B4F4 + for ; + Thu, 20 Nov 2003 18:58:45 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAKMwe19007440; + Thu, 20 Nov 2003 17:58:40 -0500 (EST) +To: stephen farrell +Cc: pgsql-performance@postgresql.org +Subject: Re: Problem with insert into select... +In-reply-to: <3FBD2D8B.8020509@almaden.ibm.com> +References: <3FBD2D8B.8020509@almaden.ibm.com> +Comments: In-reply-to stephen farrell + message dated "Thu, 20 Nov 2003 13:09:31 -0800" +Date: Thu, 20 Nov 2003 17:58:40 -0500 +Message-ID: <7439.1069369120@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/181 +X-Sequence-Number: 4741 + +stephen farrell writes: +> I'm having a problem with a queyr like: INSERT INTO FACT (x,x,x,x,x,x) +> SELECT a.key,b.key,c.key,d.key,e.key,f.key from x,a,b,c,d,e,f where x=a +> and x=b .... -- postgres7.4 is running out of memory. I'm not sure +> why this would happen -- does it buffer the subselect before doing the +> insert? + +What does EXPLAIN show for the query? And we need to see the exact +query and table definitions, not abstractions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:56:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id E77C5D1B54C; Thu, 20 Nov 2003 23:19:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32640-08; Thu, 20 Nov 2003 19:18:43 -0400 (AST) +Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) + by svr1.postgresql.org (Postfix) with ESMTP + id 403E4D1B520; Thu, 20 Nov 2003 19:18:40 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta1.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOO004BHBF8UT@mta1.srv.hcvlny.cv.net>; Thu, + 20 Nov 2003 18:18:49 -0500 (EST) +Date: Thu, 20 Nov 2003 18:18:27 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <6000.1069356024@sss.pgh.pa.us> +To: Tom Lane +Cc: Chester Kustarz , + Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBD4BC3.8030003@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: + <6000.1069356024@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/220 +X-Sequence-Number: 4780 + +Tom Lane wrote: + +>Chester Kustarz writes: +> +> +>>vacuum is to reclaim dead tuples. this means it depends on update and +>>delete. analyze depends on data values/distribution. this means it depends on +>>insert, update, and delete. thus the dependencies are slightly different +>>between the 2 operations, an so you can come up with use-cases that +>>justify running either more frequently. +>> +>> +>Agreed. +> +> + +And that is why pg_autovacuum looks at insert, update and delete when +deciding to do an analyze, but only looks at update and delete when +deciding to do a vacuum. In addition, this is why pg_autovacuum was +given knobs so that the vacuum and analyze thresholds can be set +independently. + +Matthew + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 20:17:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15A02D1D4CE + for ; + Fri, 21 Nov 2003 00:17:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44878-01 + for ; + Thu, 20 Nov 2003 20:17:18 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 061F0D1B54E + for ; + Thu, 20 Nov 2003 20:17:15 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAL0H119007949; + Thu, 20 Nov 2003 19:17:02 -0500 (EST) +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org, + Bruce Momjian +Subject: Re: duration logging setting in 7.4 +In-reply-to: <20031118091646.GA8223@siaco.id.pl> +References: <20031117222058.GD3248@siaco.id.pl> + <200311180237.hAI2b7s29417@candle.pha.pa.us> + <20031118091646.GA8223@siaco.id.pl> +Comments: In-reply-to Ryszard Lach + message dated "Tue, 18 Nov 2003 10:16:46 +0100" +Date: Thu, 20 Nov 2003 19:17:01 -0500 +Message-ID: <7948.1069373821@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/182 +X-Sequence-Number: 4742 + +Ryszard Lach writes: +> Nov 18 10:05:20 postgres[1348]: [318-1] LOG: duration: 0.297 ms statement: +> Nov 18 10:05:20 postgres[1311]: [5477-1] LOG: duration: 0.617 ms statement: +> Nov 18 10:05:20 postgres[1312]: [5134-1] LOG: duration: 0.477 ms statement: +> Nov 18 10:05:20 postgres[1349]: [318-1] LOG: duration: 0.215 ms statement: +> Nov 18 10:05:20 postgres[1313]: [5449-1] LOG: duration: 0.512 ms statement: +> Nov 18 10:05:20 postgres[1314]: [5534-1] LOG: duration: 0.420 ms statement: +> Nov 18 10:05:20 postgres[1330]: [772-1] LOG: duration: 1.386 ms statement: SELECT * FROM mytablemius WHERE id = 0; +> Nov 18 10:05:20 postgres[1315]: [5757-1] LOG: duration: 0.417 ms statement: +> Nov 18 10:05:20 postgres[1316]: [5885-1] LOG: duration: 0.315 ms statement: +> Nov 18 10:05:20 postgres[1317]: [5914-1] LOG: duration: 0.301 ms statement: +> Nov 18 10:05:20 postgres[1318]: [5990-1] LOG: duration: 0.293 ms statement: +> Nov 18 10:05:20 postgres[1319]: [6009-1] LOG: duration: 0.211 ms statement: +> Nov 18 10:05:20 postgres[1320]: [6039-1] LOG: duration: 0.188 ms statement: + + +Is it possible that you're sending a lot of queries that have an initial +newline in the text? I'd expect the first line of log output for such a +query to look as above. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:56:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9DD7FD1B520; Fri, 21 Nov 2003 00:41:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49229-04; Thu, 20 Nov 2003 20:41:05 -0400 (AST) +Received: from mta2.srv.hcvlny.cv.net (mta2.srv.hcvlny.cv.net [167.206.5.68]) + by svr1.postgresql.org (Postfix) with ESMTP + id 81586D1B50A; Thu, 20 Nov 2003 20:41:02 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta2.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOO001ATF7S9Y@mta2.srv.hcvlny.cv.net>; Thu, + 20 Nov 2003 19:40:45 -0500 (EST) +Date: Thu, 20 Nov 2003 19:40:15 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311200918.30838.josh@agliodbs.com> +To: Josh Berkus +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBD5EEF.7060205@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> + <200311200918.30838.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/219 +X-Sequence-Number: 4779 + +Josh Berkus wrote: + +>Matthew, +> +> +>>For small tables, you don't need to vacuum too often. In the testing I +>>did a small table ~100 rows, didn't really show significant performance +>>degredation until it had close to 1000 updates. +>> +>> +>This is accounted for by using the "threshold" value. That way small tables +>get vacuumed less often. However, the way large tables work is very different +>and I think your strategy shows a lack of testing on large active tables. +> +> +Probably more true than I would like to think... + +>>For large tables, +>>vacuum is so expensive, that you don't want to do it very often, and +>>scanning the whole table when there is only 5% wasted space is not very +>>helpful. +>> +>> +>5% is probably too low, you're right ... in my experience, performance +>degredation starts to set in a 10-15% updates to, for example, a 1.1 million +>row table, particularly since users tend to request the most recently updated +>rows. As long as we have the I/O issues that Background Writer and ARC are +>intended to solve, though, I can see being less agressive on the defaults; +>perhaps 20% or 25%. If you wait until 110% of a 1.1 million row table is +>updated, though, that vaccuum will take an hour or more. +> +> +True, but I think it would be one hour once, rather than 30 minutes 4 times. + +>Additionally, you are not thinking of this in terms of an overall database +>maintanence strategy. Lazy Vacuum needs to stay below the threshold of the +>Free Space Map (max_fsm_pages) to prevent creeping bloat from setting in to +>your databases. With proper configuration of pg_avd, vacuum_mem and FSM +>values, it should be possible to never run a VACUUM FULL again, and as of 7.4 +>never run an REINDEX again either. +> +> +This is one of the things I had hoped to add to pg_autovacuum, but never +got to. In addition to just the information from the stats collector on +inserts updates and deletes, pg_autovacuum should also look at the FSM, +and make decisions based on it. Anyone looking for a project? + +>But this means running vacuum frequently enough that your max_fsm_pages +>threshold is never reached. Which for a large database is going to have to +>be more frequently than 110% updates, because setting 20,000,000 +>max_fsm_pages will eat your RAM. +> +> +Again, the think the only way to do this efficiently is to look at the +FSM. Otherwise the only way to make sure you keep the FSM populated is +to run vacuum more than needed. + +>>Yes, the I set the defaults a little high perhaps so as to err on the +>>side of caution. I didn't want people to say pg_autovacuum kills the +>>performance of my server. A small table will get vacuumed, just not +>>until it has reached the threshold. So a table with 100 rows, will get +>>vacuumed after 1200 updates / deletes. +>> +>> +>Ok, I can see that for small tables. +> +> +>>In my testing it showed that +>>there was no major performance problems until you reached several +>>thousand updates / deletes. +>> +>> +>Sure. But several thousand updates can be only 2% of a very large table. +> +> +But I can't imagine that 2% makes any difference on a large table. In +fact I would think that 10-15% would hardly be noticable, beyond that +I'm not sure. + +>>HUH? analyze is very very cheap compared to vacuum. Why not do it more +>>often? +>> +>> +>Because nothing is cheap if it's not needed. +> +>Analyze is needed only as often as the *aggregate distribution* of data in the +>tables changes. Depending on the application, this could be frequently, but +>far more often (in my experience running multiple databases for several +>clients) the data distribution of very large tables changes very slowly over +>time. +> +> +Valid points, and again I think this points to the fact that +pg_autovacuum needs to be more configurable. Being able to set +different thresholds for different tables will help considerably. In +fact, you may find that some tables should have a vac threshold much +larger than the analyze thresold, while other tables might want the +opposite. + +>One client's database, for example, that I have running VACUUM on chron +>scripts runs on this schedule for the main tables: +>VACUUM only: twice per hour +>VACUUM ANALYZE: twice per day +> +> +I would be surprized if you can notice the difference between a vacuum +analyze and a vacuum, especially on large tables. + +>On the other hand, I've another client's database where most activity involves +>updates to entire classes of records. They run ANALYZE at the end of every +>transaction. +> +>So if you're going to have a seperate ANALYZE schedule at all, it should be +>slightly less frequent than VACUUM for large tables. Either that, or drop +>the idea, and simplify pg_avd by running VACUUM ANALYZE all the time instead +>of having 2 seperate schedules. +> +> +I think you need two separate schedules. There are lots of times where +a vacuum doesn't help, and an analyze is all that is needed, and an +analyze is MUCH cheaper than a vacuum. + +>BUT .... now I see how you arrived at the logic you did. If you're testing +>only on small tables, and not vacuuming them until they reach 110% updates, +>then you *would* need to analyze more frequently. This is because of your +>threshold value ... you'd want to analyze the small table as soon as even 30% +>of its rows changed. +> +>So the answer is to dramatically lower the threshold for the small tables. +> +> +Perhaps. + +>>What I think I am hearing is that people would like very much to be able +>>to tweak the settings of pg_autovacuum for individual tables / databases +>>etc. +>> +>> +>Not from me you're not. Though that would be nice, too. +> +>So, my suggested defaults based on our conversation above: +> +>Vacuum threshold: 1000 records +>Vacuum scale factor: 0.2 +>Analyze threshold: 50 records +>Analyze scale factor: 0.3 +> +> +I'm open to discussion on changing the defaults. Perhaps what it would +be better to use some non-linear (perhaps logorithmic) scaling factor. +So that you wound up with something roughly like this: + +#tuples activity% for vacuum +1k 100% +10k 70% +100k 45% +1M 20% +10M 10% +100M 8% + +Thanks for the lucid feedback / discussion. autovacuum is a feature +that, despite it's simple implementation, has generated a lot of +feedback from users, and I would really like to see it become something +closer to what it should be. + + + +From pgsql-performance-owner@postgresql.org Thu Nov 20 22:05:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DECCED1B4E6 + for ; + Fri, 21 Nov 2003 02:05:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66594-02 + for ; + Thu, 20 Nov 2003 22:05:14 -0400 (AST) +Received: from almaden.ibm.com (p1.almaden.ibm.com [198.4.83.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 76938D1B54E + for ; + Thu, 20 Nov 2003 22:05:10 -0400 (AST) +Received: from user.almaden.ibm.com (user.almaden.ibm.com [9.1.25.220]) + by almaden.ibm.com (AIX4.3/8.9.3p2/8.9.3) with ESMTP id SAA58840 + for ; Thu, 20 Nov 2003 18:05:13 -0800 +Received: from almaden.ibm.com (sfarrell@yoyo.almaden.ibm.com [9.1.24.63]) + by user.almaden.ibm.com (8.12.3/8.12.3/Debian -4) with ESMTP id + hAL259lZ027038 + for ; Thu, 20 Nov 2003 18:05:12 -0800 +Message-ID: <3FBD72D5.1040202@almaden.ibm.com> +Date: Thu, 20 Nov 2003 18:05:09 -0800 +From: stephen farrell +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.5) Gecko/20031030 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Problem with insert into select... +References: <3FBD2D8B.8020509@almaden.ibm.com> <7439.1069369120@sss.pgh.pa.us> +In-Reply-To: <7439.1069369120@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/183 +X-Sequence-Number: 4743 + +Ok -- so we created indexes and it was able to complete successfully. +But why would creating indexes affect the memory footprint, and should it? + + +Does it buffer the sub-select before doing the insert, or does it do the +insert record-by-record? + + +See correspondence below for details: + + +Steve, + + With the indexes created it worked. It took about 4 hours, but +it inserted all of the records. + + stephen farrell + +11/20/2003 05:22 PM + + To: James Rhodes/Almaden/IBM@IBMUS + cc: + Subject: Re: [Fwd: Re: [PERFORM] Problem with insert +into select...] + + + +if you do "explain" before the sql statement (e.g., "explain select * +from foo"), it'll tell you the query plan. + +James Rhodes wrote: + > + > Steve, + > + > Here is the detailed structure of the tables and the query that + > is failing (the "INSERT INTO FACT" query) and I attached the logfile. + > Also what is EXPLAIN??? + > + > CREATE TABLE RAW ( RAW_KEY serial, PATNO_TEXT VARCHAR (9), + > APPDATE_DATETIME VARCHAR (11), ISDATE_DATETIME VARCHAR (11), + > WHATEVERSNO_TEXT VARCHAR (5), WHATEVERSNO_NUMBER VARCHAR (6), APPNO_TEXT + > VARCHAR (10), TITLE_TEXT TEXT, USCLASS_TEXT VARCHAR (14), + > USCLASS_TEXTLIST_TEXT TEXT, AUTHORCODE_TEXT VARCHAR (9), + > AUTHORNORM_TEXT VARCHAR (195), AUTHOR_TEXT VARCHAR (212), + > AUTHOR_TEXTLIST_TEXT TEXT, AUTHORADDRESS_TEXT VARCHAR (84), + > AUTHORADDRESS_TEXTLIST_TEXT TEXT, INVENTOR_TEXT VARCHAR (50), + > INVENTOR_TEXTLIST_TEXT TEXT, INVENTORADDRESS_TEXT VARCHAR (90), + > INVENTORADDRESS_TEXTLIST_TEXT TEXT, AGENT_TEXT TEXT, AGENT_TEXTLIST_TEXT + > TEXT, USSEARCHFIELD_TEXT VARCHAR (26), USSEARCHFIELD_TEXTLIST_TEXT + > VARCHAR (150), USREFISDATE_TEXT VARCHAR (13), USREFISDATE_TEXTLIST_TEXT + > TEXT, USREFNAME_TEXT VARCHAR (34), USREFNAME_TEXTLIST_TEXT TEXT, + > ABSTRACT_TEXT TEXT, ABSTRACT_TEXTLIST_TEXT TEXT, ABSTRACT_RICHTEXT_PAR + > TEXT, WHATEVERS_RICHTEXT_PAR TEXT, USREFPATNO_RICHTEXT_PAR TEXT, PRIMARY + > KEY(RAW_KEY)); + > + > + > CREATE TABLE ISSUE_TIME ( + > TAB_KEY serial, + > ISDATE_DATETIME varchar (8), + > MONTH INT, + > DAY INT, + > YEAR INT + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE SOMETHING_NUMBER ( + > TAB_KEY serial, + > PATNO_TEXT varchar (7) + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE APP_TIME ( + > TAB_KEY serial, + > APPDATE_DATETIME varchar (8), + > MONTH INT, + > DAY INT, + > YEAR INT + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE AUTHOR ( + > TAB_KEY serial, + > CODE varchar (6), + > AUTHOR text + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE APPLICATION_NUMBER ( + > TAB_KEY serial, + > APPNO_TEXT varchar (7) + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE WHATEVERS ( + > TAB_KEY serial, + > abstract_richtext_par text, + > WHATEVERS_richtext_par text, + > raw_key int, + > title_text text + > , PRIMARY KEY(TAB_KEY)) + > + > CREATE TABLE FACT (DYN_DIM1 BIGINT, DYN_DIM2 BIGINT,DYN_DIM3 + > BIGINT,ISSUE_TIME BIGINT, SOMETHING_NUMBER BIGINT, APP_TIME BIGINT, + > AUTHOR BIGINT, APPLICATION_NUMBER BIGINT, WHATEVERS BIGINT) + > + > INSERT INTO FACT (ISSUE_TIME, SOMETHING_NUMBER, APP_TIME, AUTHOR, + > APPLICATION_NUMBER, WHATEVERS) SELECT ISSUE_TIME.TAB_KEY, + > SOMETHING_NUMBER.TAB_KEY, APP_TIME.TAB_KEY, AUTHOR.TAB_KEY, + > APPLICATION_NUMBER.TAB_KEY, WHATEVERS.TAB_KEY FROM ISSUE_TIME, + > SOMETHING_NUMBER, APP_TIME, AUTHOR, APPLICATION_NUMBER, WHATEVERS, raw + > WHERE ISSUE_TIME.ISDATE_DATETIME=raw.ISDATE_DATETIME AND + > SOMETHING_NUMBER.PATNO_TEXT=raw.PATNO_TEXT AND + > APP_TIME.APPDATE_DATETIME=raw.APPDATE_DATETIME AND + > AUTHOR.CODE=AUTHORCODE_TEXT AND AUTHOR.AUTHOR=(AUTHOR_TEXT || + > ' | ' || AUTHOR_TEXTLIST_TEXT) AND + > APPLICATION_NUMBER.APPNO_TEXT=raw.APPNO_TEXT AND + > WHATEVERS.raw_key=raw.raw_key + +Tom Lane wrote: +> stephen farrell writes: +> +>>I'm having a problem with a queyr like: INSERT INTO FACT (x,x,x,x,x,x) +>>SELECT a.key,b.key,c.key,d.key,e.key,f.key from x,a,b,c,d,e,f where x=a +>>and x=b .... -- postgres7.4 is running out of memory. I'm not sure +>>why this would happen -- does it buffer the subselect before doing the +>>insert? +> +> +> What does EXPLAIN show for the query? And we need to see the exact +> query and table definitions, not abstractions. +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 02:25:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D1F48D1D2BB; Fri, 21 Nov 2003 06:25:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02910-05; Fri, 21 Nov 2003 02:25:15 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 56340D1D247; Fri, 21 Nov 2003 02:25:14 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3953394; Thu, 20 Nov 2003 22:26:00 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Thu, 20 Nov 2003 22:24:45 -0800 +User-Agent: KMail/1.4.3 +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> +In-Reply-To: <3FBD5EEF.7060205@zeut.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311202224.45065.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/184 +X-Sequence-Number: 4744 + +Matthew, + +> > 110% of a 1.1 million row table is updated, though, that vaccuum will +> > take an hour or more. +> +> True, but I think it would be one hour once, rather than 30 minutes 4 +> times. + +Well, generally it would be about 6-8 times at 2-4 minutes each. + +> This is one of the things I had hoped to add to pg_autovacuum, but never +> got to. In addition to just the information from the stats collector on +> inserts updates and deletes, pg_autovacuum should also look at the FSM, +> and make decisions based on it. Anyone looking for a project? + +Hmmm ... I think that's the wrong approach. Once your database is populated, +it's very easy to determine how to set the FSM for a given pg_avd level. If +you're vacuuming after 20% updates, for example, just set fsm_pages to 20% of +the total database pages plus growth & safety margins. + +I'd be really reluctant to base pv-avd frequency on the fsm settings instead. +What if the user loads 8GB of data but leaves fsm_pages at the default of +10,000? You can't do much with that; you'd have to vacuum if even 1% of the +data changed. + +The other problem is that calculating data pages from a count of +updates+deletes would require pg_avd to keep more statistics and do more math +for every table. Do we want to do this? + +> But I can't imagine that 2% makes any difference on a large table. In +> fact I would think that 10-15% would hardly be noticable, beyond that +> I'm not sure. + +I've seen performance lag at 10% of records, especially in tables where both +update and select activity focus on one subset of the table (calendar tables, +for example). + +> Valid points, and again I think this points to the fact that +> pg_autovacuum needs to be more configurable. Being able to set +> different thresholds for different tables will help considerably. In +> fact, you may find that some tables should have a vac threshold much +> larger than the analyze thresold, while other tables might want the +> opposite. + +Sure. Though I think we can make the present configuration work with a little +adjustment of the numbers. I'll have a chance to test on production +databases soon. + +> I would be surprized if you can notice the difference between a vacuum +> analyze and a vacuum, especially on large tables. + +It's substantial for tables with high statistics settings. A 1,000,000 row +table with 5 columns set to statistics=250 can take 3 minutes to analyze on a +medium-grade server. + +> I think you need two separate schedules. There are lots of times where +> a vacuum doesn't help, and an analyze is all that is needed + +Agreed. And I've just talked to a client who may want to use pg_avd's ANALYZE +scheduling but not use vacuum at all. BTW, I think we should have a setting +for this; for example, if -V is -1, don't vacuum. + +> I'm open to discussion on changing the defaults. Perhaps what it would +> be better to use some non-linear (perhaps logorithmic) scaling factor. +> So that you wound up with something roughly like this: +> +> #tuples activity% for vacuum +> 1k 100% +> 10k 70% +> 100k 45% +> 1M 20% +> 10M 10% +> 100M 8% + +That would be cool, too. Though a count of data pages would be a better +scale than a count of rows, and equally obtainable from pg_class. + +> Thanks for the lucid feedback / discussion. autovacuum is a feature +> that, despite it's simple implementation, has generated a lot of +> feedback from users, and I would really like to see it become something +> closer to what it should be. + +Well, I hope to help now. Until very recently, I've not had a chance to +seriously look at pg_avd and test it in production. Now that I do, I'm +interested in improving it. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Nov 21 04:54:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E9BBD1D59A + for ; + Fri, 21 Nov 2003 08:53:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29079-03 + for ; + Fri, 21 Nov 2003 04:53:27 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id A1CE3D1D563 + for ; + Fri, 21 Nov 2003 04:53:23 -0400 (AST) +Received: (qmail 26805 invoked by uid 0); 21 Nov 2003 08:53:21 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 21 Nov 2003 08:53:21 -0000 +Received: (qmail 749 invoked by uid 1000); 21 Nov 2003 08:53:17 -0000 +Date: Fri, 21 Nov 2003 09:53:17 +0100 +From: Ryszard Lach +To: Tom Lane +Cc: pgsql-performance@postgresql.org, + Bruce Momjian +Subject: Re: duration logging setting in 7.4 +Message-ID: <20031121085317.GD331@siaco.id.pl> +Reply-To: Ryszard Lach +References: <20031117222058.GD3248@siaco.id.pl> + <200311180237.hAI2b7s29417@candle.pha.pa.us> + <20031118091646.GA8223@siaco.id.pl> <7948.1069373821@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <7948.1069373821@sss.pgh.pa.us> +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/185 +X-Sequence-Number: 4745 + +On Thu, Nov 20, 2003 at 07:17:01PM -0500, Tom Lane wrote: +> +> +> Is it possible that you're sending a lot of queries that have an initial +> newline in the text? I'd expect the first line of log output for such a +> query to look as above. + +I don't think so, but it is possible, that queries have e.g. two +semicolons on end - I've just noticed, that separating two queries with +two or more semicolons gives one empty log entry for each redundand +semicolon. We'll debug our application keeping this in mind. + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:55:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C72B5D1D570 + for ; + Fri, 21 Nov 2003 10:10:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44624-04 + for ; + Fri, 21 Nov 2003 06:10:22 -0400 (AST) +Received: from mailhub1.sghms.ac.uk (firewall.sghms.ac.uk [194.82.50.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B97BD1D695 + for ; + Fri, 21 Nov 2003 06:10:19 -0400 (AST) +Received: from [194.82.51.24] (helo=imail) + by mailhub1.sghms.ac.uk with esmtp (Exim 4.24) + id 1AN8Eh-0008JU-DF; Fri, 21 Nov 2003 10:09:59 +0000 +Received: from [172.16.20.3] (mrc1-003.sghms.ac.uk [172.16.20.3]) + by imail.sghms.ac.uk + (iPlanet Messaging Server 5.2 Patch 1 (built Aug 19 2002)) with ESMTPA + id <0HOP00AD15KNGA@imail.sghms.ac.uk>; + Fri, 21 Nov 2003 10:09:59 +0000 (GMT) +Date: Fri, 21 Nov 2003 10:08:42 +0000 +From: Adam Witney +Subject: Re: Hardware advice +In-reply-to: +To: "scott.marlowe" +Cc: pgsql-performance +Message-id: +MIME-version: 1.0 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +User-Agent: Microsoft-Entourage/10.1.1.2418 +X-MailScanner-Information: Please contact sysadmin at sghms.ac.uk for more + information +X-MailScanner-MH1: Found to be clean +X-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, required 5, + APARENTLY_FROM_MYSELF 1.00, BAYES_00 -4.90, FROM_SGHMS -1.00) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/218 +X-Sequence-Number: 4778 + +On 30/5/03 6:17 pm, "scott.marlowe" wrote: + +> On Fri, 30 May 2003, Adam Witney wrote: +> +>> Hi scott, +>> +>> Thanks for the info +>> +>>> You might wanna do something like go to all 146 gig drives, put a mirror +>>> set on the first 20 or so gigs for the OS, and then use the remainder +>>> (5x120gig or so ) to make your RAID5. The more drives in a RAID5 the +>>> better, generally, up to about 8 or 12 as the optimal for most setups. +>> +>> I am not quite sure I understand what you mean here... Do you mean take 20Gb +>> from each of the 5 drives to setup a 20Gb RAID 1 device? Or just from the +>> first 2 drives? +> +> You could do it either way, since the linux kernel supports more than 2 +> drives in a mirror. But, this costs on writes, so don't do it for things +> like /var or the pg_xlog directory. +> +> There are a few ways you could arrange 5 146 gig drives. +> +> One might be to make the first 20 gig on each drive part of a mirror set +> where the first two drives are the live mirror, and the next three are hot +> spares. Then you could setup your RAID5 to have 4 live drives and 1 hot +> spare. +> +> Hot spares are nice to have because they provide for the shortest period +> of time during which your machine is running with a degraded RAID array. +> +> note that in linux you can set the kernel parameter +> dev.raid.speed_limit_max and dev.raid.speed_limit_min to control the +> rebuild bandwidth used so that when a disk dies you can set a compromise +> between fast rebuilds, and lowering the demands on the I/O subsystem +> during a rebuild. The max limit default is 100k / second, which is quite +> slow. On a machine with Ultra320 gear, you could set that to 10 ot 20 +> megs a second and still not saturate your SCSI buss. +> +> Now that I think of it, you could probably set it up so that you have a +> mirror set for the OS, one for pg_xlog, and then use the rest of the +> drives as RAID5. Then grab space on the fifth drive to make a hot spare +> for both the pg_xlog and the OS drive. +> +> Drive 0 +> [OS RAID1 20 Gig D0][big data drive RAID5 106 Gig D0] +> Drive 1 +> [OS RAID1 20 Gig D1][big data drive RAID5 106 Gig D1] +> Drive 2 +> [pg_xlog RAID1 20 gig D0][big data drive RAID5 106 Gig D2] +> Drive 3 +> [pg_xlog RAID1 20 gig D1][big data drive RAID5 106 Gig D3] +> Drive 4 +> [OS hot spare 20 gig][g_clog hot spare 20 gig][big data drive RAID5 106 +> Gig hot spare] +> +> That would give you ~ 300 gigs storage. +> +> Of course, there will likely be slightly less performance than you might +> get from dedicated RAID arrays for each RAID1/RAID5 set, but my guess is +> that by having 4 (or 5 if you don't want a hot spare) drives in the RAID5 +> it'll still be faster than a dedicated 3 drive RAID array. +> + +Hi Scott, + +Just following up a post from a few months back... I have now purchased the +hardware, do you have a recommended/preferred Linux distro that is easy to +configure for software RAID? + +Thanks again + +Adam + + +-- +This message has been scanned for viruses and +dangerous content by MailScanner, and is +believed to be clean. + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:55:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC459D1D643 + for ; + Fri, 21 Nov 2003 10:19:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47972-02 + for ; + Fri, 21 Nov 2003 06:19:07 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id 7F8EED1B553 + for ; + Fri, 21 Nov 2003 06:19:03 -0400 (AST) +Received: (qmail 31948 invoked by uid 0); 21 Nov 2003 10:18:59 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 21 Nov 2003 10:18:58 -0000 +Received: (qmail 1823 invoked by uid 1000); 21 Nov 2003 10:18:54 -0000 +Date: Fri, 21 Nov 2003 11:18:54 +0100 +From: Ryszard Lach +To: Tom Lane +Cc: pgsql-performance@postgresql.org, + Bruce Momjian +Subject: Re: duration logging setting in 7.4 +Message-ID: <20031121101854.GA1106@siaco.id.pl> +Reply-To: Ryszard Lach +References: <20031117222058.GD3248@siaco.id.pl> + <200311180237.hAI2b7s29417@candle.pha.pa.us> + <20031118091646.GA8223@siaco.id.pl> <7948.1069373821@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +In-Reply-To: <7948.1069373821@sss.pgh.pa.us> +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/217 +X-Sequence-Number: 4777 + + +Hi, again. + +I've turned on only log_connections and log_statement. See the following +log fragment (I've included lines only related to opening of new +connection); + +Nov 21 11:06:44 postgres[3359]: [3-1] LOG: connection received: host= port= +Nov 21 11:06:44 postgres[3359]: [4-1] LOG: connection authorized: user=pracuj database=pracuj +Nov 21 11:06:44 postgres[3359]: [5-1] LOG: statement: set datestyle to 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else +Nov 21 11:06:44 postgres[3359]: [5-2] getdatabaseencoding() end; +Nov 21 11:06:44 postgres[3359]: [6-1] LOG: statement: +Nov 21 11:06:44 postgres[3359]: [7-1] LOG: statement: select * from ... + +Nov 21 11:06:45 postgres[3376]: [3-1] LOG: connection received: host= port= +Nov 21 11:06:45 postgres[3376]: [4-1] LOG: connection authorized: user=pracuj database=pracuj +Nov 21 11:06:45 postgres[3376]: [5-1] LOG: statement: set datestyle to 'ISO'; select version(), case when pg_encoding_to_char(1) = 'S +QL_ASCII' then ' else +Nov 21 11:06:45 postgres[3376]: [5-2] getdatabaseencoding() end; +Nov 21 11:06:45 postgres[3376]: [6-1] LOG: statement: + +It seems, that empty statements are generated during opening of +connection. + +Please, note also: + +1. We are using an older jdbc driver (pgjdbc2) +2. We ar using encoding in URL +(jdbc:postgresql://localhost:5432/database?charSet=iso-8859-1) + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Fri Nov 21 10:15:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id CD832D1D790; Fri, 21 Nov 2003 14:14:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90152-01; Fri, 21 Nov 2003 10:14:27 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP + id 80337D1D7BD; Fri, 21 Nov 2003 10:14:23 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hALDL7cM007075; + Fri, 21 Nov 2003 08:21:07 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hALEEEl07166; + Fri, 21 Nov 2003 09:14:15 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id V3JR4X5P; Fri, 21 Nov 2003 09:14:13 -0500 +Subject: Re: [HACKERS] More detail on settings for pgavd? +From: Robert Treat +To: "Matthew T. O'Connor" +Cc: Josh Berkus , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +In-Reply-To: <3FBD5EEF.7060205@zeut.net> +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 21 Nov 2003 09:14:14 -0500 +Message-Id: <1069424054.29672.12462.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/186 +X-Sequence-Number: 4746 + +On Thu, 2003-11-20 at 19:40, Matthew T. O'Connor wrote: +> I'm open to discussion on changing the defaults. Perhaps what it would +> be better to use some non-linear (perhaps logorithmic) scaling factor. +> So that you wound up with something roughly like this: +> +> #tuples activity% for vacuum +> 1k 100% +> 10k 70% +> 100k 45% +> 1M 20% +> 10M 10% +> 100M 8% +> + + +Just thinking out loud here, so disregard if you think its chaff but... +if we had a system table pg_avd_defaults that held what we generally +consider the best default percentages based on reltuples/pages, and +added a column to pg_class (could be some place better but..) which +could hold an overriding percentage, you could then have a column added +to pg_stat_all_tables called vacuum_percentage, which would be a +coalesce of the override percentage or the default percentages based on +rel_tuples (or rel_pages). This would give autovacuum a place to look +for each table as to when it should vacuum, and gives administrators the +option to tweak it on a per table basis if they find they need a +specific table to vacuum at a different rate than the "standard". + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:53:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1A60CD1CC81; Fri, 21 Nov 2003 14:32:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91583-02; Fri, 21 Nov 2003 10:31:52 -0400 (AST) +Received: from mta5.srv.hcvlny.cv.net (mta5.srv.hcvlny.cv.net [167.206.5.78]) + by svr1.postgresql.org (Postfix) with ESMTP + id 74552D1D221; Fri, 21 Nov 2003 10:31:48 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta5.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOP00L0DHP29B@mta5.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 09:31:52 -0500 (EST) +Date: Fri, 21 Nov 2003 09:31:49 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <1069424054.29672.12462.camel@camel> +To: Robert Treat +Cc: Josh Berkus , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE21D5.20508@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <3FBC6BED.9090809@myrealbox.com> <3FBCD013.3030402@zeut.net> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> + <1069424054.29672.12462.camel@camel> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/216 +X-Sequence-Number: 4776 + +Robert Treat wrote: + +>Just thinking out loud here, so disregard if you think its chaff but... +>if we had a system table pg_avd_defaults +> +[snip] + +As long as pg_autovacuum remains a contrib module, I don't think any +changes to the system catelogs will be make. If pg_autovacuum is +deemed ready to move out of contrib, then we can talk about the above. + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 10:55:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C4E9D1B520 + for ; + Fri, 21 Nov 2003 14:55:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92633-03 + for ; + Fri, 21 Nov 2003 10:55:05 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id AAC17D1CC81 + for ; + Fri, 21 Nov 2003 10:55:00 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hALEsW19012145; + Fri, 21 Nov 2003 09:54:33 -0500 (EST) +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org, + Bruce Momjian +Subject: Re: duration logging setting in 7.4 +In-reply-to: <20031121101854.GA1106@siaco.id.pl> +References: <20031117222058.GD3248@siaco.id.pl> + <200311180237.hAI2b7s29417@candle.pha.pa.us> + <20031118091646.GA8223@siaco.id.pl> <7948.1069373821@sss.pgh.pa.us> + <20031121101854.GA1106@siaco.id.pl> +Comments: In-reply-to Ryszard Lach + message dated "Fri, 21 Nov 2003 11:18:54 +0100" +Date: Fri, 21 Nov 2003 09:54:32 -0500 +Message-ID: <12144.1069426472@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/187 +X-Sequence-Number: 4747 + +Ryszard Lach writes: +> It seems, that empty statements are generated during opening of +> connection. + +Hmm. Try asking about that on the pgsql-jdbc list. I think the JDBC +driver must actually be sending empty commands. + +Looking at the backend code, I realize that 7.4 will emit LOG: entries +for empty query strings, whereas prior releases would not. This isn't +a bug IMHO, but it does explain why you are noticing output that wasn't +there before you updated to 7.4. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 21 10:56:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 20048D1B520; Fri, 21 Nov 2003 14:56:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92464-05; Fri, 21 Nov 2003 10:56:21 -0400 (AST) +Received: from mta10.srv.hcvlny.cv.net (mta10.srv.hcvlny.cv.net + [167.206.5.85]) + by svr1.postgresql.org (Postfix) with ESMTP + id ED9BCD1D7C7; Fri, 21 Nov 2003 10:56:16 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta10.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOP0002IITUPF@mta10.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 09:56:21 -0500 (EST) +Date: Fri, 21 Nov 2003 09:56:17 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311202224.45065.josh@agliodbs.com> +To: Josh Berkus +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE2791.8040404@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> + <200311202224.45065.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/188 +X-Sequence-Number: 4748 + +Josh Berkus wrote: + +>Matthew, +> +> +>>True, but I think it would be one hour once, rather than 30 minutes 4 +>>times. +>> +>> +>Well, generally it would be about 6-8 times at 2-4 minutes each. +> +> +Are you saying that you can vacuum a 1 million row table in 2-4 +minutes? While a vacuum of the same table with an additional 1 million +dead tuples would take an hour? + +>>This is one of the things I had hoped to add to pg_autovacuum, but never +>>got to. In addition to just the information from the stats collector on +>>inserts updates and deletes, pg_autovacuum should also look at the FSM, +>>and make decisions based on it. Anyone looking for a project? +>> +>> +>Hmmm ... I think that's the wrong approach. Once your database is populated, +>it's very easy to determine how to set the FSM for a given pg_avd level. If +>you're vacuuming after 20% updates, for example, just set fsm_pages to 20% of +>the total database pages plus growth & safety margins. +> +> +Ok. + +>I'd be really reluctant to base pv-avd frequency on the fsm settings instead. +>What if the user loads 8GB of data but leaves fsm_pages at the default of +>10,000? You can't do much with that; you'd have to vacuum if even 1% of the +>data changed. +> +Ok, but as you said above it's very easy to set the FSM once you know +your db size. + +>The other problem is that calculating data pages from a count of +>updates+deletes would require pg_avd to keep more statistics and do more math +>for every table. Do we want to do this? +> +> +I would think the math is simple enough to not be a big problem. Also, +I did not recommend looking blindly at the FSM as our guide, rather +consulting it as another source of information as to when it would be +useful to vacuum. I don't have a good plan as to how to incorporate +this data, but to a large extent the FSM already tracks table activity +and gives us the most accurate answer about storage growth (short of +using something like contrib/pgstattuple which takes nearly the same +amount of time as an actual vacuum) + +>>But I can't imagine that 2% makes any difference on a large table. In +>>fact I would think that 10-15% would hardly be noticable, beyond that +>>I'm not sure. +>> +>> +>I've seen performance lag at 10% of records, especially in tables where both +>update and select activity focus on one subset of the table (calendar tables, +>for example). +> +> +Ok. + +>>Valid points, and again I think this points to the fact that +>>pg_autovacuum needs to be more configurable. Being able to set +>>different thresholds for different tables will help considerably. In +>>fact, you may find that some tables should have a vac threshold much +>>larger than the analyze thresold, while other tables might want the +>>opposite. +>> +>> +>Sure. Though I think we can make the present configuration work with a little +>adjustment of the numbers. I'll have a chance to test on production +>databases soon. +> +> +I look forward to hearing results from your testing. + +>>I would be surprized if you can notice the difference between a vacuum +>>analyze and a vacuum, especially on large tables. +>> +>> +>It's substantial for tables with high statistics settings. A 1,000,000 row +>table with 5 columns set to statistics=250 can take 3 minutes to analyze on a +>medium-grade server. +> +> +In my testing, I never changed the default statistics settings. + +>>I think you need two separate schedules. There are lots of times where +>>a vacuum doesn't help, and an analyze is all that is needed +>> +>> +>Agreed. And I've just talked to a client who may want to use pg_avd's ANALYZE +>scheduling but not use vacuum at all. BTW, I think we should have a setting +>for this; for example, if -V is -1, don't vacuum. +> +> +That would be nice. Easy to add, and something I never thought of.... + +>>I'm open to discussion on changing the defaults. Perhaps what it would +>>be better to use some non-linear (perhaps logorithmic) scaling factor. +>> +>> +>That would be cool, too. Though a count of data pages would be a better +>scale than a count of rows, and equally obtainable from pg_class. +> +> +But we track tuples because we can compare against the count given by +the stats system. I don't know of a way (other than looking at the FSM, +or contrib/pgstattuple ) to see how many dead pages exist. + + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 11:07:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5A138D1B520; Fri, 21 Nov 2003 15:07:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92477-07; Fri, 21 Nov 2003 11:07:13 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP + id 97813D1D7BD; Fri, 21 Nov 2003 11:07:08 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Fri, 21 Nov 2003 08:07:04 -0700 +Message-ID: <3FBE2A0E.3010308@myrealbox.com> +Date: Fri, 21 Nov 2003 20:36:54 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Matthew T. O'Connor" +Cc: Josh Berkus , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +References: <200311181558.45847.josh@agliodbs.com> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> + <200311202224.45065.josh@agliodbs.com> <3FBE2791.8040404@zeut.net> +In-Reply-To: <3FBE2791.8040404@zeut.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/189 +X-Sequence-Number: 4749 + +Matthew T. O'Connor wrote: + +> But we track tuples because we can compare against the count given by +> the stats system. I don't know of a way (other than looking at the FSM, +> or contrib/pgstattuple ) to see how many dead pages exist. + +I think making pg_autovacuum dependent of pgstattuple is very good idea. + +Probably it might be a good idea to extend pgstattuple to return pages that are +excessively contaminated and clean them ASAP. Step by step getting closer to +daemonized vacuum. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 11:18:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5453FD1D767; Fri, 21 Nov 2003 15:18:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94367-04; Fri, 21 Nov 2003 11:17:33 -0400 (AST) +Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4F50BD1D450; Fri, 21 Nov 2003 11:17:29 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta1.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOP00KH2JTPEQ@mta1.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 10:17:50 -0500 (EST) +Date: Fri, 21 Nov 2003 10:17:31 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <3FBE2A0E.3010308@myrealbox.com> +To: Shridhar Daithankar +Cc: Josh Berkus , pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE2C8B.9040304@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <200311200918.30838.josh@agliodbs.com> <3FBD5EEF.7060205@zeut.net> + <200311202224.45065.josh@agliodbs.com> <3FBE2791.8040404@zeut.net> + <3FBE2A0E.3010308@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/190 +X-Sequence-Number: 4750 + +Shridhar Daithankar wrote: + +> Matthew T. O'Connor wrote: +> +>> But we track tuples because we can compare against the count given by +>> the stats system. I don't know of a way (other than looking at the +>> FSM, or contrib/pgstattuple ) to see how many dead pages exist. +> +> I think making pg_autovacuum dependent of pgstattuple is very good idea. + +Only if pgstattuple can become much cheaper than it is now. Based on +the testing I did when I wrote pg_autovacuum, pgstattuple cost nearly +the same amount as a regular vacuum. Given that, what have we gained +from that work? Wouldn't it just be better to run a vacuum and actually +reclaim space rather than running pgstattuple, and just look and see if +there is free space to be reclaimed? + +Perhaps we could use pgstattuple ocasionally to see if we are going a +good job of keeping the amount of dead space to a reasonable level, but +I'm still not really sure about this. + +> Probably it might be a good idea to extend pgstattuple to return pages +> that are excessively contaminated and clean them ASAP. Step by step +> getting closer to daemonized vacuum. + +I don't know of anyway to clean a particular set of pages. This is +something that has been talked about (partial vacuums and such), but I +think Tom has raised several issues with it, I don't remember the +details. Right now the only tool we have to reclaim space is vacuum, a +whole table at a time. + + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 13:10:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id DB40AD1B555; Fri, 21 Nov 2003 17:10:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42743-08; Fri, 21 Nov 2003 13:09:37 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 3C18BD1B54E; Fri, 21 Nov 2003 13:09:36 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3955426; Fri, 21 Nov 2003 09:10:21 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Matthew T. O'Connor" , + Robert Treat +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Fri, 21 Nov 2003 09:09:00 -0800 +User-Agent: KMail/1.4.3 +Cc: Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <1069424054.29672.12462.camel@camel> <3FBE21D5.20508@zeut.net> +In-Reply-To: <3FBE21D5.20508@zeut.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311210909.00978.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/191 +X-Sequence-Number: 4751 + +Matthew, + +> As long as pg_autovacuum remains a contrib module, I don't think any +> changes to the system catelogs will be make. If pg_autovacuum is +> deemed ready to move out of contrib, then we can talk about the above. + +But we could create a config file that would store stuff in a flatfile table, +OR we could add our own "system table" that would be created when one +"initializes" pg_avd. + +Just an idea. Mind you, I'm not so sure that we want to focus immediately on +per-table settings. I think that we want to get the "automatic" settings +working fairly well first; a lot of new DBAs would use the per-table settings +to shoot themselves in the foot. So we need to be able to make a strong +recommendation to "try the automatic settings first." + +> Are you saying that you can vacuum a 1 million row table in 2-4 +> minutes? While a vacuum of the same table with an additional 1 million +> dead tuples would take an hour? + +I'm probably exaggerating. I do know that I can vacuum a fairly clean 1-5 +million row table in less than 4 mintues. I've never let such a table get +to 50% dead tuples, so I don't really know how long that takes. Call me a +coward if you like ... + +> >I'd be really reluctant to base pv-avd frequency on the fsm settings +> > instead. What if the user loads 8GB of data but leaves fsm_pages at the +> > default of 10,000? You can't do much with that; you'd have to vacuum if +> > even 1% of the data changed. +> +> Ok, but as you said above it's very easy to set the FSM once you know +> your db size. + +Actually, thinking about this I realize that PG_AVD and the Perl-based +postgresql.conf configuration script I was working on (darn, who was doing +that with me?) need to go togther. With pg_avd, setting max_fsm_pages is +very easy; without it its a bit of guesswork. + +So I think we can do this: for 'auto' settings: + +If max_fsm_pages is between 13% and 100% of the total database pages, then set +the vacuum scale factor to match 3/4 of the fsm_pages setting, e.g. +database = 18,000,000 data pages; +max_fsm_pages = 3,600,000; +set vacuum scale factor = 3.6mil/18mil * 3/4 = 0.15 + +If max_fsm_pages is less than 13% of database pages, issue a warning to the +user (log it, if possible) and set scale factor to 0.1. If it's greater +than 100% set it to 1 and leave it alone. + +> I don't have a good plan as to how to incorporate +> this data, but to a large extent the FSM already tracks table activity +> and gives us the most accurate answer about storage growth (short of +> using something like contrib/pgstattuple which takes nearly the same +> amount of time as an actual vacuum) + +I don't really think we need to do dynamic monitoring at this point. It +would be a lot of engineering to check data page pollution without having +significant performance impact. It's doable, but something I think we +should hold off until version 3. It would mean hacking the FSM, which is a +little beyond me right now. + +> In my testing, I never changed the default statistics settings. + +Ah. Well, a lot of users do to resolve query problems. + +> But we track tuples because we can compare against the count given by +> the stats system. I don't know of a way (other than looking at the FSM, +> or contrib/pgstattuple ) to see how many dead pages exist. + +No, but for scaling you don't need the dynamic count of tuples or of dead +tuples; pg_class holds a reasonable accurate count of pages per table as of +last vacuum. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Nov 21 17:34:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D294ED1D660; Fri, 21 Nov 2003 21:34:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90740-10; Fri, 21 Nov 2003 17:33:48 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 04671D1CA7F; Fri, 21 Nov 2003 17:33:46 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3956660; Fri, 21 Nov 2003 13:34:19 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Fri, 21 Nov 2003 13:23:18 -0800 +User-Agent: KMail/1.4.3 +Cc: Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> +In-Reply-To: <3FBE8289.1040009@zeut.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311211323.19003.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/193 +X-Sequence-Number: 4753 + +Matthew, + +> Actually, this might be a necessary addition as pg_autovacuum currently= +=20 +> suffers from the startup transients that the FSM used to suffer from,=20 +> that is, it doesn't remember anything that happened the last time it=20 +> ran. A pg_autovacuum database could also be used to store thresholds=20 +> and counts from the last time it ran. + +I don't see how a seperate database is better than a table in the databases= +.,=20 +except that it means scanning only one table and not one per database. Fo= +r=20 +one thing, making it a seperate database could make it hard to back up and= +=20 +move your database+pg_avd config. + +But I don't feel strongly about it. + +> Where are you getting 13% from?=20 + +13% * 3/4 ~~ 10% + +And I think both of use agree that vacuuming tables with less than 10% chan= +ges=20 +is excessive and could lead to problems on its own, like overlapping vacuum= +s. + +> Do you know of an easy way to get a=20 +> count of the total pages used by a whole cluster? + +Select sum(relpages) from pg_class. + +> I do like the concept though as long as we find good values for=20 +> min_fsm_percentage and min_autovac_scaling_factor. + +See above. I propose 0.13 and 0.1 + +> Which we already keep a copy of inside of pg_autovacuum, and update=20 +> after we issue a vacuum. + +Even easier then. + +BTW, do we have any provisions to avoid overlapping vacuums? That is, to= +=20 +prevent a second vacuum on a table if an earlier one is still running? + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 17:25:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6F0ECD1D1C6; Fri, 21 Nov 2003 21:25:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 90692-05; Fri, 21 Nov 2003 17:25:05 -0400 (AST) +Received: from mta2.srv.hcvlny.cv.net (mta2.srv.hcvlny.cv.net [167.206.5.68]) + by svr1.postgresql.org (Postfix) with ESMTP + id 73CE2D1D49D; Fri, 21 Nov 2003 17:25:03 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta2.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOQ0099V0TOFV@mta2.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 16:25:03 -0500 (EST) +Date: Fri, 21 Nov 2003 16:24:25 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311210909.00978.josh@agliodbs.com> +To: Josh Berkus +Cc: Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE8289.1040009@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <1069424054.29672.12462.camel@camel> <3FBE21D5.20508@zeut.net> + <200311210909.00978.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/192 +X-Sequence-Number: 4752 + +Josh Berkus wrote: + +>Matthew, +> +> +>But we could create a config file that would store stuff in a flatfile table, +>OR we could add our own "system table" that would be created when one +>"initializes" pg_avd. +> +> +I don't want to add tables to existing databases, as I consider that +clutter and I never like using tools that clutter my production +databases. I had considered using a pg_autovacuum database that if +found, would store customized settings for individual tables / +databases. Dunno if this is a good idea, but it might make a good +stopgap until people are comfortable modifying the system catalogs for +autovacuum. + +Actually, this might be a necessary addition as pg_autovacuum currently +suffers from the startup transients that the FSM used to suffer from, +that is, it doesn't remember anything that happened the last time it +ran. A pg_autovacuum database could also be used to store thresholds +and counts from the last time it ran. + +>Just an idea. Mind you, I'm not so sure that we want to focus immediately on +>per-table settings. I think that we want to get the "automatic" settings +>working fairly well first; a lot of new DBAs would use the per-table settings +>to shoot themselves in the foot. So we need to be able to make a strong +>recommendation to "try the automatic settings first." +> +> +I agree in principle, question is what are the best settings, I still +think it will be hard to find a one size fits all, but I'm sure we can +do better than what we have. + +>Actually, thinking about this I realize that PG_AVD and the Perl-based +>postgresql.conf configuration script I was working on (darn, who was doing +>that with me?) need to go togther. With pg_avd, setting max_fsm_pages is +>very easy; without it its a bit of guesswork. +> +>So I think we can do this: for 'auto' settings: +> +>If max_fsm_pages is between 13% and 100% of the total database pages, then set +>the vacuum scale factor to match 3/4 of the fsm_pages setting, e.g. +>database = 18,000,000 data pages; +>max_fsm_pages = 3,600,000; +>set vacuum scale factor = 3.6mil/18mil * 3/4 = 0.15 +> +> +Where are you getting 13% from? Do you know of an easy way to get a +count of the total pages used by a whole cluster? I guess we can just +iterate over all the tables in all the databases and sum up the total +num of pages. We already iterate over them all, we just don't sum it up. + +>If max_fsm_pages is less than 13% of database pages, issue a warning to the +>user (log it, if possible) and set scale factor to 0.1. If it's greater +>than 100% set it to 1 and leave it alone. +> +> +Again I ask where 13% is coming from and also where is 0.1 coming from? +I assume these are your best guesses right now, but not more than that. +I do like the concept though as long as we find good values for +min_fsm_percentage and min_autovac_scaling_factor. + +>>But we track tuples because we can compare against the count given by +>>the stats system. I don't know of a way (other than looking at the FSM, +>>or contrib/pgstattuple ) to see how many dead pages exist. +>> +>> +>No, but for scaling you don't need the dynamic count of tuples or of dead +>tuples; pg_class holds a reasonable accurate count of pages per table as of +>last vacuum. +> +> +Which we already keep a copy of inside of pg_autovacuum, and update +after we issue a vacuum. + + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 18:00:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1B0C1D1B53A; Fri, 21 Nov 2003 22:00:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93371-03; Fri, 21 Nov 2003 18:00:13 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 6E64CD1B515; Fri, 21 Nov 2003 18:00:10 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3956811; Fri, 21 Nov 2003 14:00:59 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Fri, 21 Nov 2003 13:49:58 -0800 +User-Agent: KMail/1.4.3 +Cc: Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200311181558.45847.josh@agliodbs.com> + <200311211323.19003.josh@agliodbs.com> <3FBE891D.8010309@zeut.net> +In-Reply-To: <3FBE891D.8010309@zeut.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311211349.58788.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/195 +X-Sequence-Number: 4755 + +Matthew, + +> Basically, I don't like the idea of modifying users databases, besides,= +=20 +> in the long run most of what needs to be tracked will be moved to the=20 +> system catalogs. I kind of consider the pg_autvacuum database to=20 +> equivalent to the changes that will need to be made to the system catalog= +s. + +OK. As I said, I don't feel strongly about it. + +> I certainly agree that less than 10% would be excessive, I still feel=20 +> that 10% may not be high enough though. That's why I kinda liked the=20 +> sliding scale I mentioned earlier, because I agree that for very large=20 +> tables, something as low as 10% might be useful, but most tables in a=20 +> database would not be that large. + +Yes, but I thought that we were taking care of that through the "threshold"= +=20 +value? + +A sliding scale would also be OK. However, that would definitely require = +a=20 +leap to storing per-table pg_avd statistics and settings. + +> Only that pg_autovacuum isn't smart enough to kick off more than one=20 +> vacuum at a time. Basically, pg_autovacuum issues a vacuum on a table=20 +> and waits for it to finish, then check the next table in it's list to=20 +> see if it needs to be vacuumed, if so, it does it and waits for that=20 +> vacuum to finish.=20 + +OK, then, we just need to detect the condition of the vacuums "piling up"= +=20 +because they are happening too often. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 17:53:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7E504D1D2BB; Fri, 21 Nov 2003 21:53:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92181-07; Fri, 21 Nov 2003 17:52:50 -0400 (AST) +Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) + by svr1.postgresql.org (Postfix) with ESMTP + id B6D5FD1D660; Fri, 21 Nov 2003 17:52:47 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta1.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOQ00GGU24IBC@mta1.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 16:53:08 -0500 (EST) +Date: Fri, 21 Nov 2003 16:52:29 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311211323.19003.josh@agliodbs.com> +To: josh@agliodbs.com +Cc: Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE891D.8010309@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> + <200311211323.19003.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/194 +X-Sequence-Number: 4754 + +Josh Berkus wrote: + +>Matthew, +> +> +> +>I don't see how a seperate database is better than a table in the databases., +>except that it means scanning only one table and not one per database. For +>one thing, making it a seperate database could make it hard to back up and +>move your database+pg_avd config. +> +> +Basically, I don't like the idea of modifying users databases, besides, +in the long run most of what needs to be tracked will be moved to the +system catalogs. I kind of consider the pg_autvacuum database to +equivalent to the changes that will need to be made to the system catalogs. + +I guess it could make it harder to backup if you are moving your +database between clusters. Perhaps, if you create a pg_autovacuum +schema inside of your database then we would could use that. I just +don't like tools that drop things into your database. + +>>Where are you getting 13% from? +>> +>> +> +>13% * 3/4 ~~ 10% +> +>And I think both of use agree that vacuuming tables with less than 10% changes +>is excessive and could lead to problems on its own, like overlapping vacuums. +> +> +> +I certainly agree that less than 10% would be excessive, I still feel +that 10% may not be high enough though. That's why I kinda liked the +sliding scale I mentioned earlier, because I agree that for very large +tables, something as low as 10% might be useful, but most tables in a +database would not be that large. + +>> Do you know of an easy way to get a +>>count of the total pages used by a whole cluster? +>> +>> +> +>Select sum(relpages) from pg_class. +> +> +> +duh.... + +>BTW, do we have any provisions to avoid overlapping vacuums? That is, to +>prevent a second vacuum on a table if an earlier one is still running? +> +> +> +Only that pg_autovacuum isn't smart enough to kick off more than one +vacuum at a time. Basically, pg_autovacuum issues a vacuum on a table +and waits for it to finish, then check the next table in it's list to +see if it needs to be vacuumed, if so, it does it and waits for that +vacuum to finish. There was some discussion of issuing concurrent +vacuum against different tables, but it was decided that since vacuum is +I/O bound, it would only make sense to issue concurrent vacuums that +were on different spindles, which is not something I wanted to get +into. Also, given the recent talk about how vacuum is still such a +performance hog, I can't imagine what multiple concurrent vacuums would +do to performance. Maybe as 7.5 develops and many of the vacuum +performance issues are addressed, we can revisit this question. + + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 18:41:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 2BD7ED1C4D4; Fri, 21 Nov 2003 22:41:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99775-06; Fri, 21 Nov 2003 18:40:48 -0400 (AST) +Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) + by svr1.postgresql.org (Postfix) with ESMTP + id E9ED6D1B553; Fri, 21 Nov 2003 18:40:45 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta1.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HOQ00L974CHVV@mta1.srv.hcvlny.cv.net>; Fri, + 21 Nov 2003 17:41:07 -0500 (EST) +Date: Fri, 21 Nov 2003 17:40:45 -0500 +From: "Matthew T. O'Connor" +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311211349.58788.josh@agliodbs.com> +To: josh@agliodbs.com +Cc: Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Message-id: <3FBE946D.4050708@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) + Gecko/20031013 Thunderbird/0.3 +References: <200311181558.45847.josh@agliodbs.com> + <200311211323.19003.josh@agliodbs.com> <3FBE891D.8010309@zeut.net> + <200311211349.58788.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/196 +X-Sequence-Number: 4756 + +Josh Berkus wrote: + +>Matthew, +> +> +>>I certainly agree that less than 10% would be excessive, I still feel +>>that 10% may not be high enough though. That's why I kinda liked the +>>sliding scale I mentioned earlier, because I agree that for very large +>>tables, something as low as 10% might be useful, but most tables in a +>>database would not be that large. +>> +>> +> +>Yes, but I thought that we were taking care of that through the "threshold" +>value? +> +> +Well the threshold is a combination of the base value and the scaling +factor which you are proposing is 0.1, so the threshold is base + +(scaling factor)(num of tuples) So with the default base of 1000 and +your 0.1 you would have this: + + Num Rows threshold Percent + 1,000 1,100 110% + 10,000 2,000 20% + 100,000 11,000 11% +1,000,000 102,000 10% + +I don't like how that looks, hence the thought of some non-linear +scaling factor that would still allow the percent to reach 10%, but at a +slower rate, perhaps just a larger base value would suffice, but I think +small table performance is going to suffer much above 1000. Anyone else +have an opinion on the table above? Good / Bad / Indifferent? + +>A sliding scale would also be OK. However, that would definitely require a +>leap to storing per-table pg_avd statistics and settings. +> +> +> +I don't think it would, it would correlate the scaling factor with the +number of tuples, no per-table settings required. + +>>Only that pg_autovacuum isn't smart enough to kick off more than one +>>vacuum at a time. Basically, pg_autovacuum issues a vacuum on a table +>>and waits for it to finish, then check the next table in it's list to +>>see if it needs to be vacuumed, if so, it does it and waits for that +>>vacuum to finish. +>> +>> +> +>OK, then, we just need to detect the condition of the vacuums "piling up" +>because they are happening too often. +> +> +> +That would be good to look into at some point, especially if vacuum is +going to get slower as a result of the page loop delay patch that has +been floating around. + + + +From pgsql-performance-owner@postgresql.org Fri Nov 21 19:05:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 02784D1D524 + for ; + Fri, 21 Nov 2003 23:05:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05523-01 + for ; + Fri, 21 Nov 2003 19:04:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 68AF7D1B53A + for ; + Fri, 21 Nov 2003 19:04:55 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hALN4u19015609; + Fri, 21 Nov 2003 18:04:57 -0500 (EST) +To: josh@agliodbs.com +Cc: "Matthew T. O'Connor" , + Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-reply-to: <200311211323.19003.josh@agliodbs.com> +References: <200311181558.45847.josh@agliodbs.com> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> + <200311211323.19003.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Fri, 21 Nov 2003 13:23:18 -0800" +Date: Fri, 21 Nov 2003 18:04:56 -0500 +Message-ID: <15608.1069455896@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/197 +X-Sequence-Number: 4757 + +Josh Berkus writes: +> BTW, do we have any provisions to avoid overlapping vacuums? That is, to +> prevent a second vacuum on a table if an earlier one is still running? + +Yes, VACUUM takes a lock that prevents another VACUUM on the same table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 21 19:54:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C30DED1D7BC; Fri, 21 Nov 2003 23:54:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07596-06; Fri, 21 Nov 2003 19:53:43 -0400 (AST) +Received: from arbor.net (division.aa.arbor.net [204.181.64.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 625C5D1D59A; Fri, 21 Nov 2003 19:53:40 -0400 (AST) +Received: by arbor.net (Postfix, from userid 1065) + id 14BE22A893; Fri, 21 Nov 2003 18:53:27 -0500 (EST) +Received: from localhost (localhost [127.0.0.1]) + by arbor.net (Postfix) with ESMTP + id 0D5FC2A88C; Fri, 21 Nov 2003 18:53:27 -0500 (EST) +Date: Fri, 21 Nov 2003 18:53:26 -0500 (EST) +From: Chester Kustarz +To: "Matthew T. O'Connor" +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +In-Reply-To: <3FBE891D.8010309@zeut.net> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/198 +X-Sequence-Number: 4758 + +On Fri, 21 Nov 2003, Matthew T. O'Connor wrote: +> >> Do you know of an easy way to get a +> >>count of the total pages used by a whole cluster? +> > +> >Select sum(relpages) from pg_class. + +You might want to exclude indexes from this calculation. Some large +read only tables might have indexes larger than the tables themselves. + + + +From pgsql-hackers-owner@postgresql.org Fri Nov 21 20:52:03 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07EE6D1D809 + for ; + Sat, 22 Nov 2003 00:52:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10327-08 + for ; + Fri, 21 Nov 2003 20:51:36 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id E2D6ED1D7C5 + for ; + Fri, 21 Nov 2003 20:51:32 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id C055336E06; Fri, 21 Nov 2003 19:51:17 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ANLzZ-0006LP-00; Fri, 21 Nov 2003 19:51:17 -0500 +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] More detail on settings for pgavd? +References: <200311181558.45847.josh@agliodbs.com> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> + <200311211323.19003.josh@agliodbs.com> + <15608.1069455896@sss.pgh.pa.us> +In-Reply-To: <15608.1069455896@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 21 Nov 2003 19:51:17 -0500 +Message-ID: <877k1t2pkq.fsf@stark.dyndns.tv> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1213 +X-Sequence-Number: 47501 + +Tom Lane writes: + +> Josh Berkus writes: +> > BTW, do we have any provisions to avoid overlapping vacuums? That is, to +> > prevent a second vacuum on a table if an earlier one is still running? +> +> Yes, VACUUM takes a lock that prevents another VACUUM on the same table. + +The second vacuum waits for the lock to become available. If the situation got +really bad there could end up being a growing queue of vacuums waiting. + +I'm not sure how likely this is as the subsequent vacuums appear to finish +quite quickly though. But then the largest table I have to play with fits +entirely in memory. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sat Nov 22 07:57:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E94AFD1CA8E + for ; + Sat, 22 Nov 2003 11:57:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17885-08 + for ; + Sat, 22 Nov 2003 07:57:06 -0400 (AST) +Received: from easily.co.uk (unknown [213.161.76.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 46C73D1D5D9 + for ; + Sat, 22 Nov 2003 07:57:02 -0400 (AST) +Received: from [80.235.141.90] (account f4vo5dsy5djd HELO chuckie.co.uk) + by easily.co.uk (CommuniGate Pro SMTP 4.1.3) + with ESMTP id 35518619; Sat, 22 Nov 2003 11:56:34 +0000 +Message-ID: <3FBF4EF3.6090507@chuckie.co.uk> +Date: Sat, 22 Nov 2003 11:56:35 +0000 +From: Nick Barr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5b) Gecko/20030901 Thunderbird/0.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com, pgsql-performance@postgresql.org +Subject: pg_autoconfig.pl +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/199 +X-Sequence-Number: 4759 + +Heya, + +Sorry for no updates on the old pg_autoconfig script thing, been rather +busy at work the last week or two :-( but i suppose it pays the bills. I +do have a few days off work now so I can spend some time on finishing +the first version off. The latest version can be found at + +http://www.chuckie.co.uk/postgresql/pg_autoconfig.txt + +Josh have you managed to put together the rest of the calculations yet? + + +Thanks, + + +Nick + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:57:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6F9C4D1D453; Sat, 22 Nov 2003 21:36:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07852-03; Sat, 22 Nov 2003 17:35:48 -0400 (AST) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1273ED1D5FD; Sat, 22 Nov 2003 17:35:45 -0400 (AST) +Received: from root@anakena.dcc.uchile.cl [192.80.24.3] by + sunsite.dcc.uchile.cl (8.8.5/Main-DCCV8-Jo6) + id SAA09191; Sat, 22 Nov 2003 18:35:32 -0300 (CDT) +Received: from alvherre@localhost by anakena.dcc.uchile.cl + (8.8.5/MainSec-DCCV8-Jo5) + id LAA07875; Sat, 22 Nov 2003 11:46:37 -0300 (CLST) +Date: Sat, 22 Nov 2003 11:46:37 -0300 +From: Alvaro Herrera Munoz +To: "Matthew T. O'Connor" +Cc: Josh Berkus , + Robert Treat , + Shridhar Daithankar , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] More detail on settings for pgavd? +Message-ID: <20031122144637.GC6016@dcc.uchile.cl> +References: <200311181558.45847.josh@agliodbs.com> + <1069424054.29672.12462.camel@camel> <3FBE21D5.20508@zeut.net> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FBE8289.1040009@zeut.net> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/222 +X-Sequence-Number: 4782 + +On Fri, Nov 21, 2003 at 04:24:25PM -0500, Matthew T. O'Connor wrote: + +> I don't want to add tables to existing databases, as I consider that +> clutter and I never like using tools that clutter my production +> databases. [...] +> +> Actually, this might be a necessary addition as pg_autovacuum currently +> suffers from the startup transients that the FSM used to suffer from, +> that is, it doesn't remember anything that happened the last time it +> ran. A pg_autovacuum database could also be used to store thresholds +> and counts from the last time it ran. + +You could use the same approach the FSM uses: keep a file with the data, +PGDATA/base/global/pg_fsm.cache. You don't need the data to be in a table +after all ... + +-- +Alvaro Herrera () +Essentially, you're proposing Kevlar shoes as a solution for the problem +that you want to walk around carrying a loaded gun aimed at your foot. +(Tom Lane) + +From pgsql-performance-owner@postgresql.org Sat Nov 22 13:20:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FBFAD1C96C + for ; + Sat, 22 Nov 2003 17:20:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75938-06 + for ; + Sat, 22 Nov 2003 13:20:13 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C79B2D1D630 + for ; + Sat, 22 Nov 2003 13:20:11 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3960326; Sat, 22 Nov 2003 09:20:51 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Nick Barr , pgsql-performance@postgresql.org +Subject: Re: pg_autoconfig.pl +Date: Sat, 22 Nov 2003 09:19:23 -0800 +User-Agent: KMail/1.4.3 +References: <3FBF4EF3.6090507@chuckie.co.uk> +In-Reply-To: <3FBF4EF3.6090507@chuckie.co.uk> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311220919.23695.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/200 +X-Sequence-Number: 4760 + +Nick, + +> Josh have you managed to put together the rest of the calculations yet? + +Given that I spent most of November working on the PR for the 7.4 release, +I've just started to think about it. As you can see, I'm thinking about +dovetailing pg_avd and pg_autoconf. + +The difficult thing is to figure out settings for "bad" hardware setups. Like +a 5GB database on a PIII500 + 256mb running 4 other pieces of major software +(I've acctually seen this). Or a 500/minute OLTP database on a machine +with 1 fixed disk. + +All the variables are going into a hash array, right? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Nov 23 23:51:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D2F49D1B531 + for ; + Mon, 24 Nov 2003 03:51:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55336-10 + for ; + Sun, 23 Nov 2003 23:51:02 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id BFB02D1B4E1 + for ; + Sun, 23 Nov 2003 23:50:58 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAO3ovNu052862 + for ; Mon, 24 Nov 2003 03:50:57 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAO3mBR1052409 + for pgsql-performance@postgresql.org; Mon, 24 Nov 2003 03:48:11 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Maximum Possible Insert Performance? +Date: Sun, 23 Nov 2003 19:48:13 -0800 +Organization: Hub.Org Networking Services +Lines: 12 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/201 +X-Sequence-Number: 4761 + +My situation is this. We have a semi-production server where we +pre-process data and then upload the finished data to our production +servers. We need the fastest possible write performance. Having the DB +go corrupt due to power loss/OS crash is acceptable because we can +always restore from last night and re-run everything that was done since +then. + +I already have fsync off. Short of buying more hardware -- which I will +probably do anyways once I figure out whether I need more CPU, memory or +disk -- what else can I do to max out the speed? Operation mix is about +50% select, 40% insert, 10% update. + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 00:22:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A818CD1C943 + for ; + Mon, 24 Nov 2003 04:22:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77687-03 + for ; + Mon, 24 Nov 2003 00:21:35 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AB26D1D607 + for ; + Mon, 24 Nov 2003 00:21:34 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAO4LX19002409; + Sun, 23 Nov 2003 23:21:33 -0500 (EST) +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +In-reply-to: +References: +Comments: In-reply-to William Yu + message dated "Sun, 23 Nov 2003 19:48:13 -0800" +Date: Sun, 23 Nov 2003 23:21:33 -0500 +Message-ID: <2408.1069647693@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/202 +X-Sequence-Number: 4762 + +William Yu writes: +> [ we don't care about data integrity ] +> I already have fsync off. Short of buying more hardware -- which I will +> probably do anyways once I figure out whether I need more CPU, memory or +> disk -- what else can I do to max out the speed? Operation mix is about +> 50% select, 40% insert, 10% update. + +Batch operations so you commit more than one insert per transaction. +(With fsync off, this isn't such a killer consideration as it would be +with fsync on, but the per-transaction overhead is still nontrivial.) + +Get rid of as many integrity constraints as you feel can reasonably be +postponed to the final upload. FK checks are particularly painful. + +Eliminate indexes where possible. + +Also (I hate to say this, but...) you should consider using Some Other +Database. "I don't care about data integrity, only speed" sounds like +a good fit to MySQL ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 24 00:30:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 53FA7D1C96C + for ; + Mon, 24 Nov 2003 04:30:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70237-09 + for ; + Mon, 24 Nov 2003 00:29:59 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id BA25AD1C951 + for ; + Mon, 24 Nov 2003 00:29:58 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3966870; Sun, 23 Nov 2003 20:30:44 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: William Yu , pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +Date: Sun, 23 Nov 2003 20:29:04 -0800 +User-Agent: KMail/1.4.3 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311232029.04120.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/203 +X-Sequence-Number: 4763 + +William, + +> I already have fsync off. Short of buying more hardware -- which I will +> probably do anyways once I figure out whether I need more CPU, memory or +> disk -- what else can I do to max out the speed? Operation mix is about +> 50% select, 40% insert, 10% update. + +Disk. Multi-channel RAID is where it's at, and/or RAID with a great write +cache enabled. For really fast updates, I'd suggest 6-disk or even 8-disk +RAID 1+0. + +As soon as you have gobs of extra disk space, jack your checkpoint_buffers way +up, like a couple of gigs. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Nov 24 00:42:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A80ED1B8B9 + for ; + Mon, 24 Nov 2003 04:42:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81247-04 + for ; + Mon, 24 Nov 2003 00:42:02 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id E3DE3D1CAD1 + for ; + Mon, 24 Nov 2003 00:42:01 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 610270; Sun, 23 Nov 2003 20:39:54 -0800 +Message-ID: <3FC18BAF.7070506@joeconway.com> +Date: Sun, 23 Nov 2003 20:40:15 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.3) Gecko/20030312 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/204 +X-Sequence-Number: 4764 + +William Yu wrote: +> My situation is this. We have a semi-production server where we +> pre-process data and then upload the finished data to our production +> servers. We need the fastest possible write performance. Having the DB +> go corrupt due to power loss/OS crash is acceptable because we can +> always restore from last night and re-run everything that was done since +> then. + +If you can, use COPY -- it is far faster than INSERT. + +See: +http://www.postgresql.org/docs/current/static/sql-copy.html + +HTH, + +Joe + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 01:51:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 09F61D1C951 + for ; + Mon, 24 Nov 2003 05:51:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94076-02 + for ; + Mon, 24 Nov 2003 01:50:43 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id C3A69D1D7C7 + for ; + Mon, 24 Nov 2003 01:50:41 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Sun, 23 Nov 2003 22:50:41 -0700 +Message-ID: <3FC19C2C.4050704@myrealbox.com> +Date: Mon, 24 Nov 2003 11:20:36 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/205 +X-Sequence-Number: 4765 + +William Yu wrote: + +> My situation is this. We have a semi-production server where we +> pre-process data and then upload the finished data to our production +> servers. We need the fastest possible write performance. Having the DB +> go corrupt due to power loss/OS crash is acceptable because we can +> always restore from last night and re-run everything that was done since +> then. +> +> I already have fsync off. Short of buying more hardware -- which I will +> probably do anyways once I figure out whether I need more CPU, memory or +> disk -- what else can I do to max out the speed? Operation mix is about +> 50% select, 40% insert, 10% update. + +Mount WAL on RAM disk. WAL is most often hit area for heavy updates/inserts. If +you spped that up, things should be pretty faster. + +A non-tried advice though. Given that you can afford a crash, I would say it is +worth a try.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 07:26:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0421AD1D989 + for ; + Mon, 24 Nov 2003 11:26:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43333-09 + for ; + Mon, 24 Nov 2003 07:25:52 -0400 (AST) +Received: from easily.co.uk (unknown [213.161.76.90]) + by svr1.postgresql.org (Postfix) with ESMTP id F270CD1D8DA + for ; + Mon, 24 Nov 2003 07:25:48 -0400 (AST) +Received: from [80.3.250.23] (HELO hare) + by easily.co.uk (CommuniGate Pro SMTP 4.1.3) + with SMTP id 35717045; Mon, 24 Nov 2003 11:25:31 +0000 +Message-ID: <000c01c3b27d$91b4fec0$0300a8c0@hare> +From: "Nick Barr" +To: "Josh Berkus" , + +References: <3FBF4EF3.6090507@chuckie.co.uk> + <200311220919.23695.josh@agliodbs.com> +Subject: Re: pg_autoconfig.pl +Date: Mon, 24 Nov 2003 11:24:47 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/206 +X-Sequence-Number: 4766 + +----- Original Message ----- +From: "Josh Berkus" +To: "Nick Barr" ; +Sent: Saturday, November 22, 2003 5:19 PM +Subject: Re: pg_autoconfig.pl + + +> Nick, +> +> > Josh have you managed to put together the rest of the calculations yet? +> +> Given that I spent most of November working on the PR for the 7.4 release, +> I've just started to think about it. As you can see, I'm thinking about +> dovetailing pg_avd and pg_autoconf. +> +> The difficult thing is to figure out settings for "bad" hardware setups. +Like +> a 5GB database on a PIII500 + 256mb running 4 other pieces of major +software +> (I've acctually seen this). Or a 500/minute OLTP database on a machine +> with 1 fixed disk. +> +> All the variables are going into a hash array, right? + +Yep that rights.$sys is the array name. And there are loads of different +keys for the hash. I will try and get a listing out of the script sometime. + + +Nick + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 12:03:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7ACED1DA3B + for ; + Mon, 24 Nov 2003 13:39:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81119-06 + for ; + Mon, 24 Nov 2003 09:38:38 -0400 (AST) +Received: from mta11.adelphia.net (mta11.adelphia.net [68.168.78.205]) + by svr1.postgresql.org (Postfix) with ESMTP id D8E29D1DA2E + for ; + Mon, 24 Nov 2003 09:38:28 -0400 (AST) +Received: from potentialtech.com ([68.68.113.33]) by mta11.adelphia.net + (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP + id <20031124133835.QRGN1464.mta11.adelphia.net@potentialtech.com>; + Mon, 24 Nov 2003 08:38:35 -0500 +Message-ID: <3FC209D7.5080303@potentialtech.com> +Date: Mon, 24 Nov 2003 08:38:31 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/207 +X-Sequence-Number: 4767 + +William Yu wrote: +> My situation is this. We have a semi-production server where we +> pre-process data and then upload the finished data to our production +> servers. We need the fastest possible write performance. Having the DB +> go corrupt due to power loss/OS crash is acceptable because we can +> always restore from last night and re-run everything that was done since +> then. +> +> I already have fsync off. Short of buying more hardware -- which I will +> probably do anyways once I figure out whether I need more CPU, memory or +> disk -- what else can I do to max out the speed? Operation mix is about +> 50% select, 40% insert, 10% update. + +In line with what Tom Lane said, you may want to look at the various +memory databases available (I'm not familiar with any one to recommend, +though) If you can fit the whole database in RAM, that would work +great, if not, you may be able to split the DB up and put the most +used tables just in the memory database. + +I have also seen a number tutorials on how to put a database on a +RAM disk. This helps, but it's still not as fast as a database server +that's designed to keep all its data in RAM. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 13:14:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AD5DD1D896 + for ; + Mon, 24 Nov 2003 17:14:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70645-07 + for ; + Mon, 24 Nov 2003 13:14:15 -0400 (AST) +Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) + by svr1.postgresql.org (Postfix) with SMTP id 50841D1D86A + for ; + Mon, 24 Nov 2003 13:14:14 -0400 (AST) +Received: (qmail 18307 invoked from network); 24 Nov 2003 17:14:58 -0000 +Received: from unknown (HELO busybox.trade-india.com) (203.145.130.142) + by ns5.trade-india.com with SMTP; 24 Nov 2003 17:14:58 -0000 +From: Rajesh Kumar Mallah +Organization: Trade-India.com +To: pgsql-performance@postgresql.org +Subject: VACUUM problems with 7.4 +Date: Mon, 24 Nov 2003 22:43:59 +0530 +User-Agent: KMail/1.5.3 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311242243.59296.mallah@trade-india.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/208 +X-Sequence-Number: 4768 + + +I am sure there is no transaction open with the table banner_stats2. +Still VACUUM FULL does not seems to effective in removing the +dead rows. + +Can any one please help? + +Regds +mallah + +tradein_clients=# VACUUM FULL verbose banner_stats2 ; +INFO: vacuuming "public.banner_stats2" +INFO: "banner_stats2": found 0 removable, 741912 nonremovable row versions in +6710 pages +DETAIL: 737900 dead row versions cannot be removed yet. +Nonremovable row versions range from 61 to 72 bytes long. +There were 120 unused item pointers. +Total free space (including removable row versions) is 246672 bytes. +0 pages are or will become empty, including 0 at the end of the table. +557 pages containing 61344 free bytes are potential move destinations. +CPU 0.15s/1.23u sec elapsed 1.38 sec. +INFO: index "banner_stats_pkey" now contains 741912 row versions in 2173 +pages +DETAIL: 0 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.03s/0.05u sec elapsed 0.09 sec. +INFO: "banner_stats2": moved 0 row versions, truncated 6710 to 6710 pages +DETAIL: CPU 0.00s/0.00u sec elapsed 0.00 sec. +VACUUM +tradein_clients=# + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 13:21:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1674DD1B50A + for ; + Mon, 24 Nov 2003 17:21:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74973-10 + for ; + Mon, 24 Nov 2003 13:21:10 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 678ECD1C914 + for ; + Mon, 24 Nov 2003 13:21:10 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAOHLANu001635 + for ; Mon, 24 Nov 2003 17:21:10 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAOHJLOD001134 + for pgsql-performance@postgresql.org; Mon, 24 Nov 2003 17:19:21 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Maximum Possible Insert Performance? +Date: Mon, 24 Nov 2003 09:19:20 -0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <3FC19C2C.4050704@myrealbox.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <3FC19C2C.4050704@myrealbox.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/209 +X-Sequence-Number: 4769 + +This is an intriguing thought which leads me to think about a similar +solution for even a production server and that's a solid state drive for +just the WAL. What's the max disk space the WAL would ever take up? +There's quite a few 512MB/1GB/2GB solid state drives available now in +the ~$200-$500 range and if you never hit those limits... + +When my current job batch is done, I'll save a copy of the dir and give +the WAL on ramdrive a test. And perhaps even buy a Sandisk at the local +store and run that through the hooper. + + +Shridhar Daithankar wrote: +> +> Mount WAL on RAM disk. WAL is most often hit area for heavy +> updates/inserts. If you spped that up, things should be pretty faster. + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 13:27:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DC62D1C943 + for ; + Mon, 24 Nov 2003 17:27:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76321-06 + for ; + Mon, 24 Nov 2003 13:26:56 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A961D1B531 + for ; + Mon, 24 Nov 2003 13:26:55 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3969930; Mon, 24 Nov 2003 09:27:42 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: William Yu , pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +Date: Mon, 24 Nov 2003 09:25:58 -0800 +User-Agent: KMail/1.4.3 +References: <3FC19C2C.4050704@myrealbox.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311240925.58070.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/210 +X-Sequence-Number: 4770 + +William, + +> When my current job batch is done, I'll save a copy of the dir and give +> the WAL on ramdrive a test. And perhaps even buy a Sandisk at the local +> store and run that through the hooper. + +We'll be interested in the results. The Sandisk won't be much of a +performance test; last I checked, their access speed was about 1/2 that of a +fast SCSI drive. But it could be a feasability test for the more expensive +RAMdrive approach. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Nov 24 13:45:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 183A9D1CCE0 + for ; + Mon, 24 Nov 2003 17:45:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75930-10 + for ; + Mon, 24 Nov 2003 13:44:31 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B0AECD1C96C + for ; + Mon, 24 Nov 2003 13:44:30 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAOHiU19021400; + Mon, 24 Nov 2003 12:44:30 -0500 (EST) +To: Rajesh Kumar Mallah +Cc: pgsql-performance@postgresql.org +Subject: Re: VACUUM problems with 7.4 +In-reply-to: <200311242243.59296.mallah@trade-india.com> +References: <200311242243.59296.mallah@trade-india.com> +Comments: In-reply-to Rajesh Kumar Mallah + message dated "Mon, 24 Nov 2003 22:43:59 +0530" +Date: Mon, 24 Nov 2003 12:44:30 -0500 +Message-ID: <21399.1069695870@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/211 +X-Sequence-Number: 4771 + +Rajesh Kumar Mallah writes: +> I am sure there is no transaction open with the table banner_stats2. +> Still VACUUM FULL does not seems to effective in removing the +> dead rows. + +That is not the issue --- the limiting factor is what is your oldest +open transaction, period. Whether it has yet looked at this table is +not relevant, because the system has no way to know whether it might +decide to do so later. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Nov 24 13:51:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 70D6AD1D453 + for ; + Mon, 24 Nov 2003 17:51:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76764-06 + for ; + Mon, 24 Nov 2003 13:51:11 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 73A87D1B50A + for ; + Mon, 24 Nov 2003 13:51:10 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAOHp9Nu007323 + for ; Mon, 24 Nov 2003 17:51:09 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAOHjOdR006303 + for pgsql-performance@postgresql.org; Mon, 24 Nov 2003 17:45:24 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Maximum Possible Insert Performance? +Date: Mon, 24 Nov 2003 09:45:22 -0800 +Organization: Hub.Org Networking Services +Lines: 22 +Message-ID: +References: <3FC19C2C.4050704@myrealbox.com> + <200311240925.58070.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <200311240925.58070.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/212 +X-Sequence-Number: 4772 + +Josh Berkus wrote: +> William, +> +> +>>When my current job batch is done, I'll save a copy of the dir and give +>>the WAL on ramdrive a test. And perhaps even buy a Sandisk at the local +>>store and run that through the hooper. +> +> +> We'll be interested in the results. The Sandisk won't be much of a +> performance test; last I checked, their access speed was about 1/2 that of a +> fast SCSI drive. But it could be a feasability test for the more expensive +> RAMdrive approach. +> + + +The SanDisks do seem a bit pokey at 16MBps. On the otherhand, you could +get 4 of these suckers, put them in a mega-RAID-0 stripe for 64MBps. You +shouldn't need to do mirroring with a solid state drive. + +Time to Google up some more solid state drive vendors. + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:02:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 74F0FD1C914 + for ; + Mon, 24 Nov 2003 18:02:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80820-07 + for ; + Mon, 24 Nov 2003 14:01:58 -0400 (AST) +Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) + by svr1.postgresql.org (Postfix) with SMTP id 85BF1D1C976 + for ; + Mon, 24 Nov 2003 14:01:57 -0400 (AST) +Received: (qmail 10900 invoked from network); 24 Nov 2003 18:04:06 -0000 +Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) + by ns1.trade-india.com with SMTP; 24 Nov 2003 18:04:06 -0000 +Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) + by mail.trade-india.com with HTTP; + Mon, 24 Nov 2003 23:34:06 +0530 (IST) +Message-ID: <33398.203.145.130.142.1069697046.squirrel@mail.trade-india.com> +Date: Mon, 24 Nov 2003 23:34:06 +0530 (IST) +Subject: Re: VACUUM problems with 7.4 +From: +To: +In-Reply-To: <21399.1069695870@sss.pgh.pa.us> +References: <200311242243.59296.mallah@trade-india.com> + <21399.1069695870@sss.pgh.pa.us> +X-Priority: 3 +Importance: Normal +X-MSMail-Priority: Normal +Cc: +X-Mailer: SquirrelMail (version 1.2.6) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/213 +X-Sequence-Number: 4773 + +> Rajesh Kumar Mallah writes: +>> I am sure there is no transaction open with the table banner_stats2. Still VACUUM FULL does +>> not seems to effective in removing the +>> dead rows. +> +> That is not the issue --- the limiting factor is what is your oldest open transaction, period. +> Whether it has yet looked at this table is not relevant, because the system has no way to know +> whether it might decide to do so later. + + +Ok , shutting down the database and vacumming immediatly after starting +helped . + +But it was not this bad in 7.3 as far as i understand. Is it something that +has come up in 7.4 only , if so any solution to this issue? + +BTW can you please tell me if its safe to upgrade from RC2 to 7.4 final +without initdb? [ i am still on RC2 :( ] + + +Regds +Mallah. + + + + + +AFTER RESTARTING DATABASE: + +tradein_clients=# VACUUM FULL verbose banner_stats2 ; +INFO: vacuuming "public.banner_stats2" +INFO: "banner_stats2": found 737900 removable, 4012 nonremovable row versions in 6710 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 61 to 72 bytes long. +There were 120 unused item pointers. +Total free space (including removable row versions) is 51579272 bytes. +6387 pages are or will become empty, including 0 at the end of the table. +6686 pages containing 51578312 free bytes are potential move destinations. +CPU 0.17s/0.09u sec elapsed 0.26 sec. +INFO: index "banner_stats_pkey" now contains 4012 row versions in 2165 pages +DETAIL: 737900 index row versions were removed. +1813 index pages have been deleted, 1813 are currently reusable. +CPU 0.16s/1.58u sec elapsed 1.97 sec. +INFO: "banner_stats2": moved 785 row versions, truncated 6710 to 38 pages +DETAIL: CPU 0.17s/0.54u sec elapsed 8.30 sec. +INFO: index "banner_stats_pkey" now contains 4012 row versions in 2165 pages +DETAIL: 785 index row versions were removed. +1821 index pages have been deleted, 1821 are currently reusable. +CPU 0.00s/0.02u sec elapsed 0.50 sec. +VACUUM +tradein_clients=# + + + +tradein_clients=# VACUUM FULL verbose banner_stats2 ; +INFO: vacuuming "public.banner_stats2" +INFO: "banner_stats2": found 0 removable, 4012 nonremovable row versions in 38 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 61 to 72 bytes long. +There were 100 unused item pointers. +Total free space (including removable row versions) is 7368 bytes. +0 pages are or will become empty, including 0 at the end of the table. +2 pages containing 5984 free bytes are potential move destinations. +CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: index "banner_stats_pkey" now contains 4012 row versions in 2165 pages +DETAIL: 0 index row versions were removed. +1821 index pages have been deleted, 1821 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: "banner_stats2": moved 0 row versions, truncated 38 to 38 pages +DETAIL: CPU 0.00s/0.00u sec elapsed 0.00 sec. +VACUUM +tradein_clients=# + + + +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off +> all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + +----------------------------------------- +Over 1,00,000 exporters are waiting for your order! Click below to get +in touch with leading Indian exporters listed in the premier +trade directory Exporters Yellow Pages. +http://www.trade-india.com/dyn/gdh/eyp/ + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:06:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BEC6AD1CB08 + for ; + Mon, 24 Nov 2003 18:06:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78108-09 + for ; + Mon, 24 Nov 2003 14:05:36 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C3689D1C96C + for ; + Mon, 24 Nov 2003 14:05:35 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3970123; Mon, 24 Nov 2003 10:06:23 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: William Yu , pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +Date: Mon, 24 Nov 2003 10:04:37 -0800 +User-Agent: KMail/1.4.3 +References: + <200311240925.58070.josh@agliodbs.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200311241004.37969.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/214 +X-Sequence-Number: 4774 + +William, + +> The SanDisks do seem a bit pokey at 16MBps. On the otherhand, you could +> get 4 of these suckers, put them in a mega-RAID-0 stripe for 64MBps. You +> shouldn't need to do mirroring with a solid state drive. + +I wouldn't count on RAID0 improving the speed of SANDisk's much. How are you +connecting to them? USB? USB doesn't support fast parallel data access. + +Now, if it turns out that 256MB ramdisks are less than 1/5 the cost of 1GB +ramdisks, then that's worth considering. + +You're right, though, mirroring a solid state drive is pretty pointless; if +power fails, both mirrors are dead. + +As I said before, though, we're all very interested in this test. Using a +ramdisk for WAL has been discussed on this list numerous times but not +attempted by anyone who published their results. + +All that aside, though, I think you should also experiment with the Background +Writer patch recently discussed on Hackers, as it may give you a performance +boost as well. +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Nov 24 14:52:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AC9A9D1D8A9 + for ; + Mon, 24 Nov 2003 18:52:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99120-02 + for ; + Mon, 24 Nov 2003 14:51:39 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 66847D1D880 + for ; + Mon, 24 Nov 2003 14:51:10 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAOIpANu018836 + for ; Mon, 24 Nov 2003 18:51:10 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAOINbCO013502 + for pgsql-performance@postgresql.org; Mon, 24 Nov 2003 18:23:37 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Maximum Possible Insert Performance? +Date: Mon, 24 Nov 2003 10:23:36 -0800 +Organization: Hub.Org Networking Services +Lines: 29 +Message-ID: +References: + <200311240925.58070.josh@agliodbs.com> + <200311241004.37969.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <200311241004.37969.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/215 +X-Sequence-Number: 4775 + +Josh Berkus wrote: +> William, +> +> +>>The SanDisks do seem a bit pokey at 16MBps. On the otherhand, you could +>>get 4 of these suckers, put them in a mega-RAID-0 stripe for 64MBps. You +>>shouldn't need to do mirroring with a solid state drive. +> +> +> I wouldn't count on RAID0 improving the speed of SANDisk's much. How are you +> connecting to them? USB? USB doesn't support fast parallel data access. + +You can get ATA SanDisks up to 2GB. Another vendor I checked out -- +BitMicro -- has solid state drives for SATA, SCSI and FiberChannel. I'd +definitely would not use USB SSDs -- USB performance would be so pokey +to be useless. + +> Now, if it turns out that 256MB ramdisks are less than 1/5 the cost of 1GB +> ramdisks, then that's worth considering. + +Looks like they're linear with size. SanDisk Flashdrive 1GB is about +$1000 while 256MB is $250. + +> You're right, though, mirroring a solid state drive is pretty pointless; if +> power fails, both mirrors are dead. + +Actually no. Solid state memory is non-volatile. They retain data even +without power. + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 15:30:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E598ED1D453 + for ; + Mon, 24 Nov 2003 19:30:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14012-02 + for ; + Mon, 24 Nov 2003 15:30:04 -0400 (AST) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id C6FE9D1D643 + for ; + Mon, 24 Nov 2003 15:29:45 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AOMP2-000DtI-0Z; Mon, 24 Nov 2003 19:29:44 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 90E4C17CEC; Mon, 24 Nov 2003 19:29:42 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id EBF861622E; Mon, 24 Nov 2003 19:29:40 +0000 (GMT) +From: Richard Huxton +To: stephen farrell , + pgsql-performance@postgresql.org +Subject: Re: Problem with insert into select... +Date: Mon, 24 Nov 2003 19:29:40 +0000 +User-Agent: KMail/1.5 +References: <3FBD2C5D.8000706@almaden.ibm.com> +In-Reply-To: <3FBD2C5D.8000706@almaden.ibm.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311241929.40600.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/223 +X-Sequence-Number: 4783 + +On Thursday 20 November 2003 21:04, stephen farrell wrote: +> I'm having a problem with a queyr like: INSERT INTO FACT (x,x,x,x,x,x) +> SELECT a.key,b.key,c.key,d.key,e.key,f.key from x,a,b,c,d,e,f where x=a +> and x=b .... -- postgres7.4 is running out of memory. + +When this has happened to me it's always been because I've got an +unconstrained join due to pilot error. Try an EXPLAIN on the select part and +see if that pops up anything. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Nov 24 17:20:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C373D1D609 + for ; + Mon, 24 Nov 2003 21:20:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37148-07 + for ; + Mon, 24 Nov 2003 17:20:16 -0400 (AST) +Received: from smtp.noos.fr (nan-smtp-20.noos.net [212.198.2.120]) + by svr1.postgresql.org (Postfix) with ESMTP id 87615D1D8AF + for ; + Mon, 24 Nov 2003 17:20:13 -0400 (AST) +Received: (qmail 7192 invoked by uid 0); 24 Nov 2003 21:20:14 -0000 +Received: from unknown (HELO bigfoot.com) ([212.198.40.101]) + (envelope-sender ) + by 212.198.2.120 (qmail-ldap-1.03) with SMTP + for ; 24 Nov 2003 21:20:14 -0000 +Message-ID: <3FC267FB.806@bigfoot.com> +Date: Mon, 24 Nov 2003 21:20:11 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Torsten Schulz +Subject: Re: Optimize +References: <3FC26E96.9090101@be-a-part.de> +In-Reply-To: <3FC26E96.9090101@be-a-part.de> +X-Enigmail-Version: 0.81.7.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/225 +X-Sequence-Number: 4785 + +Torsten Schulz wrote: + +> Yes, I know: very difficult question, but I don't know what to do now. +> +> Our Server: +> Dual-CPU with 1.2 GHz +> 1.5 GB RAM +> +> Our Problem: We are a Community. Between 19 and 21 o clock we have >350 +> User in the Community. But then, the Database are very slow. And we have +> per CPU ~20-30% idle-time. + +May we know the postgres version that you are running and +see the query that run slow ? +Is also usefull take a look at your postgresql configuration. +You can see doing select * from pg_stat_activity the +queries that are currently running on your server, and +do a explain analize on it to see which one is the +bottleneck. If you are running the 7.4 you can see on +the log the total ammount for each query. + +Let us know. + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 16:48:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D70AD1D8AF + for ; + Mon, 24 Nov 2003 20:48:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31109-07 + for ; + Mon, 24 Nov 2003 16:48:24 -0400 (AST) +Received: from natsmtp01.rzone.de (natsmtp01.rzone.de [81.169.145.166]) + by svr1.postgresql.org (Postfix) with ESMTP id B59A9D1B531 + for ; + Mon, 24 Nov 2003 16:48:21 -0400 (AST) +Received: from be-a-part.de (pD9E820FC.dip.t-dialin.net [217.232.32.252]) + by post.webmailer.de (8.12.10/8.12.10) with ESMTP id hAOKmMMk010850 + for ; + Mon, 24 Nov 2003 21:48:22 +0100 (MET) +Message-ID: <3FC26E96.9090101@be-a-part.de> +Date: Mon, 24 Nov 2003 21:48:22 +0100 +From: Torsten Schulz +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Optimize +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/224 +X-Sequence-Number: 4784 + +Yes, I know: very difficult question, but I don't know what to do now. + +Our Server: +Dual-CPU with 1.2 GHz +1.5 GB RAM + +Our Problem: We are a Community. Between 19 and 21 o clock we have >350 +User in the Community. But then, the Database are very slow. And we have +per CPU ~20-30% idle-time. + +Has anyone an idea what's the best configuration for thta server? + +Many Greetings +T. Schulz (with very bad english, i know) + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 17:56:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D505D1D643 + for ; + Mon, 24 Nov 2003 21:56:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49023-06 + for ; + Mon, 24 Nov 2003 17:56:21 -0400 (AST) +Received: from smtp.noos.fr (nan-smtp-16.noos.net [212.198.2.124]) + by svr1.postgresql.org (Postfix) with ESMTP id AD30AD1B520 + for ; + Mon, 24 Nov 2003 17:56:18 -0400 (AST) +Received: (qmail 13334 invoked by uid 0); 24 Nov 2003 21:56:20 -0000 +Received: from unknown (HELO bigfoot.com) ([212.198.40.101]) + (envelope-sender ) + by 212.198.2.124 (qmail-ldap-1.03) with SMTP + for ; 24 Nov 2003 21:56:20 -0000 +Message-ID: <3FC27071.9000001@bigfoot.com> +Date: Mon, 24 Nov 2003 21:56:17 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Torsten Schulz +Subject: Re: Optimize +References: <3FC26E96.9090101@be-a-part.de> <3FC267FB.806@bigfoot.com> + <3FC27911.7070403@be-a-part.de> +In-Reply-To: <3FC27911.7070403@be-a-part.de> +X-Enigmail-Version: 0.81.7.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/228 +X-Sequence-Number: 4788 + +Torsten Schulz wrote: + +> Gaetano Mendola wrote: +> +>> Torsten Schulz wrote: +>> +>>> Yes, I know: very difficult question, but I don't know what to do now. +>>> +>>> Our Server: +>>> Dual-CPU with 1.2 GHz +>>> 1.5 GB RAM +>>> +>>> Our Problem: We are a Community. Between 19 and 21 o clock we have +>>> >350 User in the Community. But then, the Database are very slow. And +>>> we have per CPU ~20-30% idle-time. +>> +>> +>> +>> May we know the postgres version that you are running and +>> see the query that run slow ? +> +> +> Postgres: 7.3.2 +> Query: All queries +> +> Configuration: +> max_connections = 1000 # Must be, if lower then 500 we become +> connection-errors +> shared_buffers = 5000 # 2*max_connections, min 16 +> max_fsm_relations = 1000 # min 10, fsm is free space map +> max_fsm_pages = 2000000 # min 1000, fsm is free space map +> max_locks_per_transaction = 64 # min 10 +> wal_buffers = 2000 # min 4 +> +> sort_mem = 32768 # min 32 +> vacuum_mem = 32768 # min 1024 +> +> fsync = false +> +> enable_seqscan = true +> enable_indexscan = true +> enable_tidscan = true +> enable_sort = true +> enable_nestloop = true +> enable_mergejoin = true +> enable_hashjoin = true +> +> effective_cache_size = 96000 # default in 8k pages + +With 500 connection at the sime time 32MB for sort_mem can be too much. +What say "iostat 1" and "vmstat 1" ? + +Try also to reduce this costs: + +random_page_cost = 2.5 +cpu_tuple_cost = 0.005 +cpu_index_tuple_cost = 0.0005 + + +BTW take a query and show us the result of explain analyze. + + +Regards +Gaetano Mendola + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 17:33:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BF53BD1D9D3 + for ; + Mon, 24 Nov 2003 21:33:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43164-07 + for ; + Mon, 24 Nov 2003 17:33:07 -0400 (AST) +Received: from natsmtp01.rzone.de (natsmtp01.rzone.de [81.169.145.166]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FCDAD1D8EA + for ; + Mon, 24 Nov 2003 17:33:05 -0400 (AST) +Received: from be-a-part.de (pD9E820FC.dip.t-dialin.net [217.232.32.252]) + by post.webmailer.de (8.12.10/8.12.10) with ESMTP id hAOLX5Al021454 + for ; + Mon, 24 Nov 2003 22:33:06 +0100 (MET) +Message-ID: <3FC27911.7070403@be-a-part.de> +Date: Mon, 24 Nov 2003 22:33:05 +0100 +From: Torsten Schulz +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Optimize +References: <3FC26E96.9090101@be-a-part.de> <3FC267FB.806@bigfoot.com> +In-Reply-To: <3FC267FB.806@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/226 +X-Sequence-Number: 4786 + +Gaetano Mendola wrote: + +> Torsten Schulz wrote: +> +>> Yes, I know: very difficult question, but I don't know what to do now. +>> +>> Our Server: +>> Dual-CPU with 1.2 GHz +>> 1.5 GB RAM +>> +>> Our Problem: We are a Community. Between 19 and 21 o clock we have +>> >350 User in the Community. But then, the Database are very slow. And +>> we have per CPU ~20-30% idle-time. +> +> +> May we know the postgres version that you are running and +> see the query that run slow ? + +Postgres: 7.3.2 +Query: All queries + +Configuration: +max_connections = 1000 # Must be, if lower then 500 we become +connection-errors +shared_buffers = 5000 # 2*max_connections, min 16 +max_fsm_relations = 1000 # min 10, fsm is free space map +max_fsm_pages = 2000000 # min 1000, fsm is free space map +max_locks_per_transaction = 64 # min 10 +wal_buffers = 2000 # min 4 + +sort_mem = 32768 # min 32 +vacuum_mem = 32768 # min 1024 + +fsync = false + +enable_seqscan = true +enable_indexscan = true +enable_tidscan = true +enable_sort = true +enable_nestloop = true +enable_mergejoin = true +enable_hashjoin = true + +effective_cache_size = 96000 # default in 8k pages + + +That are all uncommented lines. I've found the values in internet and +had tested it. But in performance are no difference between old +configuration an this. + +> Is also usefull take a look at your postgresql configuration. +> You can see doing select * from pg_stat_activity the +> queries that are currently running on your server, and +> do a explain analize on it to see which one is the +> bottleneck. If you are running the 7.4 you can see on +> the log the total ammount for each query. +> +I'll show tomorrow for this, today it is too late, the performance is +now perfect. It's only slow on this 2 hours with so many users on server. + +Oh, and i can't update to 7.4. The Chat don't run with libraries of 7.4 + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 17:46:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 09166D1D86B + for ; + Mon, 24 Nov 2003 21:46:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48630-02 + for ; + Mon, 24 Nov 2003 17:45:51 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 019D6D1D643 + for ; + Mon, 24 Nov 2003 17:45:48 -0400 (AST) +Received: from zigo.dhs.org (zigo [127.0.0.1]) + by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id hAOLjiL2028737; + Mon, 24 Nov 2003 22:45:44 +0100 +Received: from localhost (db@localhost) + by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id hAOLjioS028733; + Mon, 24 Nov 2003 22:45:44 +0100 +Date: Mon, 24 Nov 2003 22:45:44 +0100 (CET) +From: Dennis Bjorklund +To: Torsten Schulz +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimize +In-Reply-To: <3FC27911.7070403@be-a-part.de> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/227 +X-Sequence-Number: 4787 + +On Mon, 24 Nov 2003, Torsten Schulz wrote: + +> sort_mem = 32768 # min 32 + +32 meg per sort can be a lot in total if you have many clients sorting +things. I assume you have checked so that the computer is not pushed into +swapping when you have the peak with lots of users. A swapping computer is +never fast. + +Using some swap space is not bad, but a lot of page in and page out to the +swap is not good. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 18:03:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E4B2D1C92F + for ; + Mon, 24 Nov 2003 22:03:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52085-01 + for ; + Mon, 24 Nov 2003 18:02:51 -0400 (AST) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id B66CBD1D643 + for ; + Mon, 24 Nov 2003 18:02:48 -0400 (AST) +Received: from game (12-250-179-10.client.attbi.com[12.250.179.10]) + by comcast.net (sccrmhc13) with SMTP + id <2003112422025001600etecle>; Mon, 24 Nov 2003 22:02:50 +0000 +Message-ID: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +Reply-To: "MK Spam" +From: "MK Spam" +To: +Subject: Where to start for performance problem? +Date: Mon, 24 Nov 2003 16:03:17 -0600 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_2B1C_01C3B2A4.7921BA20" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=HTML_10_20 +X-Spam-Level: * +X-Archive-Number: 200311/229 +X-Sequence-Number: 4789 + +This is a multi-part message in MIME format. + +------=_NextPart_000_2B1C_01C3B2A4.7921BA20 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I've scanned some of the archives and have learned a lot about different pe= +rformance tuning practices. I will be looking into using many of these ide= +as but I'm not sure they address the issue I am currently experiencing. + +First, I'm a total newb with postgresql. Like many before me, I have inher= +ited many responsibilities outside of my original job description due to la= +yoffs. I am now the sole developer/support for a software product. *sigh*= + This product uses postgresql. I am familiar with the basics of sql and h= +ave worked on the database and code for the software but by no means am I p= +roficient with postgresql. + +The archives of this list provides many ideas for improving performance, bu= +t the problem we are having is gradually degrading performance ending in po= +stgres shutting down. So it's not a matter of optimizing a complex query t= +o take 5 seconds instead of 60 seconds. From what I can tell we are using = +the VACUUM command on a schedule but it doesn't seem to prevent the databas= +e from becoming "congested" as we refer to it. :] Anyway, the only way I = +know to "fix" the problem is to export (pg_dump) the db, drop the database,= + recreate the database and import the dump. This seems to return performan= +ce back to normal but obviously isn't a very good "solution". The slowdown= + and subsequent crash can take as little as 1 week for databases with a lot= + of data or go as long as a few weeks to a month for smaller data sets. + +I don't really know where to start looking for a solution. Any advice on w= +here to start, understanding that I am a newb, would be greatly appreciated= +. Thank you. + +Nid +------=_NextPart_000_2B1C_01C3B2A4.7921BA20 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
I've scanned some of the archives and have= + learned=20 +a lot about different performance tuning practices.  I will be looking= + into=20 +using many of these ideas but I'm not sure they address the issue I am curr= +ently=20 +experiencing.
+
 
+
First, I'm a total newb with postgresql.&n= +bsp; Like=20 +many before me, I have inherited many responsibilities outside of my origin= +al=20 +job description due to layoffs.  I am now the sole developer/support f= +or a=20 +software product.  *sigh*  This product uses postgresql.  I = +am=20 +familiar with the basics of sql and have worked on the database and code fo= +r the=20 +software but by no means am I proficient with postgresql.
+
 
+
The archives of this list provides many id= +eas for=20 +improving performance, but the problem we are having is gradually degrading= +=20 +performance ending in postgres shutting down.  So it's not a matter of= +=20 +optimizing a complex query to take 5 seconds instead of 60 seconds.&nb= +sp;=20 +>From what I can tell we are using the VACUUM command on a schedule but it= +=20 +doesn't seem to prevent the database from becoming "congested" as we refer = +to=20 +it.  :]  Anyway, the only way I know to "fix" the problem is to e= +xport=20 +(pg_dump) the db, drop the database, recreate the database and import the= +=20 +dump.  This seems to return performance back to normal but obviously i= +sn't=20 +a very good "solution".  The slowdown and subsequent crash can take as= +=20 +little as 1 week for databases with a lot of data or go as long as a few we= +eks=20 +to a month for smaller data sets.
+
 
+
I don't really know where to start looking= + for a=20 +solution.  Any advice on where to start, understanding that I am a new= +b,=20 +would be greatly appreciated.  Thank you.
+
 
+
Nid
+ +------=_NextPart_000_2B1C_01C3B2A4.7921BA20-- + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 18:08:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38570D1D80D + for ; + Mon, 24 Nov 2003 22:08:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50487-04 + for ; + Mon, 24 Nov 2003 18:07:34 -0400 (AST) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 00DD8D1B520 + for ; + Mon, 24 Nov 2003 18:07:32 -0400 (AST) +Received: from game (12-250-179-10.client.attbi.com[12.250.179.10]) + by comcast.net (sccrmhc11) with SMTP + id <2003112422073301100nq75ae>; Mon, 24 Nov 2003 22:07:33 +0000 +Message-ID: <2b4b01c3b2d7$6ce8e160$0201a8c0@game> +Reply-To: "Nid" +From: "Nid" +To: +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +Subject: Re: Where to start for performance problem? +Date: Mon, 24 Nov 2003 16:08:00 -0600 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_2B48_01C3B2A5.22211FD0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + REFERENCES +X-Spam-Level: * +X-Archive-Number: 200311/230 +X-Sequence-Number: 4790 + +This is a multi-part message in MIME format. + +------=_NextPart_000_2B48_01C3B2A5.22211FD0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +My apologies for the "From" name of MK Spam. That references an email acco= +unt I made for signing up for things on the net. :] + +Nid + ----- Original Message -----=20 + From: MK Spam=20 + To: pgsql-performance@postgresql.org=20 + Sent: Monday, November 24, 2003 4:03 PM + Subject: [PERFORM] Where to start for performance problem? + + + I've scanned some of the archives and have learned a lot about different = +performance tuning practices. I will be looking into using many of these i= +deas but I'm not sure they address the issue I am currently experiencing. + + First, I'm a total newb with postgresql. Like many before me, I have inh= +erited many responsibilities outside of my original job description due to = +layoffs. I am now the sole developer/support for a software product. *sig= +h* This product uses postgresql. I am familiar with the basics of sql and= + have worked on the database and code for the software but by no means am I= + proficient with postgresql. + + The archives of this list provides many ideas for improving performance, = +but the problem we are having is gradually degrading performance ending in = +postgres shutting down. So it's not a matter of optimizing a complex query= + to take 5 seconds instead of 60 seconds. From what I can tell we are usin= +g the VACUUM command on a schedule but it doesn't seem to prevent the datab= +ase from becoming "congested" as we refer to it. :] Anyway, the only way = +I know to "fix" the problem is to export (pg_dump) the db, drop the databas= +e, recreate the database and import the dump. This seems to return perform= +ance back to normal but obviously isn't a very good "solution". The slowdo= +wn and subsequent crash can take as little as 1 week for databases with a l= +ot of data or go as long as a few weeks to a month for smaller data sets. + + I don't really know where to start looking for a solution. Any advice on= + where to start, understanding that I am a newb, would be greatly appreciat= +ed. Thank you. + + Nid +------=_NextPart_000_2B48_01C3B2A5.22211FD0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
My apologies for the "From" name of MK Spa= +m. =20 +That references an email account I made for signing up for things on the=20 +net.  :]
+
 
+
Nid
+
+
----- Original Message -----
+ Fro= +m:=20 + MK Spa= +m=20 + +
To: pgsql-performance@postgr= +esql.org=20 +
+
Sent: Monday, November 24, 2003 4:= +03=20 + PM
+
Subject: [PERFORM] Where to start = +for=20 + performance problem?
+

+
I've scanned some of the archives and ha= +ve=20 + learned a lot about different performance tuning practices.  I will = +be=20 + looking into using many of these ideas but I'm not sure they address the = +issue=20 + I am currently experiencing.
+
 
+
First, I'm a total newb with postgresql.= + =20 + Like many before me, I have inherited many responsibilities outside of my= +=20 + original job description due to layoffs.  I am now the sole=20 + developer/support for a software product.  *sigh*  This product= + uses=20 + postgresql.  I am familiar with the basics of sql and have worked on= + the=20 + database and code for the software but by no means am I proficient with= +=20 + postgresql.
+
 
+
The archives of this list provides many = +ideas for=20 + improving performance, but the problem we are having is gradually degradi= +ng=20 + performance ending in postgres shutting down.  So it's not a matter = +of=20 + optimizing a complex query to take 5 seconds instead of 60 seconds.&= +nbsp;=20 + From what I can tell we are using the VACUUM command on a schedule but it= +=20 + doesn't seem to prevent the database from becoming "congested" as we refe= +r to=20 + it.  :]  Anyway, the only way I know to "fix" the problem is to= +=20 + export (pg_dump) the db, drop the database, recreate the database and imp= +ort=20 + the dump.  This seems to return performance back to normal but obvio= +usly=20 + isn't a very good "solution".  The slowdown and subsequent crash can= + take=20 + as little as 1 week for databases with a lot of data or go as long as a f= +ew=20 + weeks to a month for smaller data sets.
+
 
+
I don't really know where to start looki= +ng for a=20 + solution.  Any advice on where to start, understanding that I am a n= +ewb,=20 + would be greatly appreciated.  Thank you.
+
 
+
Nid
+ +------=_NextPart_000_2B48_01C3B2A5.22211FD0-- + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 21:12:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D16CBD1C914 + for ; + Tue, 25 Nov 2003 01:12:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88612-04 + for ; + Mon, 24 Nov 2003 21:11:41 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id A0F7DD1C951 + for ; + Mon, 24 Nov 2003 21:11:36 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAP1BGoD032541; Tue, 25 Nov 2003 09:11:18 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC2ACCF.2030303@familyhealth.com.au> +Date: Tue, 25 Nov 2003 09:13:51 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: MK Spam +Cc: pgsql-performance@postgresql.org +Subject: Re: Where to start for performance problem? +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +In-Reply-To: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/231 +X-Sequence-Number: 4791 + +> The archives of this list provides many ideas for improving performance, +> but the problem we are having is gradually degrading performance ending +> in postgres shutting down. So it's not a matter of optimizing a complex +> query to take 5 seconds instead of 60 seconds. >From what I can tell we +> are using the VACUUM command on a schedule but it doesn't seem to +> prevent the database from becoming "congested" as we refer to it. :] + +Our busy website has a cronjob that runs VACUUM ANALYZE once an hour +(vacuumdb -a -q -z). + +Have you tried going 'VACUUM FULL ANALYZE' (vacuumdb -a -q -z -f) +instead of a dump and reload? + +Chris + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 21:17:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48BD7D1D8FC + for ; + Tue, 25 Nov 2003 01:17:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88267-10 + for ; + Mon, 24 Nov 2003 21:16:39 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 31F89D1CAD1 + for ; + Mon, 24 Nov 2003 21:16:36 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 478D93695B; Mon, 24 Nov 2003 20:16:28 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AORoZ-0001Dr-00; Mon, 24 Nov 2003 20:16:27 -0500 +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +References: + <200311240925.58070.josh@agliodbs.com> + <200311241004.37969.josh@agliodbs.com> +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 24 Nov 2003 20:16:27 -0500 +Message-ID: <87brr11c44.fsf@stark.dyndns.tv> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/232 +X-Sequence-Number: 4792 + +William Yu writes: + +> > You're right, though, mirroring a solid state drive is pretty pointless; if +> > power fails, both mirrors are dead. +> +> Actually no. Solid state memory is non-volatile. They retain data even without +> power. + +Note that flash ram only has a finite number of write cycles before it fails. + +On the other hand that might not be so bad for WAL which writes sequentially, +you can easily calculate how close you are to the maximum. For things like +heap storage or swap it's awful as you can get hot spots that get written to +thousands of times before the rest of the space is used. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 22:25:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 26B67D1D66C + for ; + Tue, 25 Nov 2003 02:25:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11223-08 + for ; + Mon, 24 Nov 2003 22:24:50 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 29F0BD1D880 + for ; + Mon, 24 Nov 2003 22:24:44 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 3F394203A; Mon, 24 Nov 2003 21:24:47 -0500 (EST) +To: Torsten Schulz +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimize +From: Neil Conway +In-Reply-To: <3FC26E96.9090101@be-a-part.de> (Torsten Schulz's message of + "Mon, 24 Nov 2003 21:48:22 +0100") +References: <3FC26E96.9090101@be-a-part.de> +Date: Mon, 24 Nov 2003 21:24:45 -0500 +Message-ID: <87fzgdnq1e.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/233 +X-Sequence-Number: 4793 + +Torsten Schulz writes: +> Our Server: +> Dual-CPU with 1.2 GHz +> 1.5 GB RAM + +What kind of I/O subsystem is in this machine? This is an x86 machine, +right? + +> Has anyone an idea what's the best configuration for thta server? + +It is difficult to say until you provide some information on the +system's state during periods of heavy traffic. + +BTW, in addition to the machine's hardware configuration, have you +looked at tuning the queries running on PostgreSQL? What about the OS +kernel? + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 22:28:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9724BD1DBA8 + for ; + Tue, 25 Nov 2003 02:28:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12604-05 + for ; + Mon, 24 Nov 2003 22:27:43 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F560D1DA94 + for ; + Mon, 24 Nov 2003 22:27:39 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id BAFD81D9B; Mon, 24 Nov 2003 21:27:41 -0500 (EST) +To: +Cc: , +Subject: Re: VACUUM problems with 7.4 +From: Neil Conway +In-Reply-To: <33398.203.145.130.142.1069697046.squirrel@mail.trade-india.com> + (mallah@trade-india.com's + message of "Mon, 24 Nov 2003 23:34:06 +0530 (IST)") +References: <200311242243.59296.mallah@trade-india.com> + <21399.1069695870@sss.pgh.pa.us> + <33398.203.145.130.142.1069697046.squirrel@mail.trade-india.com> +Date: Mon, 24 Nov 2003 21:27:40 -0500 +Message-ID: <87brr1npwj.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=IN_REP_TO, + RCVD_IN_OSIRUSOFT_COM, REFERENCES, USER_AGENT_GNUS_UA +X-Spam-Level: +X-Archive-Number: 200311/234 +X-Sequence-Number: 4794 + + writes: +> But it was not this bad in 7.3 as far as i understand. + +No, I believe this behavior is present in any recent release of +PostgreSQL. + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 23:05:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB1A0D1C96C + for ; + Tue, 25 Nov 2003 03:05:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16802-01 + for ; + Mon, 24 Nov 2003 23:05:29 -0400 (AST) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id B66F6D1C976 + for ; + Mon, 24 Nov 2003 23:05:24 -0400 (AST) +Received: from game (12-250-179-10.client.attbi.com[12.250.179.10]) + by comcast.net (sccrmhc12) with SMTP + id <2003112503052801200l34a2e>; Tue, 25 Nov 2003 03:05:28 +0000 +Message-ID: <2b8e01c3b301$0bc2f090$0201a8c0@game> +Reply-To: "Nid" +From: "Nid" +To: "Christopher Kings-Lynne" +Cc: +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> + <3FC2ACCF.2030303@familyhealth.com.au> +Subject: Re: Where to start for performance problem? +Date: Mon, 24 Nov 2003 21:05:56 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/235 +X-Sequence-Number: 4795 + +I've been digging around in the code and found where we are executing the +VACUUM command. VACUUM ANALYZE is executed every 15 minutes. We haven't +tried VACUUM FULL ANALYZE. I think I read that using FULL is a good idea +once a day or something. Just doing a VACUUM ANALYZE doesn't seem to be +preventing our problem. Thank you for the responses. + +nid + +----- Original Message ----- +From: "Christopher Kings-Lynne" +To: "MK Spam" +Cc: +Sent: Monday, November 24, 2003 7:13 PM +Subject: Re: [PERFORM] Where to start for performance problem? + + +> > The archives of this list provides many ideas for improving performance, +> > but the problem we are having is gradually degrading performance ending +> > in postgres shutting down. So it's not a matter of optimizing a complex +> > query to take 5 seconds instead of 60 seconds. >From what I can tell we +> > are using the VACUUM command on a schedule but it doesn't seem to +> > prevent the database from becoming "congested" as we refer to it. :] +> +> Our busy website has a cronjob that runs VACUUM ANALYZE once an hour +> (vacuumdb -a -q -z). +> +> Have you tried going 'VACUUM FULL ANALYZE' (vacuumdb -a -q -z -f) +> instead of a dump and reload? +> +> Chris +> +> +> + + + +From pgsql-performance-owner@postgresql.org Mon Nov 24 23:16:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CB6FED1DBAC + for ; + Tue, 25 Nov 2003 03:16:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16507-03 + for ; + Mon, 24 Nov 2003 23:16:13 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id CDB3AD1D888 + for ; + Mon, 24 Nov 2003 23:16:07 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAP3G8oD033859; Tue, 25 Nov 2003 11:16:08 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC2CA18.3080001@familyhealth.com.au> +Date: Tue, 25 Nov 2003 11:18:48 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Nid +Cc: pgsql-performance@postgresql.org +Subject: Re: Where to start for performance problem? +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> + <3FC2ACCF.2030303@familyhealth.com.au> + <2b8e01c3b301$0bc2f090$0201a8c0@game> +In-Reply-To: <2b8e01c3b301$0bc2f090$0201a8c0@game> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/236 +X-Sequence-Number: 4796 + +Nid wrote: + +> I've been digging around in the code and found where we are executing the +> VACUUM command. VACUUM ANALYZE is executed every 15 minutes. We haven't +> tried VACUUM FULL ANALYZE. I think I read that using FULL is a good idea +> once a day or something. Just doing a VACUUM ANALYZE doesn't seem to be +> preventing our problem. Thank you for the responses. + +Try upgrading to PostgreSQL 7.4 and use the new pg_autovacuum daemon. +This daemon will monitor your tables and vacuum and analyze whenever +necessary. + +Chris + + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 00:21:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C0D8D1D61F + for ; + Tue, 25 Nov 2003 04:21:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27484-08 + for ; + Tue, 25 Nov 2003 00:21:17 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 585DAD1CAD1 + for ; + Tue, 25 Nov 2003 00:21:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAP4LGNu050445 + for ; Tue, 25 Nov 2003 04:21:16 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAP4CTZT049017 + for pgsql-performance@postgresql.org; Tue, 25 Nov 2003 04:12:29 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: [HACKERS] More detail on settings for pgavd? +Date: Mon, 24 Nov 2003 23:08:08 -0500 +Organization: cbbrowne Computing Inc +Lines: 38 +Message-ID: +References: <200311181558.45847.josh@agliodbs.com> + <1069424054.29672.12462.camel@camel> <3FBE21D5.20508@zeut.net> + <200311210909.00978.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:XUF1rnSlb/8Axa0fuCtewYQLVvk= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, REFERENCES, + USER_AGENT_GNUS_UA +X-Spam-Level: +X-Archive-Number: 200311/237 +X-Sequence-Number: 4797 + +After a long battle with technology, josh@agliodbs.com (Josh Berkus), an earthling, wrote: +>> As long as pg_autovacuum remains a contrib module, I don't think +>> any changes to the system catelogs will be make. If pg_autovacuum +>> is deemed ready to move out of contrib, then we can talk about the +>> above. +> +> But we could create a config file that would store stuff in a +> flatfile table, OR we could add our own "system table" that would be +> created when one "initializes" pg_avd. + +The problem with introducing a "config file" is that you then have to +introduce a language and a parser for that language. + +That introduces rather a lot of complexity. That was the BIG problem +with pgavd (which is a discarded project; pg_autovacuum is NOT the +same thing as pgavd). There was more code involved just in managing +the pgavd parser than there is in all of pg_autovacuum. + +I think the right answer for more sophisticated configuration would +involve specifying a database in which to find the pg_autovacuum +table(s). + +> Just an idea. Mind you, I'm not so sure that we want to focus +> immediately on per-table settings. I think that we want to get the +> "automatic" settings working fairly well first; a lot of new DBAs +> would use the per-table settings to shoot themselves in the foot. +> So we need to be able to make a strong recommendation to "try the +> automatic settings first." + +Yeah, it's probably a good idea to ensure that per-table settings +involves some really conspicuous form of "foot gun" (with no kevlar +socks) to discourage its use except when you _know_ what you're +doing... +-- +let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];; +http://www3.sympatico.ca/cbbrowne/nonrdbms.html +Q: Can SETQ only be used with numerics? +A: No, SETQ may also be used by Symbolics, and use it they do. + +From pgsql-performance-owner@postgresql.org Tue Nov 25 02:07:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A3D4D1DA6F + for ; + Tue, 25 Nov 2003 06:07:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54653-03 + for ; + Tue, 25 Nov 2003 02:06:58 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 14A63D1D695 + for ; + Tue, 25 Nov 2003 02:06:55 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hAP66w7v031691 + for ; Tue, 25 Nov 2003 11:36:58 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hAP66vLp031664; + Tue, 25 Nov 2003 11:36:58 +0530 +Message-ID: <3FC2F17A.5050307@persistent.co.in> +Date: Tue, 25 Nov 2003 11:36:50 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +References: <3FC19C2C.4050704@myrealbox.com> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/238 +X-Sequence-Number: 4798 + +William Yu wrote: + +> This is an intriguing thought which leads me to think about a similar +> solution for even a production server and that's a solid state drive for +> just the WAL. What's the max disk space the WAL would ever take up? +> There's quite a few 512MB/1GB/2GB solid state drives available now in +> the ~$200-$500 range and if you never hit those limits... + +Maximum number of WAL segments at any time in 2*(number of checkpoint +segments)+1 IIRC. + +So if you have 3 checkpoint segments, you can not have more than 7 WAL segments +at any time. Give or take 1. + +Correct me if I am wrong.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 11:52:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9AB24D1DC04 + for ; + Tue, 25 Nov 2003 14:05:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57255-01 + for ; + Tue, 25 Nov 2003 10:05:19 -0400 (AST) +Received: from mail.dsvr.co.uk (mail.dsvr.co.uk [212.69.192.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 53F83D1DC3E + for ; + Tue, 25 Nov 2003 10:05:15 -0400 (AST) +Received: from dsvr.net (eth0.rt1.o1-1.tck.dsvr.net [::ffff:212.69.216.20]) + by mail.dsvr.co.uk with esmtp; Tue, 25 Nov 2003 14:05:17 +0000 +Message-ID: <3FC3623E.3020304@dsvr.net> +Date: Tue, 25 Nov 2003 14:07:58 +0000 +From: Rob Fielding +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030807 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Where to start for performance problem? +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +In-Reply-To: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/239 +X-Sequence-Number: 4799 + +The problems with giving suggestions about increasing performance is +that one persons increase is another persons decrease. + +having said that, there are a few general suggestions : + +Set-up some shared memory, about a tenth of your available RAM, and +configure shared_memory and max_clients correctly. I've used the +following formula, ripped off the net from somewhere. It's not entirely +acurate, as other settings steal a little shared memory, but it works +for the most part : + +((1024*RAM_SIZE) - (14.2 * max_connections) - 250) / 8.2 + +as I say, it should get you a good value, otherwise lower it bit by bit +if you have trouble starting your db. + +Increase effective_cache (50%-70% avail ram) and sort_mem (about 1/20th +ram) and lower you random_page_cost to around 2 or less (as low as 0.3) +if you have fast SCSI drives in a RAID10 set-up - this was a big speedup ;) + +But this might not be the answer though. The values detailed above are +when tuning an already stable setup. + +Perhaps you need to look at your system resource usage. If you're +degrading performance over time it sounds to me like you are slowly +running out of memory and swap ? + +Generall if I take something over, I'll try and get it onto my terms. +Have you tried importing the DB to a fresh installation, one where you +know sensible defaults are set, so you aren't inheriting any cruft from +the previous sysadmin. + +To be honest tho, I've never run pg so that it actually shutdown because +it was running so badly - i just wouldn't think it would do that. + + +-- + +Rob Fielding +rob@dsvr.net + +www.dsvr.co.uk Development Designer Servers Ltd + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 12:04:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E571D1D8A8 + for ; + Tue, 25 Nov 2003 15:48:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83828-07 + for ; + Tue, 25 Nov 2003 11:48:06 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 787DAD1D8DE + for ; + Tue, 25 Nov 2003 11:48:01 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAPFlb19027728; + Tue, 25 Nov 2003 10:47:37 -0500 (EST) +To: Shridhar Daithankar +Cc: William Yu , pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +In-reply-to: <3FC2F17A.5050307@persistent.co.in> +References: <3FC19C2C.4050704@myrealbox.com> + <3FC2F17A.5050307@persistent.co.in> +Comments: In-reply-to Shridhar Daithankar + + message dated "Tue, 25 Nov 2003 11:36:50 +0530" +Date: Tue, 25 Nov 2003 10:47:37 -0500 +Message-ID: <27727.1069775257@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/240 +X-Sequence-Number: 4800 + +Shridhar Daithankar writes: +> William Yu wrote: +>> This is an intriguing thought which leads me to think about a similar +>> solution for even a production server and that's a solid state drive for +>> just the WAL. What's the max disk space the WAL would ever take up? + +> Maximum number of WAL segments at any time in 2*(number of checkpoint +> segments)+1 IIRC. +> So if you have 3 checkpoint segments, you can not have more than 7 WAL +> segments at any time. Give or take 1. + +I don't believe that's a *hard* limit. The system tries to schedule +checkpoints often enough to prevent WAL from getting bigger than that, +but if you had a sufficiently big spike in update activity, it's at +least theoretically possible that more than checkpoint_segments segments +could be filled before the concurrently running checkpoint finishes and +releases some old segments. + +The odds of this being a real problem are small, especially if you don't +try to fit on an undersized SSD by reducing checkpoint_segments. I'd +think that a 512Mb SSD would be plenty of space for ordinary update load +levels ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Nov 25 12:54:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DFA0D1B440 + for ; + Tue, 25 Nov 2003 16:54:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95033-06 + for ; + Tue, 25 Nov 2003 12:53:33 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id CAD60D1B438 + for ; + Tue, 25 Nov 2003 12:53:33 -0400 (AST) +Received: (qmail 25386 invoked by uid 500); 25 Nov 2003 16:52:32 -0000 +Date: Tue, 25 Nov 2003 10:52:32 -0600 +From: Bruno Wolff III +To: MK Spam +Cc: pgsql-performance@postgresql.org +Subject: Re: Where to start for performance problem? +Message-ID: <20031125165232.GA25043@wolff.to> +Mail-Followup-To: MK Spam , + pgsql-performance@postgresql.org +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <2b1f01c3b2d6$c403ba70$0201a8c0@game> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/241 +X-Sequence-Number: 4801 + +On Mon, Nov 24, 2003 at 16:03:17 -0600, + MK Spam wrote: +> +> The archives of this list provides many ideas for improving performance, but the problem we are having is gradually degrading performance ending in postgres shutting down. So it's not a matter of optimizing a complex query to take 5 seconds instead of 60 seconds. From what I can tell we are using the VACUUM command on a schedule but it doesn't seem to prevent the database from becoming "congested" as we refer to it. :] Anyway, the only way I know to "fix" the problem is to export (pg_dump) the db, drop the database, recreate the database and import the dump. This seems to return performance back to normal but obviously isn't a very good "solution". The slowdown and subsequent crash can take as little as 1 week for databases with a lot of data or go as long as a few weeks to a month for smaller data sets. + +A couple of things you might look for are index bloat and having FSM set too +small for your plain vacuums. Upgrading to 7.4 may help with index bloat +if that is your problem. + +From pgsql-performance-owner@postgresql.org Tue Nov 25 13:08:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E737D1B448 + for ; + Tue, 25 Nov 2003 17:08:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98193-07 + for ; + Tue, 25 Nov 2003 13:08:13 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id C764AD1B444 + for ; + Tue, 25 Nov 2003 13:07:50 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAPH7n19028468; + Tue, 25 Nov 2003 12:07:49 -0500 (EST) +To: MK Spam +Cc: pgsql-performance@postgresql.org +Subject: Re: Where to start for performance problem? +In-reply-to: <20031125165232.GA25043@wolff.to> +References: <2b1f01c3b2d6$c403ba70$0201a8c0@game> + <20031125165232.GA25043@wolff.to> +Comments: In-reply-to Bruno Wolff III + message dated "Tue, 25 Nov 2003 10:52:32 -0600" +Date: Tue, 25 Nov 2003 12:07:49 -0500 +Message-ID: <28467.1069780069@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/242 +X-Sequence-Number: 4802 + +MK Spam wrote: +> ... the problem we are having is gradually degrading +> performance ending in postgres shutting down. + +As someone else commented, that's not an ordinary sort of performance +problem. What exactly happens when the database "shuts down"? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Nov 25 14:28:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 831B8D1B451 + for ; + Tue, 25 Nov 2003 18:28:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10627-07 + for ; + Tue, 25 Nov 2003 14:27:51 -0400 (AST) +Received: from smtp-relay-7.sea.adobe.com (smtp-relay-7.adobe.com + [192.150.22.7]) + by svr1.postgresql.org (Postfix) with ESMTP id 404D0D1B450 + for ; + Tue, 25 Nov 2003 14:27:51 -0400 (AST) +Received: from inner-relay-1.corp.adobe.com (inner-relay-1 [153.32.1.51]) + by smtp-relay-7.sea.adobe.com (8.12.10/8.12.10) with ESMTP id + hAPIRY7c003097 for ; + Tue, 25 Nov 2003 10:27:34 -0800 (PST) +Received: from mail-321.corp.adobe.com (mail-321 [153.32.2.46]) + by inner-relay-1.corp.adobe.com (8.12.9/8.12.9) with ESMTP id + hAPIRT6F005192 for ; + Tue, 25 Nov 2003 10:27:29 -0800 (PST) +Received: from adobe.com (c-155-236.corp.adobe.com [153.32.155.236]) + by mail-321.corp.adobe.com (8.11.4/8.11.4) with ESMTP id hAPIRSA08003 + for ; + Tue, 25 Nov 2003 10:27:28 -0800 (PST) +Message-ID: <3FC3A2A7.6060804@adobe.com> +Date: Tue, 25 Nov 2003 10:42:47 -0800 +From: shane hill +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5b) Gecko/20030901 Thunderbird/0.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance +Subject: design question: general db performance +References: <3FC26E96.9090101@be-a-part.de> <3FC267FB.806@bigfoot.com> + <3FC27911.7070403@be-a-part.de> <3FC27071.9000001@bigfoot.com> +In-Reply-To: <3FC27071.9000001@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/243 +X-Sequence-Number: 4803 + +Hi folks, + +Disclaimer: I am relatively new to RDBMSs, so please do not laugh at me +too loudly, you can laugh, just not too loudly and please do not point. :) + +I am working on an Automated Installer Testing System for Adobe Systems +and I am doing a DB redesign of the current postgres db: + +1. We are testing a matrix of over 900 Acrobat installer configurations +and we are tracking every file and registry entry that is affected by an +installation. + +2. a single file or registry entry that is affected by any test is +stored in the db as a record. + +3. a typical record is about 12 columns of string data. the data is all +information about a file (mac or windows) or windows registry entry [ +file or regkey name, file size, modification date, checksum, +permissions, owner, group, and in the case of a mac, we are getting all +the hfs atts as well]. + +4. A typical test produces anywhere from 2000 - 5000 records. + + +Our db is getting to be a respectable size (about 10GB right now) and is +growing slower and slower. I have been charged with making it faster and +with a smaller footprint while retaining all of the current +functionality. here is one of my ideas. Please tell me if I am crazy: + +The strings that we are storing (mentioned in 3 above) are extremely +repetitive. for example, there are a limited number of permissions for +the files in the acrobat installer and we are storing this information +over and over again in the tables. The same goes for filenames, registry +key names and almost all of the data we are storing. So it seems to me +that to create a smaller and faster database we could assign an integer +to each string and just store the integer representation of the string +rather than the string itself. Then we would just store the strings in +a separate table one time and do join queries against the tables that +are holding the strings and the main data tables. for example, + +a table that would hold unique permissions strings would look like + +table: perms_strs + +string | id +--------------------- +'drwxr-xr-x' | 1 +'-rw-------' | 2 +'drwxrwxr-x' | 3 +'-rw-r--r--' | 4 + +then in my data I would just store 1,2,3 or 4 instead of the whole +permissions string. + +it seems to me that we would save lots of space and over time not see +the same performance degradation. + +anyways, please tell me if this makes sense and make any other +suggestions that you can think of. I am just now starting this analysis +so I cannot give specifics as to where we are seeing poor performance +just yet. just tell me if my concepts are correct. + +thanks for your time and for suffering this email. + +chao, + +-Shane + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 14:59:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D1597D1B45E + for ; + Tue, 25 Nov 2003 18:59:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17122-05 + for ; + Tue, 25 Nov 2003 14:58:29 -0400 (AST) +Received: from indygecko.com (h24-71-76-41.ok.shawcable.net [24.71.76.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B8DFD1B447 + for ; + Tue, 25 Nov 2003 14:58:29 -0400 (AST) +Received: from [192.168.10.10] ([::ffff:192.168.10.10]) + by indygecko.com with esmtp; Tue, 25 Nov 2003 10:58:28 -0800 +Subject: Re: design question: general db performance +From: Jord Tanner +To: shane hill +Cc: pgsql-performance +In-Reply-To: <3FC3A2A7.6060804@adobe.com> +References: <3FC26E96.9090101@be-a-part.de> <3FC267FB.806@bigfoot.com> + <3FC27911.7070403@be-a-part.de> <3FC27071.9000001@bigfoot.com> + <3FC3A2A7.6060804@adobe.com> +Organization: +Message-Id: <1069786707.4242.66.camel@gecko> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 25 Nov 2003 10:58:28 -0800 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/244 +X-Sequence-Number: 4804 + +[small chuckle] + +By George, I think he's got it! + +You are on the right track. Have a look at this link on database +normalization for more info: + +http://databases.about.com/library/weekly/aa080501a.htm + + + +On Tue, 2003-11-25 at 10:42, shane hill wrote: +> Hi folks, +> +> Disclaimer: I am relatively new to RDBMSs, so please do not laugh at me +> too loudly, you can laugh, just not too loudly and please do not point. :) +> + +[snip] + +-- +Jord Tanner + + +From pgsql-performance-owner@postgresql.org Fri Nov 28 14:15:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CBDB9D1B46F + for ; + Tue, 25 Nov 2003 19:05:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16929-08 + for ; + Tue, 25 Nov 2003 15:04:33 -0400 (AST) +Received: from node-4024d1a2.mdw.onnet.us.uu.net + (node-40241d3a.mdw.onnet.us.uu.net [64.36.29.58]) + by svr1.postgresql.org (Postfix) with ESMTP id B3A1FD1B45F + for ; + Tue, 25 Nov 2003 15:04:33 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by node-4024d1a2.mdw.onnet.us.uu.net (Postfix) with ESMTP id 2BA7637D0B + for ; + Tue, 25 Nov 2003 12:59:54 -0600 (CST) +Subject: Re: Maximum Possible Insert Performance? +From: Suchandra Thapa +To: pgsql-performance@postgresql.org +In-Reply-To: <87brr11c44.fsf@stark.dyndns.tv> +References: + <200311240925.58070.josh@agliodbs.com> + <200311241004.37969.josh@agliodbs.com> + <87brr11c44.fsf@stark.dyndns.tv> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-by9rSZ6nTuoexoHmUfLz" +Organization: +Message-Id: <1069786793.19104.33.camel@hepcat> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 25 Nov 2003 12:59:54 -0600 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/298 +X-Sequence-Number: 4858 + +--=-by9rSZ6nTuoexoHmUfLz +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, 2003-11-24 at 19:16, Greg Stark wrote: +> William Yu writes: +>=20 +> > > You're right, though, mirroring a solid state drive is pretty pointle= +ss; if +> > > power fails, both mirrors are dead. +> >=20 +> > Actually no. Solid state memory is non-volatile. They retain data even = +without +> > power. +>=20 +> Note that flash ram only has a finite number of write cycles before it fa= +ils. +>=20 +> On the other hand that might not be so bad for WAL which writes sequentia= +lly, +> you can easily calculate how close you are to the maximum. For things like +> heap storage or swap it's awful as you can get hot spots that get written= + to +> thousands of times before the rest of the space is used. + +I could be wrong, but I was under the impression that most of the newer +flash disks tended to spread writes out over the drive so that hotspots +are minimized.=20=20 + +--=20 +Suchandra Thapa + +--=-by9rSZ6nTuoexoHmUfLz +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) + +iD8DBQA/w6ap6nShCjt5AZIRAii6AKCfCeSjosYKgxEJi628ftZwpqO7JACeMGUl +fr3exMlo0k2CFdP57BGevPs= +=S6Ro +-----END PGP SIGNATURE----- + +--=-by9rSZ6nTuoexoHmUfLz-- + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:23:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 40014D1B45F + for ; + Tue, 25 Nov 2003 19:23:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22406-01 + for ; + Tue, 25 Nov 2003 15:23:18 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id DB17BD1B434 + for ; + Tue, 25 Nov 2003 15:23:17 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3977127; Tue, 25 Nov 2003 11:23:50 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: shane hill , + pgsql-performance +Subject: Re: design question: general db performance +Date: Tue, 25 Nov 2003 11:12:47 -0800 +User-Agent: KMail/1.4.3 +References: <3FC26E96.9090101@be-a-part.de> <3FC27071.9000001@bigfoot.com> + <3FC3A2A7.6060804@adobe.com> +In-Reply-To: <3FC3A2A7.6060804@adobe.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311251112.47473.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/245 +X-Sequence-Number: 4805 + +Shane, + +> Disclaimer: I am relatively new to RDBMSs, so please do not laugh at me= +=20 +> too loudly, you can laugh, just not too loudly and please do not point. = +:) + +Hey, we all started somewhere. Nobody was born knowing databases. Except= +=20 +maybe Neil Conway. + +> I am working on an Automated Installer Testing System for Adobe Systems= +=20 +> and I am doing a DB redesign of the current postgres db: + +Cool! We're going to want to talk to you about a case study later, if yo= +u=20 +can get your boss to authorize it .... + +> Our db is getting to be a respectable size (about 10GB right now) and is= +=20 +> growing slower and slower.=20 + +Slower and slower? Hmmm ... what's your VACUUM. ANALYZE & REINDEX schedul= +e?=20=20 +What PG version? What are your postgresql.conf settings? Progressive=20 +performance loss may indicate a problem with one or more of these things ... + +> then in my data I would just store 1,2,3 or 4 instead of the whole=20 +> permissions string. +>=20 +> it seems to me that we would save lots of space and over time not see=20 +> the same performance degradation. + +Yes, this is a good idea. Abstracting other repetitive data is good too.= +=20=20 +Also keep in mind that the permissions themselves can be represented as oct= +al=20 +numbers instead of strings, which takes less space. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 16:21:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 245A3D1B47D + for ; + Tue, 25 Nov 2003 20:20:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24158-09 + for ; + Tue, 25 Nov 2003 16:20:09 -0400 (AST) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B905D1B436 + for ; + Tue, 25 Nov 2003 16:20:08 -0400 (AST) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id hAPKNEA11370; + Tue, 25 Nov 2003 21:23:14 +0100 +Received: from bigfoot.com (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id hAPK8vR32160; + Tue, 25 Nov 2003 21:08:57 +0100 +Message-ID: <3FC3AB3D.4080708@bigfoot.com> +Date: Tue, 25 Nov 2003 20:19:25 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Torsten Schulz +Subject: Re: [Fwd: Re: Optimize] +References: <3FC3AFD9.300@be-a-part.de> +In-Reply-To: <3FC3AFD9.300@be-a-part.de> +X-Enigmail-Version: 0.81.7.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/252 +X-Sequence-Number: 4812 + +Torsten Schulz wrote: +> Hi, +> +>> You can see doing select * from pg_stat_activity the +>> queries that are currently running on your server, and +>> do a explain analize on it to see which one is the +>> bottleneck. If you are running the 7.4 you can see on +>> the log the total ammount for each query. +> +> +> +> with this query I see how much queries running, but the field +> current_query are free, so i can't see which queries are very slow. + +You must perform that query with permission of super_user. + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:24:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75203D1B460 + for ; + Tue, 25 Nov 2003 19:24:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21749-06 + for ; + Tue, 25 Nov 2003 15:23:34 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id E61A7D1B453 + for ; + Tue, 25 Nov 2003 15:23:33 -0400 (AST) +Received: (qmail 89861 invoked from network); 25 Nov 2003 19:23:39 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 25 Nov 2003 19:23:39 -0000 +Date: Tue, 25 Nov 2003 14:23:18 -0500 +From: Jeff +To: shane hill +Cc: pgsql-performance@postgresql.org +Subject: Re: design question: general db performance +Message-Id: <20031125142318.4ff8bdb2.threshar@torgo.978.org> +In-Reply-To: <3FC3A2A7.6060804@adobe.com> +References: <3FC26E96.9090101@be-a-part.de> <3FC267FB.806@bigfoot.com> + <3FC27911.7070403@be-a-part.de> <3FC27071.9000001@bigfoot.com> + <3FC3A2A7.6060804@adobe.com> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/246 +X-Sequence-Number: 4806 + +On Tue, 25 Nov 2003 10:42:47 -0800 +shane hill wrote: + +> Our db is getting to be a respectable size (about 10GB right now) and +> is growing slower and slower. I have been charged with making it +> faster and with a smaller footprint while retaining all of the current +> functionality. here is one of my ideas. Please tell me if I am +> crazy: +> + +What exactly is it getting slower doing? + +Have you run through the usual gamut of things to check - shared +buffers, vacuum analyzig, etc. etc. + +What ver of PG? + +What OS? + +Can you post any schema/queries? + +Normalizing can help. But I don't think it is going to be a magical +bullet that will make the DB instantly fast. It will reduce the size of +it though. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:28:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AEFDD1B47A + for ; + Tue, 25 Nov 2003 19:28:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21190-09 + for ; + Tue, 25 Nov 2003 15:28:00 -0400 (AST) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 6381ED1B434 + for ; + Tue, 25 Nov 2003 15:27:44 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AOiqd-0000Hj-0W; Tue, 25 Nov 2003 19:27:43 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id D42AE17DE4; Tue, 25 Nov 2003 19:27:41 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 190DB179A4; Tue, 25 Nov 2003 19:27:40 +0000 (GMT) +From: Richard Huxton +To: shane hill , + pgsql-performance +Subject: Re: design question: general db performance +Date: Tue, 25 Nov 2003 19:27:39 +0000 +User-Agent: KMail/1.5 +References: <3FC26E96.9090101@be-a-part.de> <3FC27071.9000001@bigfoot.com> + <3FC3A2A7.6060804@adobe.com> +In-Reply-To: <3FC3A2A7.6060804@adobe.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311251927.39671.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/247 +X-Sequence-Number: 4807 + +On Tuesday 25 November 2003 18:42, shane hill wrote: +> +> Our db is getting to be a respectable size (about 10GB right now) and is +> growing slower and slower. I have been charged with making it faster and +> with a smaller footprint while retaining all of the current +> functionality. here is one of my ideas. Please tell me if I am crazy: + +Your idea of using an integer makes sense - that's how it is stored on unix +anyway. + +Are you familiar with VACUUM/VACUUM FULL/REINDEX and when you should use them? +If not, that's a good place to start. Try a VACUUM FULL on frequently updated +tables and see if that reduces your disk size. + +You'll probably want to check the performance notes too: +http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php + + + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:39:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D8B0D1B460 + for ; + Tue, 25 Nov 2003 19:39:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23954-04 + for ; + Tue, 25 Nov 2003 15:39:22 -0400 (AST) +Received: from natsmtp01.rzone.de (natsmtp01.rzone.de [81.169.145.166]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D146D1B439 + for ; + Tue, 25 Nov 2003 15:39:22 -0400 (AST) +Received: from be-a-part.de (pD9E81E1A.dip.t-dialin.net [217.232.30.26]) + by post.webmailer.de (8.12.10/8.12.10) with ESMTP id hAPJd5SV002529 + for ; + Tue, 25 Nov 2003 20:39:06 +0100 (MET) +Message-ID: <3FC3AFD9.300@be-a-part.de> +Date: Tue, 25 Nov 2003 20:39:05 +0100 +From: Torsten Schulz +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: [Fwd: Re: Optimize] +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + USER_AGENT_MOZILLA_UA +X-Spam-Level: +X-Archive-Number: 200311/248 +X-Sequence-Number: 4808 + +Hi, + +> You can see doing select * from pg_stat_activity the +> queries that are currently running on your server, and +> do a explain analize on it to see which one is the +> bottleneck. If you are running the 7.4 you can see on +> the log the total ammount for each query. + + +with this query I see how much queries running, but the field +current_query are free, so i can't see which queries are very slow. + +Greetings +Torsten + + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:47:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17E5FD1B461 + for ; + Tue, 25 Nov 2003 19:47:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25699-01 + for ; + Tue, 25 Nov 2003 15:46:28 -0400 (AST) +Received: from jhuml2.jhmi.edu (jhuml2.jhmi.edu [162.129.234.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 97E0ED1B454 + for ; + Tue, 25 Nov 2003 15:46:27 -0400 (AST) +Received: from jhuml2.jhmi.edu (jhuml2.jhmi.edu [162.129.234.21]) + by jhuml2.jhmi.edu (PMDF V6.2-X17 #30840) + with SMTP id <0HOX005BYAR30W@jhuml2.jhmi.edu> for + pgsql-performance@postgresql.org; Tue, 25 Nov 2003 14:45:44 -0500 (EST) +Received: from jhuml2.jhmi.edu ([162.129.234.21]) + by jhuml2.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003112514454426245 + for + ; Tue, 25 Nov 2003 14:45:44 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml2.jhmi.edu (PMDF V6.2-X17 #30840) + with ESMTP id <0HOX0039TAW7XU@jhuml2.jhmi.edu> for + pgsql-performance@postgresql.org; Tue, 25 Nov 2003 14:45:44 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Tue, + 25 Nov 2003 19:48:49 +0000 (GMT) +Date: Tue, 25 Nov 2003 19:48:49 +0000 (GMT) +From: LIANHE SHAO +Subject: why index scan not working when using 'like'? +To: pgsql-performance@postgresql.org +Message-id: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200311/249 +X-Sequence-Number: 4809 + +Hi all, + +I want to use index on the gene_symbol column in my +query and gene_symbol is indexed. but when I use +lower (gene_symbol) like lower('%mif%'), the index +is not used. While when I change to +lower(gene_symbol) = lower('mif'), the index is used +and index scan works, but this is not what I like. I +want all the gene_symbols containing substring +'mif' are pulled out, and not necessarily exactly match. + +could anybody give me some hints how to deal with +this. If I do not used index, it take too long for +the query. + + +PGA> explain select distinct probeset_id, chip, +gene_symbol, title, sequence_description, pfam from +affy_array_annotation where lower(gene_symbol) like +upper('%mif%'); + QUERY PLAN +----------------------------------------------------------------------------------------- + Unique (cost=29576.44..29591.44 rows=86 width=265) + -> Sort (cost=29576.44..29578.59 rows=857 +width=265) + Sort Key: probeset_id, chip, gene_symbol, +title, sequence_description, pfam + -> Seq Scan on affy_array_annotation +(cost=0.00..29534.70 rows=857 width=265) + Filter: (lower((gene_symbol)::text) +~~ 'MIF%'::text) +(5 rows) + + +PGA=> explain select distinct probeset_id, chip, +gene_symbol, title, sequence_description, pfam from +affy_array_annotation where lower(gene_symbol) = +upper('%mif%'); + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Unique (cost=3433.44..3448.44 rows=86 width=265) + -> Sort (cost=3433.44..3435.58 rows=857 width=265) + Sort Key: probeset_id, chip, gene_symbol, +title, sequence_description, pfam + -> Index Scan using gene_symbol_idx_fun1 +on affy_array_annotation (cost=0.00..3391.70 +rows=857 width=265) + Index Cond: +(lower((gene_symbol)::text) = '%MIF%'::text) +(5 rows) + + + + + +Regards, +William + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 16:02:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1AD2D1B437 + for ; + Tue, 25 Nov 2003 20:02:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27088-01 + for ; + Tue, 25 Nov 2003 16:01:56 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C03E6D1B431 + for ; + Tue, 25 Nov 2003 16:01:55 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3977322; Tue, 25 Nov 2003 12:02:44 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: LIANHE SHAO , pgsql-performance@postgresql.org +Subject: Re: why index scan not working when using 'like'? +Date: Tue, 25 Nov 2003 11:51:40 -0800 +User-Agent: KMail/1.4.3 +References: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> +In-Reply-To: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311251151.40781.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/251 +X-Sequence-Number: 4811 + +Lianhe, + +> I want to use index on the gene_symbol column in my +> query and gene_symbol is indexed. but when I use +> lower (gene_symbol) like lower('%mif%'), the index +> is not used. While when I change to +> lower(gene_symbol) =3D lower('mif'), the index is used +> and index scan works, but this is not what I like. I +> want all the gene_symbols containing substring +> 'mif' are pulled out, and not necessarily exactly match. + +LIKE '%mif%' is what's called an "unanchored text search" and it cannot use= + an=20 +index. The database *has* to scan the full text looking for the substring= +.=20=20 +This is true of all database platforms I know of. + +In regular text fields containing words, your problem is solvable with full= +=20 +text indexing (FTI). Unfortunately, FTI is not designed for arbitrary=20 +non-language strings. It could be adapted, but would require a lot of=20 +hacking. + +So you will need to find a way to restructure you data to avoid needing=20 +unanchored text searches. One way would be to break down the gene_symbol= +=20 +field into its smallest atomic components and store those in an indexed chi= +ld=20 +table. Or if you're searching on the same values all the time, you can=20 +create a partial index. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 15:57:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1822D1B47D + for ; + Tue, 25 Nov 2003 19:57:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26341-02 + for ; + Tue, 25 Nov 2003 15:56:28 -0400 (AST) +Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net + [66.117.144.213]) + by svr1.postgresql.org (Postfix) with ESMTP id 72EF0D1B43C + for ; + Tue, 25 Nov 2003 15:56:28 -0400 (AST) +Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) + by rlx13.zapatec.com (Postfix) with ESMTP id D6D19A941 + for ; + Tue, 25 Nov 2003 11:56:14 -0800 (PST) +Received: (from dror@localhost) + by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id hAPJuDaH040935 + for pgsql-performance@postgresql.org; + Tue, 25 Nov 2003 11:56:13 -0800 (PST) (envelope-from dror) +Date: Tue, 25 Nov 2003 11:56:13 -0800 +From: Dror Matalon +To: pgsql-performance@postgresql.org +Subject: Re: why index scan not working when using 'like'? +Message-ID: <20031125195613.GB30893@rlx11.zapatec.com> +References: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/250 +X-Sequence-Number: 4810 + + +Hi, + +Searches with like or regexes often can't use the index. Think of the index as +a sorted list of your items. It's easy to find an item when you know it +starts with mif so ('mif%' should use the index). But when you use a +'like' that starts with '%' the index is useless and the search needs to +do a sequential scan. + +Regards, + +Dror + +On Tue, Nov 25, 2003 at 07:48:49PM +0000, LIANHE SHAO wrote: +> Hi all, +> +> I want to use index on the gene_symbol column in my +> query and gene_symbol is indexed. but when I use +> lower (gene_symbol) like lower('%mif%'), the index +> is not used. While when I change to +> lower(gene_symbol) = lower('mif'), the index is used +> and index scan works, but this is not what I like. I +> want all the gene_symbols containing substring +> 'mif' are pulled out, and not necessarily exactly match. +> +> could anybody give me some hints how to deal with +> this. If I do not used index, it take too long for +> the query. +> +> +> PGA> explain select distinct probeset_id, chip, +> gene_symbol, title, sequence_description, pfam from +> affy_array_annotation where lower(gene_symbol) like +> upper('%mif%'); +> QUERY PLAN +> ----------------------------------------------------------------------------------------- +> Unique (cost=29576.44..29591.44 rows=86 width=265) +> -> Sort (cost=29576.44..29578.59 rows=857 +> width=265) +> Sort Key: probeset_id, chip, gene_symbol, +> title, sequence_description, pfam +> -> Seq Scan on affy_array_annotation +> (cost=0.00..29534.70 rows=857 width=265) +> Filter: (lower((gene_symbol)::text) +> ~~ 'MIF%'::text) +> (5 rows) +> +> +> PGA=> explain select distinct probeset_id, chip, +> gene_symbol, title, sequence_description, pfam from +> affy_array_annotation where lower(gene_symbol) = +> upper('%mif%'); +> +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------- +> Unique (cost=3433.44..3448.44 rows=86 width=265) +> -> Sort (cost=3433.44..3435.58 rows=857 width=265) +> Sort Key: probeset_id, chip, gene_symbol, +> title, sequence_description, pfam +> -> Index Scan using gene_symbol_idx_fun1 +> on affy_array_annotation (cost=0.00..3391.70 +> rows=857 width=265) +> Index Cond: +> (lower((gene_symbol)::text) = '%MIF%'::text) +> (5 rows) +> +> +> +> +> +> Regards, +> William +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com + +From pgsql-performance-owner@postgresql.org Tue Nov 25 17:29:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F2B8D1B44F + for ; + Tue, 25 Nov 2003 21:29:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37579-09 + for ; + Tue, 25 Nov 2003 17:29:06 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 671F0D1B474 + for ; + Tue, 25 Nov 2003 17:29:05 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAPLT419008755; + Tue, 25 Nov 2003 16:29:04 -0500 (EST) +To: josh@agliodbs.com +Cc: LIANHE SHAO , pgsql-performance@postgresql.org +Subject: Re: why index scan not working when using 'like'? +In-reply-to: <200311251151.40781.josh@agliodbs.com> +References: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> + <200311251151.40781.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 25 Nov 2003 11:51:40 -0800" +Date: Tue, 25 Nov 2003 16:29:04 -0500 +Message-ID: <8754.1069795744@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/253 +X-Sequence-Number: 4813 + +Josh Berkus writes: +> In regular text fields containing words, your problem is solvable with full +> text indexing (FTI). Unfortunately, FTI is not designed for arbitrary +> non-language strings. It could be adapted, but would require a lot of +> hacking. + +I'm not sure why you say that FTI isn't a usable solution. As long as +the gene symbols are separated by whitespace or some other non-letters +(eg, "foo mif bar" not "foomifbar"), I'd think FTI would work. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Nov 25 17:58:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E28AD1B48D + for ; + Tue, 25 Nov 2003 21:58:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42250-10 + for ; + Tue, 25 Nov 2003 17:57:58 -0400 (AST) +Received: from smtp2.mail.be.easynet.net (smtp2.mail.be.easynet.net + [212.100.160.76]) + by svr1.postgresql.org (Postfix) with ESMTP id 84AFAD1B45F + for ; + Tue, 25 Nov 2003 17:57:57 -0400 (AST) +Received: from 213-193-177-64.adsl.easynet.be ([213.193.177.64]) + by smtp2.mail.be.easynet.net with esmtp (Exim 4.22) + id 1AOlBs-0004mZ-9Y + for pgsql-performance@postgresql.org; Tue, 25 Nov 2003 22:57:48 +0100 +From: Stefan Champailler +Reply-To: schampailler@easynet.be +To: pgsql-performance@postgresql.org +Subject: Impossibly slow DELETEs +Date: Tue, 25 Nov 2003 22:56:56 +0100 +User-Agent: KMail/1.5.3 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311252256.56433.schampailler@easynet.be> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/254 +X-Sequence-Number: 4814 + +Dear You all, + +(please tell me if this has already been discussed, I was unable to find any +convincing information) + +I'm developing a small application, tied to a PG 7.4 beta 5 (i didn't +upgrade). The DB i use is roughly 20 tales each of them containing at most 30 +records (I'm still in development). I can provide a whole dump if necessary. +I access the DB throug IODBC (Suse Linux 8.1), through PHP. The machine +everything runs on is 512M of Ram, 2.5GHz speed. So I assume it should be +blazingly fast. + +So here's my trouble : some DELETE statement take up to 1 minute to complete +(but not always, sometimes it's fast, sometimes it's that slow). Here's a +typical one : DELETE FROM response_bool WHERE response_id = '125' +The response_bool table has no foreing key and no index on response_id column. +No foreign key reference the response_bool table. There are 6 rows in the +table (given that size, I assumed that an index was not necessary). + +So 1 minute to complete look like I did something REALLY bad. + +It is my feeling that doing the same query with psql works without problem, +but I can't be sure. The rest of my queries (inserts, updates) just work fine +and pretty fast. + +Can someone help me or point me to a place where I can find help ? I didn't do +any in deep debugging though. + +thx, + +stF + + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 18:06:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A6BED1B474 + for ; + Tue, 25 Nov 2003 22:06:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45480-02 + for ; + Tue, 25 Nov 2003 18:06:10 -0400 (AST) +Received: from natsmtp01.rzone.de (natsmtp01.rzone.de [81.169.145.166]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B3E1D1B45F + for ; + Tue, 25 Nov 2003 18:06:09 -0400 (AST) +Received: from be-a-part.de (pD9E81E1A.dip.t-dialin.net [217.232.30.26]) + by post.webmailer.de (8.12.10/8.12.10) with ESMTP id hAPM6AmC002378 + for ; + Tue, 25 Nov 2003 23:06:10 +0100 (MET) +Message-ID: <3FC3D252.1000204@be-a-part.de> +Date: Tue, 25 Nov 2003 23:06:10 +0100 +From: Torsten Schulz +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: [Fwd: Re: Optimize] +References: <3FC3AFD9.300@be-a-part.de> <3FC3AB3D.4080708@bigfoot.com> +In-Reply-To: <3FC3AB3D.4080708@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/255 +X-Sequence-Number: 4815 + +Gaetano Mendola wrote: + +> Torsten Schulz wrote: +> +>> Hi, +>> +>>> You can see doing select * from pg_stat_activity the +>>> queries that are currently running on your server, and +>>> do a explain analize on it to see which one is the +>>> bottleneck. If you are running the 7.4 you can see on +>>> the log the total ammount for each query. +>> +>> +>> +>> +>> with this query I see how much queries running, but the field +>> current_query are free, so i can't see which queries are very slow. +> +> +> You must perform that query with permission of super_user. +> +I've made it in root-account with psql -U postgres - but i can't see the +query + +Regards +Torsten Schulz + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 18:08:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01A1AD1B460 + for ; + Tue, 25 Nov 2003 22:07:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43550-08 + for ; + Tue, 25 Nov 2003 18:07:20 -0400 (AST) +Received: from natsmtp00.webmailer.de (natsmtp00.rzone.de [81.169.145.165]) + by svr1.postgresql.org (Postfix) with ESMTP id A329ED1B43F + for ; + Tue, 25 Nov 2003 18:07:18 -0400 (AST) +Received: from be-a-part.de (pD9E81E1A.dip.t-dialin.net [217.232.30.26]) + by post.webmailer.de (8.12.10/8.12.10) with ESMTP id hAPM7Jkg012396 + for ; + Tue, 25 Nov 2003 23:07:19 +0100 (MET) +Message-ID: <3FC3D296.9040404@be-a-part.de> +Date: Tue, 25 Nov 2003 23:07:18 +0100 +From: Torsten Schulz +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030827 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Optimize +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/256 +X-Sequence-Number: 4816 + +Chester Kustarz wrote: + +> On Mon, 24 Nov 2003, Torsten Schulz wrote: +> +> +>> shared_buffers = 5000 # 2*max_connections, min 16 +>> +> +> +> that looks pretty small. that would only be 40MBytes (8k/page * +> 5000pages). +> +> http://www.varlena.com/GeneralBits/Tidbits/perf.html +> +> +> +Ok, thats it. I've set it to 51200, now it seems to be very fast. + +Thank you! + + +-------- Original Message -------- +Subject: Re: [PERFORM] Optimize +Date: Tue, 25 Nov 2003 23:04:06 +0100 +From: Torsten Schulz +To: Chester Kustarz +References: + + + +Chester Kustarz wrote: + +>On Mon, 24 Nov 2003, Torsten Schulz wrote: +> +> +>>shared_buffers = 5000 # 2*max_connections, min 16 +>> +>> +> +>that looks pretty small. that would only be 40MBytes (8k/page * 5000pages). +> +>http://www.varlena.com/GeneralBits/Tidbits/perf.html +> +> +> +Ok, thats it. I've set it to 51200, now it seems to be very fast. + +Thank you! + + + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 18:30:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E953D1B456 + for ; + Tue, 25 Nov 2003 22:30:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44835-07 + for ; + Tue, 25 Nov 2003 18:29:51 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F08CD1B487 + for ; + Tue, 25 Nov 2003 18:29:50 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3977968 for pgsql-performance@postgresql.org; + Tue, 25 Nov 2003 14:30:39 -0800 +Content-Type: text/plain; + charset="us-ascii" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Wierd context-switching issue on Xeon +Date: Tue, 25 Nov 2003 14:19:36 -0800 +User-Agent: KMail/1.4.3 +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311251419.36771.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/258 +X-Sequence-Number: 4818 + +Folks, + +We're seeing some odd issues with hyperthreading-capable Xeons, whether or = +not=20 +hyperthreading is enabled. Basically, when a small number of really-heavy= +=20 +duty queries hit the system and push all of the CPUs to more than 70% used= +=20 +(about 1/2 user & 1/2 kernel), the system goes to 100,000+ context switcthe= +s=20 +per second and performance degrades.=20=20 + +I know that there's other Xeon users on this list ... has anyone else seen= +=20 +anything like that? The machines are Dells running Red Hat 7.3. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 18:27:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 03D7AD1B46D + for ; + Tue, 25 Nov 2003 22:27:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43363-09 + for ; + Tue, 25 Nov 2003 18:27:07 -0400 (AST) +Received: from mta1.sucs.soton.ac.uk (mta1.sucs.soton.ac.uk [152.78.128.140]) + by svr1.postgresql.org (Postfix) with ESMTP id 155BCD1B430 + for ; + Tue, 25 Nov 2003 18:27:05 -0400 (AST) +Received: from russell (ip-002.area-012.loc-245.halls.soton.ac.uk + [10.245.12.2]) (authenticated bits=0) + by mta1.sucs.soton.ac.uk (8.12.10/8.12.10) with ESMTP id hAPMQi3A008276; + Tue, 25 Nov 2003 22:26:44 GMT +From: "Russell Garrett" +To: "Torsten Schulz" , +Subject: Re: [Fwd: Re: Optimize] +Date: Tue, 25 Nov 2003 22:27:34 -0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +In-Reply-To: <3FC3D252.1000204@be-a-part.de> +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-ISS-MailScanner: Believed to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/257 +X-Sequence-Number: 4817 + +>>> with this query I see how much queries running, but the field +>>> current_query are free, so i can't see which queries are very slow. +>> +>> +>> You must perform that query with permission of super_user. +>> +> I've made it in root-account with psql -U postgres - but i can't see +> the query + +You must have these lines in your postgresql.conf for the query stats to be +collected: + +stats_start_collector = true +stats_command_string = true + +-------------------------------------------------------------------- +Russ Garrett russ@last.fm + http://last.fm + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 19:48:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A649FD1B441 + for ; + Tue, 25 Nov 2003 23:48:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56083-04 + for ; + Tue, 25 Nov 2003 19:47:57 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF28D1B43B + for ; + Tue, 25 Nov 2003 19:47:55 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 3978264; Tue, 25 Nov 2003 15:48:45 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Wierd context-switching issue on Xeon +Date: Tue, 25 Nov 2003 15:37:42 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: <200311251419.36771.josh@agliodbs.com> + <9470.1069803647@sss.pgh.pa.us> +In-Reply-To: <9470.1069803647@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200311251537.42527.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/261 +X-Sequence-Number: 4821 + +Tom, + +> Strictly a WAG ... but what this sounds like to me is disastrously bad +> behavior of the spinlock code under heavy contention. We thought we'd +> fixed the spinlock code for SMP machines awhile ago, but maybe +> hyperthreading opens some new vistas for misbehavior ... + +Yeah, I thought of that based on the discussion on -Hackers. But we tried= +=20 +turning off hyperthreading, with no change in behavior. + +> If you can't try 7.4, or want to gather more data first, it would be +> good to try to confirm or disprove the theory that the context switches +> are coming from spinlock delays. If they are, they'd be coming from the +> select() calls in s_lock() in s_lock.c. Can you strace or something to +> see what kernel calls the context switches occur on? + +Might be worth it ... will suggest that. Will also try 7.4. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 19:41:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 154F1D1B435 + for ; + Tue, 25 Nov 2003 23:41:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55137-10 + for ; + Tue, 25 Nov 2003 19:40:48 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E055DD1B432 + for ; + Tue, 25 Nov 2003 19:40:46 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAPNel19009471; + Tue, 25 Nov 2003 18:40:47 -0500 (EST) +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Wierd context-switching issue on Xeon +In-reply-to: <200311251419.36771.josh@agliodbs.com> +References: <200311251419.36771.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 25 Nov 2003 14:19:36 -0800" +Date: Tue, 25 Nov 2003 18:40:47 -0500 +Message-ID: <9470.1069803647@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/259 +X-Sequence-Number: 4819 + +Josh Berkus writes: +> We're seeing some odd issues with hyperthreading-capable Xeons, whether or not +> hyperthreading is enabled. Basically, when a small number of really-heavy +> duty queries hit the system and push all of the CPUs to more than 70% used +> (about 1/2 user & 1/2 kernel), the system goes to 100,000+ context switcthes +> per second and performance degrades. + +Strictly a WAG ... but what this sounds like to me is disastrously bad +behavior of the spinlock code under heavy contention. We thought we'd +fixed the spinlock code for SMP machines awhile ago, but maybe +hyperthreading opens some new vistas for misbehavior ... + +> I know that there's other Xeon users on this list ... has anyone else seen +> anything like that? The machines are Dells running Red Hat 7.3. + +What Postgres version? Is it easy for you to try 7.4? If we were +really lucky, the random-backoff algorithm added late in 7.4 development +would cure this. + +If you can't try 7.4, or want to gather more data first, it would be +good to try to confirm or disprove the theory that the context switches +are coming from spinlock delays. If they are, they'd be coming from the +select() calls in s_lock() in s_lock.c. Can you strace or something to +see what kernel calls the context switches occur on? + +Another line of thought is that RH 7.3 is a long ways back, and it +wasn't so very long ago that Linux still had lots of SMP bugs. Maybe +what you really need is a kernel update? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Nov 25 19:46:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38D4AD1B44B + for ; + Tue, 25 Nov 2003 23:45:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55083-08 + for ; + Tue, 25 Nov 2003 19:45:26 -0400 (AST) +Received: from mta11.adelphia.net (mta11.adelphia.net [68.168.78.205]) + by svr1.postgresql.org (Postfix) with ESMTP id B6AC4D1B44A + for ; + Tue, 25 Nov 2003 19:45:06 -0400 (AST) +Received: from potentialtech.com ([68.68.113.33]) by mta11.adelphia.net + (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP + id <20031125234513.JPLA1464.mta11.adelphia.net@potentialtech.com>; + Tue, 25 Nov 2003 18:45:13 -0500 +Message-ID: <3FC3E984.3020508@potentialtech.com> +Date: Tue, 25 Nov 2003 18:45:08 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: schampailler@easynet.be +Cc: pgsql-performance@postgresql.org +Subject: Re: Impossibly slow DELETEs +References: <200311252256.56433.schampailler@easynet.be> +In-Reply-To: <200311252256.56433.schampailler@easynet.be> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/260 +X-Sequence-Number: 4820 + +Stefan Champailler wrote: +> Dear You all, +> +> (please tell me if this has already been discussed, I was unable to find any +> convincing information) +> +> I'm developing a small application, tied to a PG 7.4 beta 5 (i didn't +> upgrade). The DB i use is roughly 20 tales each of them containing at most 30 +> records (I'm still in development). I can provide a whole dump if necessary. +> I access the DB throug IODBC (Suse Linux 8.1), through PHP. The machine +> everything runs on is 512M of Ram, 2.5GHz speed. So I assume it should be +> blazingly fast. +> +> So here's my trouble : some DELETE statement take up to 1 minute to complete +> (but not always, sometimes it's fast, sometimes it's that slow). Here's a +> typical one : DELETE FROM response_bool WHERE response_id = '125' +> The response_bool table has no foreing key and no index on response_id column. +> No foreign key reference the response_bool table. There are 6 rows in the +> table (given that size, I assumed that an index was not necessary). +> +> So 1 minute to complete look like I did something REALLY bad. +> +> It is my feeling that doing the same query with psql works without problem, +> but I can't be sure. + +I think that last sentence is the crux of the problem. If you can establish +for sure that the unreasonable delay is _only_ there when the command is +issued through IODBC, then it's not a Postgresql problem. + +Out of curiosity, why are you using ODBC for PHP anyway? PHP has Postgresql +libraries that work very well. I use them quite often without problems. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 19:56:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AC9A2D1B441 + for ; + Tue, 25 Nov 2003 23:56:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59279-03 + for ; + Tue, 25 Nov 2003 19:55:33 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id E0BDDD1B446 + for ; + Tue, 25 Nov 2003 19:55:31 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id B12AE2092; Tue, 25 Nov 2003 18:55:33 -0500 (EST) +To: schampailler@easynet.be +Cc: pgsql-performance@postgresql.org +Subject: Re: Impossibly slow DELETEs +From: Neil Conway +In-Reply-To: <200311252256.56433.schampailler@easynet.be> (Stefan + Champailler's message of "Tue, 25 Nov 2003 22:56:56 +0100") +References: <200311252256.56433.schampailler@easynet.be> +Date: Tue, 25 Nov 2003 18:55:33 -0500 +Message-ID: <87znekuhoq.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/262 +X-Sequence-Number: 4822 + +Stefan Champailler writes: +> So here's my trouble : some DELETE statement take up to 1 minute to +> complete (but not always, sometimes it's fast, sometimes it's that +> slow). Here's a typical one : DELETE FROM response_bool WHERE +> response_id = '125' The response_bool table has no foreing key and +> no index on response_id column. No foreign key reference the +> response_bool table. + +I'm skeptical that PostgreSQL is causing the performance problem +here -- 1 minute for a DELETE on a single-page table is absurdly +slow. If you enable the log_min_duration_statement configuration +variable, you should be able to get an idea of how long it actually +takes PostgreSQL to execute each query -- do you see some 60 second +queries in the log? + +What is the system load like when the query takes a long time? For +example, `vmstat 1` output around this point in time would be +helpful. + +Does PostgreSQL consume a lot of CPU time or do a lot of disk I/O? + +Can you confirm this problem using psql? + +> There are 6 rows in the table (given that size, I assumed that an +> index was not necessary). + +That's a reasonable assumption. + +-Neil + + +From pgsql-performance-owner@postgresql.org Tue Nov 25 20:37:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E488AD1B49D + for ; + Wed, 26 Nov 2003 00:37:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62520-08 + for ; + Tue, 25 Nov 2003 20:37:24 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DBC64D1B44C + for ; + Tue, 25 Nov 2003 20:37:22 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAQ0bI19009858; + Tue, 25 Nov 2003 19:37:18 -0500 (EST) +To: Neil Conway +Cc: schampailler@easynet.be, pgsql-performance@postgresql.org +Subject: Re: Impossibly slow DELETEs +In-reply-to: <87znekuhoq.fsf@mailbox.samurai.com> +References: <200311252256.56433.schampailler@easynet.be> + <87znekuhoq.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Tue, 25 Nov 2003 18:55:33 -0500" +Date: Tue, 25 Nov 2003 19:37:18 -0500 +Message-ID: <9857.1069807038@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/263 +X-Sequence-Number: 4823 + +Neil Conway writes: +>> There are 6 rows in the table (given that size, I assumed that an +>> index was not necessary). + +> That's a reasonable assumption. + +But if he's updated those rows a few hundred thousand times and never +VACUUMed, he could be having some problems ... + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Wed Nov 26 00:28:24 2003 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D114D1B44E + for ; + Wed, 26 Nov 2003 04:28:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84559-05 + for ; + Wed, 26 Nov 2003 00:27:47 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 55315D1B492 + for ; + Wed, 26 Nov 2003 00:27:47 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AOrHH-0007rD-00 + for ; Tue, 25 Nov 2003 23:27:47 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 045D7CC68; Tue, 25 Nov 2003 23:27:46 -0500 (EST) +Date: Tue, 25 Nov 2003 23:27:46 -0500 +From: Andrew Sullivan +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] More detail on settings for pgavd? +Message-ID: <20031126042746.GB23015@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-hackers@postgresql.org +References: <200311181558.45847.josh@agliodbs.com> + <200311210909.00978.josh@agliodbs.com> <3FBE8289.1040009@zeut.net> + <200311211323.19003.josh@agliodbs.com> + <15608.1069455896@sss.pgh.pa.us> <877k1t2pkq.fsf@stark.dyndns.tv> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <877k1t2pkq.fsf@stark.dyndns.tv> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/1359 +X-Sequence-Number: 47647 + +On Fri, Nov 21, 2003 at 07:51:17PM -0500, Greg Stark wrote: +> The second vacuum waits for the lock to become available. If the +> situation got really bad there could end up being a growing queue +> of vacuums waiting. + +Those of us who have run into this know that "the situation got +really bad" is earlier than one might think. And it can indeed cause +some pretty pathological behaviour. + +A + + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 02:07:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EE43D1B48D + for ; + Wed, 26 Nov 2003 06:07:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92857-09 + for ; + Wed, 26 Nov 2003 02:06:40 -0400 (AST) +Received: from smtp.pspl.co.in (www.pspl.co.in [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id A9920D1B434 + for ; + Wed, 26 Nov 2003 02:06:37 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hAQ66gCZ030653 + for ; Wed, 26 Nov 2003 11:36:42 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hAQ66eLp030627; + Wed, 26 Nov 2003 11:36:40 +0530 +Message-ID: <3FC442EA.7060300@persistent.co.in> +Date: Wed, 26 Nov 2003 11:36:34 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Torsten Schulz +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimize +References: <3FC3D296.9040404@be-a-part.de> +In-Reply-To: <3FC3D296.9040404@be-a-part.de> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/264 +X-Sequence-Number: 4824 + +Torsten Schulz wrote: + +> Chester Kustarz wrote: + +>> On Mon, 24 Nov 2003, Torsten Schulz wrote: +>>> shared_buffers = 5000 # 2*max_connections, min 16 +>> that looks pretty small. that would only be 40MBytes (8k/page * +>> 5000pages). +>> http://www.varlena.com/GeneralBits/Tidbits/perf.html +> Ok, thats it. I've set it to 51200, now it seems to be very fast. + +Whoa..That is too much. You acn get still better performance at something low +like 10,000 or even 5000. + +Bumping up shared buffers stops being useful after a point and later it actually +degrades the performance.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 12:39:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 04EC6D1B45D + for ; + Wed, 26 Nov 2003 16:38:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73348-01 + for ; + Wed, 26 Nov 2003 12:38:30 -0400 (AST) +Received: from pcs-1.paccomsys.com (208.225.nwc.net [207.151.225.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 6100BD1B430 + for ; + Wed, 26 Nov 2003 12:38:23 -0400 (AST) +Received: from paccomsys.com (mail.musicreports.com [64.161.179.34]) + by pcs-1.paccomsys.com (8.12.5/8.12.5) with ESMTP id hAQGEi74011497 + for ; Wed, 26 Nov 2003 08:14:45 -0800 +Message-ID: <3FC4D703.5080909@paccomsys.com> +Date: Wed, 26 Nov 2003 08:38:27 -0800 +From: Roger Ging +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.3) Gecko/20030708 Debian/1.3-4.lindows43 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: expression (functional) index use in joins +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/265 +X-Sequence-Number: 4825 + +I just installed v7.4 and restored a database from v7.3.4. I have an +index based on a function that the planner is using on the old version, +but doing seq scans on left joins in the new version. I have run +analyze on the table post restore. the query returns in less than 1 +second on version 7.3.4 and takes over 10 seconds on version 7.4. Any +help will be appreciated. + +Roger Ging + +Query: + +SELECT L.row_id FROM music.logfile L LEFT JOIN music.program P ON +music.fn_mri_id_no_program(P.mri_id_no) = L.program_id +WHERE L.station = UPPER('kabc')::VARCHAR +AND L.air_date = '04/12/2002'::TIMESTAMP +AND P.cutoff_date IS NULL +ORDER BY L.chron_start,L.chron_end; + +planner results on 7.4: + + Sort (cost=17595.99..17608.23 rows=4894 width=12) + Sort Key: l.chron_start, l.chron_end + -> Merge Left Join (cost=17135.92..17296.07 rows=4894 width=12) + Merge Cond: ("outer"."?column5?" = "inner"."?column3?") + Filter: ("inner".cutoff_date IS NULL) + -> Sort (cost=1681.69..1682.73 rows=414 width=21) + Sort Key: (l.program_id)::text + -> Index Scan using idx_logfile_station_air_date on +logfile l (cost=0.00..1663.70 rows=414 width=21) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2002-04-12 00:00:00'::timestamp without time zone)) + -> Sort (cost=15454.22..15465.06 rows=4335 width=20) + Sort Key: (music.fn_mri_id_no_program(p.mri_id_no))::text + -> Seq Scan on program p (cost=0.00..15192.35 +rows=4335 width=20) + +planner results on 7.3.4: + + Sort (cost=55765.51..55768.33 rows=1127 width=41) + Sort Key: l.chron_start, l.chron_end + -> Nested Loop (cost=0.00..55708.36 rows=1127 width=41) + Filter: ("inner".cutoff_date IS NULL) + -> Index Scan using idx_logfile_station_air_date on logfile l + (cost=0.00..71.34 rows=17 width=21) + Index Cond: ((station = 'KABC'::character varying) AND +(air_date = '2002-04-12 00:00:00'::timestamp without time zone)) + -> Index Scan using idx_program_mri_id_no_program on program +p (cost=0.00..3209.16 rows=870 width=20) + Index Cond: (music.fn_mri_id_no_program(p.mri_id_no) = +"outer".program_id) + +table "Program" details: + + Column | Type | Modifiers +----------------+-----------------------------+----------- + record_id | integer | + title | character varying(40) | + mri_id_no | character varying(8) | + ascap_cat | character varying(1) | + ascap_mult | numeric(5,3) | + ascap_prod | character varying(10) | + npa_ind | character varying(3) | + non_inc_in | character varying(1) | + as_pr_su | character varying(1) | + as_1st_run | character varying(1) | + as_cue_st | character varying(1) | + bmi_cat | character varying(2) | + bmi_mult | numeric(6,2) | + bmi_prod | character varying(7) | + year | integer | + prog_type | character varying(1) | + total_ep | integer | + last_epis | character varying(3) | + syndicator | character varying(6) | + station | character varying(4) | + syn_loc | character varying(1) | + spdb_ver | character varying(4) | + as_filed | character varying(4) | + bmidb_ver | character varying(4) | + cutoff_date | timestamp without time zone | + effective_date | timestamp without time zone | + program_id | character varying(5) | +Indexes: + "idx_program_mri_id_no" btree (mri_id_no) + "idx_program_mri_id_no_program" btree +(music.fn_mri_id_no_program(mri_id_no)) + "idx_program_program_id" btree (program_id) + "program_mri_id_no" btree (mri_id_no) + "program_oid" btree (oid) + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 12:52:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1225D1B430 + for ; + Wed, 26 Nov 2003 16:52:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70459-08 + for ; + Wed, 26 Nov 2003 12:51:36 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EF51BD1B44C + for ; + Wed, 26 Nov 2003 12:51:30 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAQGpZNu086709 + for ; Wed, 26 Nov 2003 16:51:35 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAQGivrO085544 + for pgsql-performance@postgresql.org; Wed, 26 Nov 2003 16:44:57 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Maximum Possible Insert Performance? +Date: Wed, 26 Nov 2003 08:44:59 -0800 +Organization: Hub.Org Networking Services +Lines: 42 +Message-ID: +References: <3FC19C2C.4050704@myrealbox.com> + <200311240925.58070.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <200311240925.58070.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/266 +X-Sequence-Number: 4826 + +Josh Berkus wrote: +> William, +> +> +>>When my current job batch is done, I'll save a copy of the dir and give +>>the WAL on ramdrive a test. And perhaps even buy a Sandisk at the local +>>store and run that through the hooper. +> +> +> We'll be interested in the results. The Sandisk won't be much of a +> performance test; last I checked, their access speed was about 1/2 that of a +> fast SCSI drive. But it could be a feasability test for the more expensive +> RAMdrive approach. + +Some initial numbers. I simulated a CPU increase by underclocking the +processors. Most of the time, performance does not scale linearly with +clock speed but since I also underclocked the FSB and memory bandwidth +with the CPU, it's nearly an exact match. + +1.15GHz 6.14 +1.53GHz 6.97 +33% CPU = +13.5% performance + +I then simulated adding a heapload of extra memory by running my job a +second time. Unfortunately, to keep my 25GB DB mostly cached in memory, +the word heapload is too accurate. + +Run 1 6.97 +Run 2 7.99 +14% + +I popped in an extra IDE hard drive to store the WAL files and that +boosted the numbers by a little. From looking at iostat, the ratio +looked like 300K/s WAL for 1MB/s data. + +WAL+Data on same disk 6.97 +WAL+Data separated 7.26 +4% + +I then tried to put the WAL directory onto a ramdisk. I turned off +swapping, created a tmpfs mount point and copied the pg_xlog directory +over. Everything looked fine as far as I could tell but Postgres just +panic'd with a "file permissions" error. Anybody have thoughts to why +tmpfs would not work? + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 13:12:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 214F5D1B45C + for ; + Wed, 26 Nov 2003 17:12:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77504-01 + for ; + Wed, 26 Nov 2003 13:11:35 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E8A3D1B44D + for ; + Wed, 26 Nov 2003 13:11:29 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 8D50636C4E; Wed, 26 Nov 2003 12:11:34 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1AP3CQ-0000E4-00; Wed, 26 Nov 2003 12:11:34 -0500 +To: Neil Conway +Cc: schampailler@easynet.be, pgsql-performance@postgresql.org +Subject: Re: Impossibly slow DELETEs +References: <200311252256.56433.schampailler@easynet.be> + <87znekuhoq.fsf@mailbox.samurai.com> +In-Reply-To: <87znekuhoq.fsf@mailbox.samurai.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Nov 2003 12:11:34 -0500 +Message-ID: <87vfp7vyux.fsf@stark.dyndns.tv> +Lines: 6 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/267 +X-Sequence-Number: 4827 + + +Is it possible another connection has updated the record and not committed, +and it takes a minute for the connection to time out and commit or roll back? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 13:33:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ED9C6D1B433 + for ; + Wed, 26 Nov 2003 17:33:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78416-08 + for ; + Wed, 26 Nov 2003 13:33:25 -0400 (AST) +Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EE77D1B43A + for ; + Wed, 26 Nov 2003 13:33:18 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAQHXEhr003791; + Wed, 26 Nov 2003 19:33:15 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAQHX8rm003789; + Wed, 26 Nov 2003 19:33:08 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: why index scan not working when using 'like'? +From: Hannu Krosing +To: Tom Lane +Cc: josh@agliodbs.com, LIANHE SHAO , + pgsql-performance@postgresql.org +In-Reply-To: <8754.1069795744@sss.pgh.pa.us> +References: <3d83693d9fe0.3d9fe03d8369@jhmimail.jhmi.edu> + <200311251151.40781.josh@agliodbs.com> <8754.1069795744@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1069867988.2749.26.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 26 Nov 2003 19:33:08 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/268 +X-Sequence-Number: 4828 + +Tom Lane kirjutas T, 25.11.2003 kell 23:29: +> Josh Berkus writes: +> > In regular text fields containing words, your problem is solvable with full +> > text indexing (FTI). Unfortunately, FTI is not designed for arbitrary +> > non-language strings. It could be adapted, but would require a lot of +> > hacking. +> +> I'm not sure why you say that FTI isn't a usable solution. As long as +> the gene symbols are separated by whitespace or some other non-letters +> (eg, "foo mif bar" not "foomifbar"), I'd think FTI would work. + +If he wants to search on arbitrary substring, he could change tokeniser +in FTI to produce trigrams, so that "foomifbar" would be indexed as if +it were text "foo oom omi mif ifb fba bar" and search for things like +%mifb% should first do a FTI search for "mif" AND "ifb" and then simple +LIKE %mifb% to weed out something like "mififb". + +There are ways to use trigrams for 1 and 2 letter matches as well. + +------------- +Hannu + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 14:00:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1932BD1B42F + for ; + Wed, 26 Nov 2003 18:00:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84719-04 + for ; + Wed, 26 Nov 2003 14:00:05 -0400 (AST) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 48422D1B433 + for ; + Wed, 26 Nov 2003 13:59:59 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AP3xL-000407-0Y; Wed, 26 Nov 2003 18:00:04 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id AC2D116291; Wed, 26 Nov 2003 17:52:32 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 56AE515D31; Wed, 26 Nov 2003 17:52:31 +0000 (GMT) +From: Richard Huxton +To: Roger Ging , + pgsql-performance@postgresql.org +Subject: Re: expression (functional) index use in joins +Date: Wed, 26 Nov 2003 17:52:30 +0000 +User-Agent: KMail/1.5 +References: <3FC4D703.5080909@paccomsys.com> +In-Reply-To: <3FC4D703.5080909@paccomsys.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311261752.30729.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/270 +X-Sequence-Number: 4830 + +On Wednesday 26 November 2003 16:38, Roger Ging wrote: +> I just installed v7.4 and restored a database from v7.3.4. +[snip] + +Hmm - you seem to be getting different row estimates in the plan. Can you +re-analyse both versions and post EXPLAIN ANALYSE rather than just EXPLAIN? + +> -> Seq Scan on program p (cost=0.00..15192.35 +> rows=4335 width=20) +> +> planner results on 7.3.4: +> +> -> Index Scan using idx_program_mri_id_no_program on program +> p (cost=0.00..3209.16 rows=870 width=20) + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Nov 26 13:56:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EE272D1B431 + for ; + Wed, 26 Nov 2003 17:56:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85112-01 + for ; + Wed, 26 Nov 2003 13:55:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D975ED1B489 + for ; + Wed, 26 Nov 2003 13:55:51 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAQHtu19016110; + Wed, 26 Nov 2003 12:55:57 -0500 (EST) +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +In-reply-to: +References: <3FC19C2C.4050704@myrealbox.com> + <200311240925.58070.josh@agliodbs.com> + +Comments: In-reply-to William Yu + message dated "Wed, 26 Nov 2003 08:44:59 -0800" +Date: Wed, 26 Nov 2003 12:55:56 -0500 +Message-ID: <16109.1069869356@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/269 +X-Sequence-Number: 4829 + +William Yu writes: +> I then tried to put the WAL directory onto a ramdisk. I turned off +> swapping, created a tmpfs mount point and copied the pg_xlog directory +> over. Everything looked fine as far as I could tell but Postgres just +> panic'd with a "file permissions" error. Anybody have thoughts to why +> tmpfs would not work? + +I'd say you got the file or directory ownership or permissions wrong. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Nov 26 14:22:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0754ED1B439 + for ; + Wed, 26 Nov 2003 18:22:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86685-05 + for ; + Wed, 26 Nov 2003 14:21:37 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F0A8D1B432 + for ; + Wed, 26 Nov 2003 14:21:31 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hAQILaNw003602 + for ; Wed, 26 Nov 2003 18:21:36 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hAQI3iuq000563 + for pgsql-performance@postgresql.org; Wed, 26 Nov 2003 18:03:45 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Maximum Possible Insert Performance? +Date: Wed, 26 Nov 2003 10:03:47 -0800 +Organization: Hub.Org Networking Services +Lines: 14 +Message-ID: +References: <3FC19C2C.4050704@myrealbox.com> + <200311240925.58070.josh@agliodbs.com> + <16109.1069869356@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <16109.1069869356@sss.pgh.pa.us> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/271 +X-Sequence-Number: 4831 + +Tom Lane wrote: +> William Yu writes: +> +>>I then tried to put the WAL directory onto a ramdisk. I turned off +>>swapping, created a tmpfs mount point and copied the pg_xlog directory +>>over. Everything looked fine as far as I could tell but Postgres just +>>panic'd with a "file permissions" error. Anybody have thoughts to why +>>tmpfs would not work? +> +> +> I'd say you got the file or directory ownership or permissions wrong. + +I did a mv instead of a cp which duplicates ownership & permissions exactly. + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 14:39:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 360F3D1B43F + for ; + Wed, 26 Nov 2003 18:39:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86685-10 + for ; + Wed, 26 Nov 2003 14:39:31 -0400 (AST) +Received: from pcs-1.paccomsys.com (208.225.nwc.net [207.151.225.208]) + by svr1.postgresql.org (Postfix) with ESMTP id C87F5D1B431 + for ; + Wed, 26 Nov 2003 14:39:23 -0400 (AST) +Received: from paccomsys.com (mail.musicreports.com [64.161.179.34]) + by pcs-1.paccomsys.com (8.12.5/8.12.5) with ESMTP id hAQIFm74012678 + for ; Wed, 26 Nov 2003 10:15:49 -0800 +Message-ID: <3FC4F360.2090609@paccomsys.com> +Date: Wed, 26 Nov 2003 10:39:28 -0800 +From: Roger Ging +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.3) Gecko/20030708 Debian/1.3-4.lindows43 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Followup - expression (functional) index use in joins +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/272 +X-Sequence-Number: 4832 + + +version 7.4 results: + +explain analyse SELECT L.row_id FROM music.logfile L LEFT JOIN +music.program P ON +music.fn_mri_id_no_program(P.mri_id_no) = L.program_id +WHERE L.station = UPPER('kabc')::VARCHAR +AND L.air_date = '04/12/2002'::TIMESTAMP +AND P.cutoff_date IS NULL +ORDER BY L.chron_start,L.chron_end; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=17595.99..17608.23 rows=4894 width=12) (actual +time=8083.719..8083.738 rows=30 loops=1) + Sort Key: l.chron_start, l.chron_end + -> Merge Left Join (cost=17135.92..17296.07 rows=4894 width=12) +(actual time=7727.590..8083.349 rows=30 loops=1) + Merge Cond: ("outer"."?column5?" = "inner"."?column3?") + Filter: ("inner".cutoff_date IS NULL) + -> Sort (cost=1681.69..1682.73 rows=414 width=21) (actual +time=1.414..1.437 rows=30 loops=1) + Sort Key: (l.program_id)::text + -> Index Scan using idx_logfile_station_air_date on +logfile l (cost=0.00..1663.70 rows=414 width=21) (actual +time=0.509..1.228 rows=30 loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2002-04-12 00:00:00'::timestamp without time zone)) + -> Sort (cost=15454.22..15465.06 rows=4335 width=20) (actual +time=7718.612..7869.874 rows=152779 loops=1) + Sort Key: (music.fn_mri_id_no_program(p.mri_id_no))::text + -> Seq Scan on program p (cost=0.00..15192.35 +rows=4335 width=20) (actual time=109.045..1955.882 rows=173998 loops=1) + Total runtime: 8194.290 ms +(13 rows) + + +version 7.3 results: + +explain analyse SELECT L.row_id FROM music.logfile L LEFT JOIN +music.program P ON +music.fn_mri_id_no_program(P.mri_id_no) = L.program_id +WHERE L.station = UPPER('kabc')::VARCHAR +AND L.air_date = '04/12/2002'::TIMESTAMP +AND P.cutoff_date IS NULL +ORDER BY L.chron_start,L.chron_end; + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=55765.51..55768.33 rows=1127 width=41) (actual +time=7.74..7.75 rows=30 loops=1) + Sort Key: l.chron_start, l.chron_end + -> Nested Loop (cost=0.00..55708.36 rows=1127 width=41) (actual +time=0.21..7.62 rows=30 loops=1) + Filter: ("inner".cutoff_date IS NULL) + -> Index Scan using idx_logfile_station_air_date on logfile l + (cost=0.00..71.34 rows=17 width=21) (actual time=0.14..0.74 rows=30 +loops=1) + Index Cond: ((station = 'KABC'::character varying) AND +(air_date = '2002-04-12 00:00:00'::timestamp without time zone)) + -> Index Scan using idx_program_mri_id_no_program on program +p (cost=0.00..3209.16 rows=870 width=20) (actual time=0.05..0.22 rows=9 +loops=30) + Index Cond: (music.fn_mri_id_no_program(p.mri_id_no) = +"outer".program_id) + Total runtime: 7.86 msec + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 14:54:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F540D1B430 + for ; + Wed, 26 Nov 2003 18:54:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89528-08 + for ; + Wed, 26 Nov 2003 14:54:28 -0400 (AST) +Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net + [66.117.144.213]) + by svr1.postgresql.org (Postfix) with ESMTP id 58FACD1B437 + for ; + Wed, 26 Nov 2003 14:54:21 -0400 (AST) +Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) + by rlx13.zapatec.com (Postfix) with ESMTP id AF44CA941 + for ; + Wed, 26 Nov 2003 10:54:22 -0800 (PST) +Received: (from dror@localhost) + by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id hAQIsL6p043232 + for pgsql-performance@postgresql.org; + Wed, 26 Nov 2003 10:54:21 -0800 (PST) (envelope-from dror) +Date: Wed, 26 Nov 2003 10:54:21 -0800 +From: Dror Matalon +To: pgsql-performance@postgresql.org +Subject: Re: Maximum Possible Insert Performance? +Message-ID: <20031126185421.GN30893@rlx11.zapatec.com> +References: <3FC19C2C.4050704@myrealbox.com> + <200311240925.58070.josh@agliodbs.com> + <16109.1069869356@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/273 +X-Sequence-Number: 4833 + + +But the permissions of the base ramdisk might be wrong. I'd su to the +user that you run postgres as (probably postgres), and make sure that +you can go to the directory where the log and the database files are and +make sure you can see the files. + +On Wed, Nov 26, 2003 at 10:03:47AM -0800, William Yu wrote: +> Tom Lane wrote: +> >William Yu writes: +> > +> >>I then tried to put the WAL directory onto a ramdisk. I turned off +> >>swapping, created a tmpfs mount point and copied the pg_xlog directory +> >>over. Everything looked fine as far as I could tell but Postgres just +> >>panic'd with a "file permissions" error. Anybody have thoughts to why +> >>tmpfs would not work? +> > +> > +> >I'd say you got the file or directory ownership or permissions wrong. +> +> I did a mv instead of a cp which duplicates ownership & permissions exactly. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com + +From pgsql-performance-owner@postgresql.org Wed Nov 26 15:18:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 46D2FD1B445 + for ; + Wed, 26 Nov 2003 19:13:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93073-07 + for ; + Wed, 26 Nov 2003 15:13:01 -0400 (AST) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id B3BA9D1B48F + for ; + Wed, 26 Nov 2003 15:11:59 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AP553-000GEZ-0X; Wed, 26 Nov 2003 19:12:05 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 7E10B16570; Wed, 26 Nov 2003 19:12:04 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id A2D3D15D31; Wed, 26 Nov 2003 19:12:02 +0000 (GMT) +From: Richard Huxton +To: Roger Ging , + pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +Date: Wed, 26 Nov 2003 19:12:01 +0000 +User-Agent: KMail/1.5 +References: <3FC4F360.2090609@paccomsys.com> +In-Reply-To: <3FC4F360.2090609@paccomsys.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311261912.01286.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/274 +X-Sequence-Number: 4834 + +On Wednesday 26 November 2003 18:39, Roger Ging wrote: +> version 7.4 results: +> +> explain analyse SELECT L.row_id FROM music.logfile L LEFT JOIN +> music.program P ON +> music.fn_mri_id_no_program(P.mri_id_no) = L.program_id +> WHERE L.station = UPPER('kabc')::VARCHAR +> AND L.air_date = '04/12/2002'::TIMESTAMP +> AND P.cutoff_date IS NULL +> ORDER BY L.chron_start,L.chron_end; + +> -> Seq Scan on program p (cost=0.00..15192.35 +> rows=4335 width=20) (actual time=109.045..1955.882 rows=173998 loops=1) + +The estimated number of rows here (4335) is *way* off (173998 actually). If +you only had 4335 rows, then this might be a more sensible plan. + +First step is to run: + VACUUM ANALYSE program; +Then, check the definition of your function fn_mri_id_no_program() and make +sure it is marked immutable/stable (depending on what it does) and that it's +returning a varchar. + + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Nov 26 16:03:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 800BBD1B439 + for ; + Wed, 26 Nov 2003 20:03:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03910-07 + for ; + Wed, 26 Nov 2003 16:03:09 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FAF7D1B446 + for ; + Wed, 26 Nov 2003 16:03:02 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with SMTP id <0HOZ00IUP69ZN1@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 15:02:53 -0500 (EST) +Received: from jhuml1.jhmi.edu ([162.129.234.20]) + by jhuml1.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003112615025324392 + for + ; Wed, 26 Nov 2003 15:02:53 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with ESMTP id <0HOZ00IQ26CSN1@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 15:02:52 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Wed, + 26 Nov 2003 20:06:02 +0000 (GMT) +Date: Wed, 26 Nov 2003 20:06:02 +0000 (GMT) +From: LIANHE SHAO +Subject: For full text indexing, which is better, tsearch2 or fulltextindex +To: pgsql-performance@postgresql.org +Message-id: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/275 +X-Sequence-Number: 4835 + +Hi all, +Which one is better (performance/easier to use), +tsearch2 or fulltextindex? +there is an example how to use fulltextindex in the +techdocs, but I checked the contrib/fulltextindex +package, there is a WARNING that fulltextindex is +much slower than tsearch2. but tsearch2 seems +complex to use, and I can not find a good example. +Which one I should use? Any suggestions? + +thanks and Regards, +William + +----- Original Message ----- +From: Hannu Krosing +Date: Wednesday, November 26, 2003 5:33 pm +Subject: Re: [PERFORM] why index scan not working +when using 'like'? + +> Tom Lane kirjutas T, 25.11.2003 kell 23:29: +> > Josh Berkus writes: +> > > In regular text fields containing words, your +problem is +> solvable with full +> > > text indexing (FTI). Unfortunately, FTI is +not designed for +> arbitrary +> > > non-language strings. It could be adapted, +but would require a +> lot of +> > > hacking. +> > +> > I'm not sure why you say that FTI isn't a usable +solution. As +> long as +> > the gene symbols are separated by whitespace or +some other non- +> letters> (eg, "foo mif bar" not "foomifbar"), I'd +think FTI would +> work. +> If he wants to search on arbitrary substring, he +could change +> tokeniserin FTI to produce trigrams, so that +"foomifbar" would be +> indexed as if +> it were text "foo oom omi mif ifb fba bar" and +search for things like +> %mifb% should first do a FTI search for "mif" AND +"ifb" and then +> simpleLIKE %mifb% to weed out something like "mififb". +> +> There are ways to use trigrams for 1 and 2 letter +matches as well. +> +> ------------- +> Hannu +> +> +> ---------------------------(end of +broadcast)----------------------- +> ---- +> TIP 3: if posting/reading through Usenet, please +send an appropriate +> subscribe-nomail command to +majordomo@postgresql.org so that +> your message can get through to the mailing +list cleanly +> + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 16:14:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 611CAD1B445 + for ; + Wed, 26 Nov 2003 20:14:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71751-05 + for ; + Wed, 26 Nov 2003 16:14:28 -0400 (AST) +Received: from penguin.goodinassociates.com (unknown [63.150.225.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 76276D1B434 + for ; + Wed, 26 Nov 2003 16:14:20 -0400 (AST) +Received: from [192.168.14.183] (bluejay.goodinassociates.com + [192.168.14.183]) + by penguin.goodinassociates.com (8.12.8/linuxconf) with ESMTP id + hAQKEBna013924 + for ; Wed, 26 Nov 2003 14:14:11 -0600 +Subject: cross table indexes or something? +From: Jeremiah Jahn +To: postgres performance +Content-Type: text/plain +Message-Id: <1069877651.22346.13.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Wed, 26 Nov 2003 14:14:11 -0600 +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/276 +X-Sequence-Number: 4836 + +I was wondering if there is something I can do that would act similar to +a index over more than one table. + +I have about 3 million people in my DB at the moment, they all have +roles, and many of them have more than one name. + +for example, a Judge will only have one name, but a Litigant could have +multiple aliases. Things go far to slow when I do a query on a judge +named smith. Does any one know a possible way to speed this up? + +I would think that In a perfect world there would be a way to create an +index on commonly used joins, or something of that nature. I've tried +partial indexes, but the optimizer feels that it would be quicker to do +an index scan for smith% then join using the pkey of the person to get +their role. For litigants, this makes since, for non-litigants, this +doesn't. + +thanx for any insight, +-jj- + +the basic schema + +actor + actor_id PK + role_class_code + +identity + actor_id FK + identity_id PK + full_name + +event + event_date_time + event_id PK + +event_actor + event_id FK + actor_id FK + + +explain select distinct actor.actor_id,court.id,court.name,role_class_code,full_name from actor,identity,court,event,event_actor where role_class_code = 'Judge' and full_name like 'SMITH%' and identity.actor_id = actor.actor_id and identity.court_ori = actor.court_ori and actor.court_ori = court.id and actor.actor_id = event_actor.actor_id and event_actor.event_id = event.event_id and event_date_time > '20021126' order by full_name; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Unique (cost=726.57..726.58 rows=1 width=92) + -> Sort (cost=726.57..726.57 rows=1 width=92) + Sort Key: identity.full_name, actor.actor_id, court.id, court.name, actor.role_class_code + -> Nested Loop (cost=3.02..726.56 rows=1 width=92) + -> Nested Loop (cost=3.02..720.72 rows=1 width=144) + -> Nested Loop (cost=3.02..9.62 rows=1 width=117) + Join Filter: (("outer".court_ori)::text = ("inner".court_ori)::text) + -> Hash Join (cost=3.02..4.18 rows=1 width=93) + Hash Cond: (("outer".id)::text = ("inner".court_ori)::text) + -> Seq Scan on court (cost=0.00..1.10 rows=10 width=34) + -> Hash (cost=3.01..3.01 rows=1 width=59) + -> Index Scan using name_speed on identity (cost=0.00..3.01 rows=1 width=59) + Index Cond: (((full_name)::text >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character varying)) + Filter: ((full_name)::text ~~ 'SMITH%'::text) + -> Index Scan using actor_speed on actor (cost=0.00..5.43 rows=1 width=50) + Index Cond: (("outer".actor_id)::text = (actor.actor_id)::text) + Filter: ((role_class_code)::text = 'Judge'::text) + -> Index Scan using event_actor_speed on event_actor (cost=0.00..695.15 rows=1275 width=73) + Index Cond: ((event_actor.actor_id)::text = ("outer".actor_id)::text) + -> Index Scan using event_pkey on event (cost=0.00..5.83 rows=1 width=52) + Index Cond: (("outer".event_id)::text = (event.event_id)::text) + Filter: (event_date_time > '20021126'::bpchar) + + +-- +"You can't make a program without broken egos." +-- +Jeremiah Jahn + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 16:19:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5F2ED1B439 + for ; + Wed, 26 Nov 2003 20:19:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72256-04 + for ; + Wed, 26 Nov 2003 16:18:53 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 11879D1B43E + for ; + Wed, 26 Nov 2003 16:18:46 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with SMTP id <0HOZ003VR6ZNE1@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 15:18:52 -0500 (EST) +Received: from jhuml1.jhmi.edu ([162.129.234.20]) + by jhuml1.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003112615185228023 + for + ; Wed, 26 Nov 2003 15:18:52 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with ESMTP id <0HOZ008FJ73GMX@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 15:18:52 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Wed, + 26 Nov 2003 20:22:01 +0000 (GMT) +Date: Wed, 26 Nov 2003 20:22:01 +0000 (GMT) +From: LIANHE SHAO +Subject: very large db performance question +To: pgsql-performance@postgresql.org +Message-id: <4cbacd4cb3c2.4cb3c24cbacd@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/277 +X-Sequence-Number: 4837 + +Hello All, +We will have a very large database to store +microarray data (may exceed 80-100G some day). now +we have 1G RAM, 2G Hz Pentium 4, 1 CPU. and enough +hard disk. + +I never touched such large database before. I ask +several dbas if the hardware is ok, some said it is +ok for the query, but I am not so convinced. Because +I check the mailing list and learned that it is not +unreasonable to take several minutes to do the +query. But I want to query to be as fast as possible. + +Could anybody tell me that our hardware is an issue +or not? do we really need better hardware to make +real difference? + +Regards, +William + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 17:29:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 388D0D1B43F + for ; + Wed, 26 Nov 2003 21:29:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78896-07 + for ; + Wed, 26 Nov 2003 17:29:19 -0400 (AST) +Received: from pcs-1.paccomsys.com (208.225.nwc.net [207.151.225.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D2D8D1B482 + for ; + Wed, 26 Nov 2003 17:29:11 -0400 (AST) +Received: from paccomsys.com (mail.musicreports.com [64.161.179.34]) + by pcs-1.paccomsys.com (8.12.5/8.12.5) with ESMTP id hAQL5f74014340 + for ; Wed, 26 Nov 2003 13:05:42 -0800 +Message-ID: <3FC51B2C.2030700@paccomsys.com> +Date: Wed, 26 Nov 2003 13:29:16 -0800 +From: Roger Ging +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.3) Gecko/20030708 Debian/1.3-4.lindows43 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +References: <3FC4F360.2090609@paccomsys.com> + <200311261912.01286.dev@archonet.com> +In-Reply-To: <200311261912.01286.dev@archonet.com> +Content-Type: multipart/alternative; + boundary="------------060905040807020201000309" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/278 +X-Sequence-Number: 4838 + +This is a multi-part message in MIME format. +--------------060905040807020201000309 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Ran vacuum analyse on both program and logfile tables. Estimates are +more in line with reality now, but query still takes 10 seconds on v7.4 +and 10 ms on v7.3. Function is marked as immutable and returns +varchar(5). I am wondering why the planner would choose a merge join +(v7.4) as opposed to a nested loop (v7.3) given the small number of rows +in the top level table (logfile) based upon the where clause ( + +L.air_date = '04/12/2002'::TIMESTAMP + +) +there are typically only 30 rows per station/air_date. What am I +missing here? + +Richard Huxton wrote: + +>On Wednesday 26 November 2003 18:39, Roger Ging wrote: +> +> +>>version 7.4 results: +>> +>>explain analyse SELECT L.row_id FROM music.logfile L LEFT JOIN +>>music.program P ON +>>music.fn_mri_id_no_program(P.mri_id_no) = L.program_id +>>WHERE L.station = UPPER('kabc')::VARCHAR +>>AND L.air_date = '04/12/2002'::TIMESTAMP +>>AND P.cutoff_date IS NULL +>>ORDER BY L.chron_start,L.chron_end; +>> +>> +> +> +> +>> -> Seq Scan on program p (cost=0.00..15192.35 +>>rows=4335 width=20) (actual time=109.045..1955.882 rows=173998 loops=1) +>> +>> +> +>The estimated number of rows here (4335) is *way* off (173998 actually). If +>you only had 4335 rows, then this might be a more sensible plan. +> +>First step is to run: +> VACUUM ANALYSE program; +>Then, check the definition of your function fn_mri_id_no_program() and make +>sure it is marked immutable/stable (depending on what it does) and that it's +>returning a varchar. +> +> +> +> + +--------------060905040807020201000309 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Ran vacuum analyse on both program and logfile tables.  Estimates are +more in line with reality now, but query still takes 10 seconds on v7.4 +and 10 ms on v7.3.  Function is marked as immutable and returns +varchar(5).  I am wondering why the planner would choose a merge join +(v7.4) as opposed to a nested loop (v7.3) given the small number of +rows in the top level table (logfile) based upon the where clause ( +
L.air_date = '04/12/2002'::TIMESTAMP
+)
+there are typically only 30 rows per station/air_date.  What am I +missing here?
+
+Richard Huxton wrote:
+
+
On Wednesday 26 November 2003 18:39, Roger Ging wrote:
+  
+
+
version 7.4 results:
+
+explain analyse SELECT L.row_id FROM music.logfile L LEFT JOIN
+music.program P ON
+music.fn_mri_id_no_program(P.mri_id_no) = L.program_id
+WHERE  L.station = UPPER('kabc')::VARCHAR
+AND L.air_date = '04/12/2002'::TIMESTAMP
+AND P.cutoff_date IS NULL
+ORDER BY L.chron_start,L.chron_end;
+    
+
+

+  
+
+
                ->  Seq Scan on program p  (cost=0.00..15192.35
+rows=4335 width=20) (actual time=109.045..1955.882 rows=173998 loops=1)
+    
+
+

+The estimated number of rows here (4335) is *way* off (173998 actually). If 
+you only had 4335 rows, then this might be a more sensible plan.
+
+First step is to run:
+  VACUUM ANALYSE program;
+Then, check the definition of your function fn_mri_id_no_program() and make 
+sure it is marked immutable/stable (depending on what it does) and that it's 
+returning a varchar.
+
+
+  
+
+ + + +--------------060905040807020201000309-- + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 18:04:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A266D1B43C + for ; + Wed, 26 Nov 2003 22:03:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86105-02 + for ; + Wed, 26 Nov 2003 18:03:32 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 749B2D1B48A + for ; + Wed, 26 Nov 2003 18:03:24 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 19EDF1F40; Wed, 26 Nov 2003 17:03:31 -0500 (EST) +To: LIANHE SHAO +Cc: pgsql-performance@postgresql.org +Subject: Re: very large db performance question +From: Neil Conway +In-Reply-To: <4cbacd4cb3c2.4cb3c24cbacd@jhmimail.jhmi.edu> (LIANHE SHAO's + message of "Wed, 26 Nov 2003 20:22:01 +0000 (GMT)") +References: <4cbacd4cb3c2.4cb3c24cbacd@jhmimail.jhmi.edu> +Date: Wed, 26 Nov 2003 17:03:31 -0500 +Message-ID: <87u14q6b4c.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/279 +X-Sequence-Number: 4839 + +LIANHE SHAO writes: +> We will have a very large database to store microarray data (may +> exceed 80-100G some day). now we have 1G RAM, 2G Hz Pentium 4, 1 +> CPU. and enough hard disk. + +> Could anybody tell me that our hardware is an issue or not? + +IMHO the size of the DB is less relevant than the query workload. For +example, if you're storying 100GB of data but only doing a single +index scan on it every 10 seconds, any modern machine with enough HD +space should be fine. + +If you give us an idea of the # of queries you expect per second, the +approximate mix of reads and writes, and some idea of how complex the +queries are, we might be able to give you some better advice. + +-Neil + + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 18:24:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CFECD1B430 + for ; + Wed, 26 Nov 2003 22:24:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85810-08 + for ; + Wed, 26 Nov 2003 18:23:50 -0400 (AST) +Received: from appsrv1.nuvergence.com (appsrv1.mgamble.ca [64.56.239.120]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F71CD1B43F + for ; + Wed, 26 Nov 2003 18:23:38 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by appsrv1.nuvergence.com (Postfix) with ESMTP id 4E54330AE20 + for ; + Wed, 26 Nov 2003 17:23:14 -0500 (EST) +Received: from host-130.in3healthsystems.com ( + [host-130.in3healthsystems.com]) + as user marc@redboxdata.com@appsrv1.simpledomains.net by + webmail.nuvergence.com with HTTP; Wed, 26 Nov 2003 17:23:14 -0500 +Message-ID: <1069885394.3fc527d23560e@webmail.nuvergence.com> +Date: Wed, 26 Nov 2003 17:23:14 -0500 +From: "Marc A. Leith" +To: postgres performance +Subject: Re: cross table indexes or something? +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> +In-Reply-To: <1069877651.22346.13.camel@bluejay.goodinassociates.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/280 +X-Sequence-Number: 4840 + +Sybase IQ lets you build "joined indexsets". This is amazing but pricey +and really intended more for Data Warehousing than OLTP, although they did +release a version which permitted writes on-the-fly. (This was implemented +using a multi-concurrency solution much like PostreSQL uses.) + +It essentially pre-joined the data. + +Marc A. Leith +redboxdata inc. +E-mail:mleith@redboxdata.com + +Quoting Jeremiah Jahn : + +> I was wondering if there is something I can do that would act similar to +> a index over more than one table. +> +> I have about 3 million people in my DB at the moment, they all have +> roles, and many of them have more than one name. +> +> for example, a Judge will only have one name, but a Litigant could have +> multiple aliases. Things go far to slow when I do a query on a judge +> named smith. Does any one know a possible way to speed this up? +> +> I would think that In a perfect world there would be a way to create an +> index on commonly used joins, or something of that nature. I've tried +> partial indexes, but the optimizer feels that it would be quicker to do +> an index scan for smith% then join using the pkey of the person to get +> their role. For litigants, this makes since, for non-litigants, this +> doesn't. +> +> thanx for any insight, +> -jj- +> +> the basic schema +> +> actor +> actor_id PK +> role_class_code +> +> identity +> actor_id FK +> identity_id PK +> full_name +> +> event +> event_date_time +> event_id PK +> +> event_actor +> event_id FK +> actor_id FK +> +> +> explain select distinct +> actor.actor_id,court.id,court.name,role_class_code,full_name from +> actor,identity,court,event,event_actor where role_class_code = 'Judge' and +> full_name like 'SMITH%' and identity.actor_id = actor.actor_id and +> identity.court_ori = actor.court_ori and actor.court_ori = court.id and +> actor.actor_id = event_actor.actor_id and event_actor.event_id = +> event.event_id and event_date_time > '20021126' order by full_name; +> +> QUERY PLAN +> ------------------------------------------------------------------------------ +-------------------------------------------------------------------------------- +---- +> Unique (cost=726.57..726.58 rows=1 width=92) +> -> Sort (cost=726.57..726.57 rows=1 width=92) +> Sort Key: identity.full_name, actor.actor_id, court.id, court.name, +> actor.role_class_code +> -> Nested Loop (cost=3.02..726.56 rows=1 width=92) +> -> Nested Loop (cost=3.02..720.72 rows=1 width=144) +> -> Nested Loop (cost=3.02..9.62 rows=1 width=117) +> Join Filter: (("outer".court_ori)::text = +> ("inner".court_ori)::text) +> -> Hash Join (cost=3.02..4.18 rows=1 width=93) +> Hash Cond: (("outer".id)::text = +> ("inner".court_ori)::text) +> -> Seq Scan on court (cost=0.00..1.10 +> rows=10 width=34) +> -> Hash (cost=3.01..3.01 rows=1 width=59) +> -> Index Scan using name_speed on +> identity (cost=0.00..3.01 rows=1 width=59) +> Index Cond: (((full_name)::text +> >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character +> varying)) +> Filter: ((full_name)::text ~~ +> 'SMITH%'::text) +> -> Index Scan using actor_speed on actor +> (cost=0.00..5.43 rows=1 width=50) +> Index Cond: (("outer".actor_id)::text = +> (actor.actor_id)::text) +> Filter: ((role_class_code)::text = +> 'Judge'::text) +> -> Index Scan using event_actor_speed on event_actor +> (cost=0.00..695.15 rows=1275 width=73) +> Index Cond: ((event_actor.actor_id)::text = +> ("outer".actor_id)::text) +> -> Index Scan using event_pkey on event (cost=0.00..5.83 +> rows=1 width=52) +> Index Cond: (("outer".event_id)::text = +> (event.event_id)::text) +> Filter: (event_date_time > '20021126'::bpchar) +> +> +> -- +> "You can't make a program without broken egos." +> -- +> Jeremiah Jahn +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 18:33:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 78F9AD1B442 + for ; + Wed, 26 Nov 2003 22:33:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88758-05 + for ; + Wed, 26 Nov 2003 18:32:54 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id D6412D1B494 + for ; + Wed, 26 Nov 2003 18:32:45 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hAQMWULX003331; + Thu, 27 Nov 2003 00:32:31 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hAQMWUrl003329; + Thu, 27 Nov 2003 00:32:30 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: cross table indexes or something? +From: Hannu Krosing +To: Jeremiah Jahn +Cc: postgres performance +In-Reply-To: <1069877651.22346.13.camel@bluejay.goodinassociates.com> +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1069885949.3176.57.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 27 Nov 2003 00:32:30 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/281 +X-Sequence-Number: 4841 + +Jeremiah Jahn kirjutas K, 26.11.2003 kell 22:14: +> I was wondering if there is something I can do that would act similar to +> a index over more than one table. +> +> I have about 3 million people in my DB at the moment, they all have +> roles, and many of them have more than one name. +> +> for example, a Judge will only have one name, but a Litigant could have +> multiple aliases. Things go far to slow when I do a query on a judge +> named smith. + +If you dont need all the judges named smith you could try to use LIMIT. + +Have you run ANALYZE ? Why does DB think that there is only one judge +with name like SMITH% ? + +------------- +Hannu + +P.S. +Always send EXPLAIN ANALYZE output if asking for advice on [PERFORM] + +------------- +Hannu + +From pgsql-performance-owner@postgresql.org Wed Nov 26 18:43:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 87083D1B494 + for ; + Wed, 26 Nov 2003 22:43:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91445-01 + for ; + Wed, 26 Nov 2003 18:43:18 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 19E40D1B489 + for ; + Wed, 26 Nov 2003 18:43:10 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with SMTP id <0HOZ006IGDS1HD@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 17:43:16 -0500 (EST) +Received: from jhuml1.jhmi.edu ([162.129.234.20]) + by jhuml1.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003112617431615949 + for + ; Wed, 26 Nov 2003 17:43:16 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) id + <0HOZ00801DS4MO@jhuml1.jhmi.edu> + (original mail from lshao2@jhmi.edu) for + pgsql-performance@postgresql.org; + Wed, 26 Nov 2003 17:43:16 -0500 (EST) +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with ESMTP id <0HOZ0040TDS3GN@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Wed, 26 Nov 2003 17:43:16 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Wed, + 26 Nov 2003 22:46:24 +0000 (GMT) +Date: Wed, 26 Nov 2003 22:46:24 +0000 (GMT) +From: LIANHE SHAO +Subject: Re: very large db performance question +To: Neil Conway +Cc: pgsql-performance@postgresql.org +Message-id: <4e2c4d4e061f.4e061f4e2c4d@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/282 +X-Sequence-Number: 4842 + +Thanks for reply. Actually our database only supply +some scientists to use (we predict that). so there +is no workload problem. there is only very +infrequent updates. the query is not complex. the +problem is, we have one table that store most of the +data ( with 200 million rows). In this table, there +is a text column which we need to do full text +search for each row. The result will then join the +data from another table which has 30,000 rows. Now +the query runs almost forever. + +I tried a small table with 2 million rows using the +following simple command, it takes me about 6 +seconds to get the result back. So, I get confused. +That is why I ask: Is it the hardware problem or +something else. (I just vacuumed the whole database +yesterday). + +PGA=> select count (*) from expressiondata ; + count +--------- + 2197497 +(1 row) + + +PGA=> explain select count (*) from expressiondata ; + QUERY PLAN +------------------------------------------------------------------------------ + Aggregate (cost=46731.71..46731.71 rows=1 width=0) + -> Seq Scan on expressiondata +(cost=0.00..41237.97 rows=2197497 width=0) +(2 rows) + + + +Regards, +William + +----- Original Message ----- +From: Neil Conway +Date: Wednesday, November 26, 2003 10:03 pm +Subject: Re: [PERFORM] very large db performance +question + +> LIANHE SHAO writes: +> > We will have a very large database to store +microarray data (may +> > exceed 80-100G some day). now we have 1G RAM, 2G +Hz Pentium 4, 1 +> > CPU. and enough hard disk. +> +> > Could anybody tell me that our hardware is an +issue or not? +> +> IMHO the size of the DB is less relevant than the +query workload. For +> example, if you're storying 100GB of data but only +doing a single +> index scan on it every 10 seconds, any modern +machine with enough HD +> space should be fine. +> +> If you give us an idea of the # of queries you +expect per second, the +> approximate mix of reads and writes, and some idea +of how complex the +> queries are, we might be able to give you some +better advice. +> +> -Neil +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 20:09:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C8FC7D1B492 + for ; + Thu, 27 Nov 2003 00:09:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97927-04 + for ; + Wed, 26 Nov 2003 20:09:27 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D98CED1B45C + for ; + Wed, 26 Nov 2003 20:09:18 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hAR09P19018734; + Wed, 26 Nov 2003 19:09:25 -0500 (EST) +To: Roger Ging +Cc: pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +In-reply-to: <3FC51B2C.2030700@paccomsys.com> +References: <3FC4F360.2090609@paccomsys.com> + <200311261912.01286.dev@archonet.com> + <3FC51B2C.2030700@paccomsys.com> +Comments: In-reply-to Roger Ging + message dated "Wed, 26 Nov 2003 13:29:16 -0800" +Date: Wed, 26 Nov 2003 19:09:25 -0500 +Message-ID: <18733.1069891765@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/283 +X-Sequence-Number: 4843 + +Roger Ging writes: +> Ran vacuum analyse on both program and logfile tables. Estimates are +> more in line with reality now, + +And they are what now? You really can't expect to get useful help here +when you're being so miserly with the details ... + +FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting +enable_mergejoin to off (might have to also set enable_hashjoin to off, +if it then tries for a hash join). 7.3 could not even consider those +join types in this example, while 7.4 can. The interesting question +from my perspective is why the planner is guessing wrong about the +relative costs of the plans. EXPLAIN ANALYZE results with each type of +join forced would be useful to look at. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Nov 26 20:47:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33278D1B457 + for ; + Thu, 27 Nov 2003 00:47:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01406-06 + for ; + Wed, 26 Nov 2003 20:47:32 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 032C0D1B43F + for ; + Wed, 26 Nov 2003 20:47:22 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAR0l9oD051233; Thu, 27 Nov 2003 08:47:10 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC54A82.2040605@familyhealth.com.au> +Date: Thu, 27 Nov 2003 08:51:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: LIANHE SHAO +Cc: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> +In-Reply-To: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/284 +X-Sequence-Number: 4844 + +> Which one is better (performance/easier to use), +> tsearch2 or fulltextindex? +> there is an example how to use fulltextindex in the +> techdocs, but I checked the contrib/fulltextindex +> package, there is a WARNING that fulltextindex is +> much slower than tsearch2. but tsearch2 seems +> complex to use, and I can not find a good example. +> Which one I should use? Any suggestions? + +I believe I wrote that warning :) + +Tsearch2 is what you should use. Yes, it's more complicated but it's +HEAPS faster and seriously powerful. + +Just read the README file. + +You could also try out the original tsearch (V1), but that will probably +be superceded soon, now that tsearch2 is around. + +Chris + + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 20:59:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E2D3D1B439 + for ; + Thu, 27 Nov 2003 00:59:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04518-01 + for ; + Wed, 26 Nov 2003 20:59:13 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id C9C45D1B43F + for ; + Wed, 26 Nov 2003 20:59:03 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAR0x8oD051309; Thu, 27 Nov 2003 08:59:09 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC54D52.4040207@familyhealth.com.au> +Date: Thu, 27 Nov 2003 09:03:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: LIANHE SHAO +Cc: Neil Conway , pgsql-performance@postgresql.org +Subject: Re: very large db performance question +References: <4e2c4d4e061f.4e061f4e2c4d@jhmimail.jhmi.edu> +In-Reply-To: <4e2c4d4e061f.4e061f4e2c4d@jhmimail.jhmi.edu> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/285 +X-Sequence-Number: 4845 + +> Thanks for reply. Actually our database only supply +> some scientists to use (we predict that). so there +> is no workload problem. there is only very +> infrequent updates. the query is not complex. the +> problem is, we have one table that store most of the +> data ( with 200 million rows). In this table, there +> is a text column which we need to do full text +> search for each row. The result will then join the +> data from another table which has 30,000 rows. Now +> the query runs almost forever. + +Use TSearch2. + +> I tried a small table with 2 million rows using the +> following simple command, it takes me about 6 +> seconds to get the result back. So, I get confused. +> That is why I ask: Is it the hardware problem or +> something else. (I just vacuumed the whole database +> yesterday). +> +> PGA=> select count (*) from expressiondata ; +> count +> --------- +> 2197497 +> (1 row) + +select count(*) on a postgres table ALWAYS does a sequential scan. Just +don't do it. There are technical reasons (MVCC) why this is so. It's a +bad "test". + +Chris + + + +From pgsql-performance-owner@postgresql.org Wed Nov 26 21:04:37 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EE9C5D1B49C + for ; + Thu, 27 Nov 2003 01:04:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03659-02 + for ; + Wed, 26 Nov 2003 21:04:09 -0400 (AST) +Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net + [66.117.144.213]) + by svr1.postgresql.org (Postfix) with ESMTP id E663BD1B448 + for ; + Wed, 26 Nov 2003 21:03:59 -0400 (AST) +Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) + by rlx13.zapatec.com (Postfix) with ESMTP id 8A4F6A941 + for ; + Wed, 26 Nov 2003 17:03:53 -0800 (PST) +Received: (from dror@localhost) + by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id hAR13qsa044103 + for pgsql-performance@postgresql.org; + Wed, 26 Nov 2003 17:03:52 -0800 (PST) (envelope-from dror) +Date: Wed, 26 Nov 2003 17:03:52 -0800 +From: Dror Matalon +To: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +Message-ID: <20031127010352.GT30893@rlx11.zapatec.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FC54A82.2040605@familyhealth.com.au> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/286 +X-Sequence-Number: 4846 + + +On Thu, Nov 27, 2003 at 08:51:14AM +0800, Christopher Kings-Lynne wrote: +> >Which one is better (performance/easier to use), +> >tsearch2 or fulltextindex? +> >there is an example how to use fulltextindex in the +> >techdocs, but I checked the contrib/fulltextindex +> >package, there is a WARNING that fulltextindex is +> >much slower than tsearch2. but tsearch2 seems +> >complex to use, and I can not find a good example. +> >Which one I should use? Any suggestions? +> +> I believe I wrote that warning :) +> +> Tsearch2 is what you should use. Yes, it's more complicated but it's +> HEAPS faster and seriously powerful. +> + +Can you provide some numbers please, both for creating full text indexes +as well as for searching them? I tried to use tsearch and it seemed like +just creating a full text index on million+ records took forever. + +> Just read the README file. +> +> You could also try out the original tsearch (V1), but that will probably +> be superceded soon, now that tsearch2 is around. +> +> Chris +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com + +From pgsql-performance-owner@postgresql.org Wed Nov 26 23:35:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A7C3D1B47C + for ; + Thu, 27 Nov 2003 03:33:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20533-03 + for ; + Wed, 26 Nov 2003 23:33:10 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 2556CD1B4CE + for ; + Wed, 26 Nov 2003 23:33:00 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id EBB9990000D; Wed, 26 Nov 2003 19:28:31 -0800 (PST) +Date: Wed, 26 Nov 2003 19:28:31 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +Message-ID: <20031127032831.GA4836@gp.word-to-the-wise.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FC54A82.2040605@familyhealth.com.au> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/287 +X-Sequence-Number: 4847 + +On Thu, Nov 27, 2003 at 08:51:14AM +0800, Christopher Kings-Lynne wrote: +> >Which one is better (performance/easier to use), +> >tsearch2 or fulltextindex? +> >there is an example how to use fulltextindex in the +> >techdocs, but I checked the contrib/fulltextindex +> >package, there is a WARNING that fulltextindex is +> >much slower than tsearch2. but tsearch2 seems +> >complex to use, and I can not find a good example. +> >Which one I should use? Any suggestions? +> +> I believe I wrote that warning :) +> +> Tsearch2 is what you should use. Yes, it's more complicated but it's +> HEAPS faster and seriously powerful. + +Does anyone have any metrics on how fast tsearch2 actually is? + +I tried it on a synthetic dataset of a million documents of a hundred +words each and while insertions were impressively fast I gave up on +the search after 10 minutes. + +Broken? Unusable slow? This was on the last 7.4 release candidate. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Thu Nov 27 00:39:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 062B2D1B461 + for ; + Thu, 27 Nov 2003 04:38:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24019-09 + for ; + Thu, 27 Nov 2003 00:38:20 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id EA5D8D1B45F + for ; + Thu, 27 Nov 2003 00:38:03 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAR4beoD053430; Thu, 27 Nov 2003 12:37:41 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC58097.8090803@familyhealth.com.au> +Date: Thu, 27 Nov 2003 12:41:59 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Atkins +Cc: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> +In-Reply-To: <20031127032831.GA4836@gp.word-to-the-wise.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/288 +X-Sequence-Number: 4848 + +> Does anyone have any metrics on how fast tsearch2 actually is? +> +> I tried it on a synthetic dataset of a million documents of a hundred +> words each and while insertions were impressively fast I gave up on +> the search after 10 minutes. +> +> Broken? Unusable slow? This was on the last 7.4 release candidate. + +I just created a 1.1million row dataset by copying one of our 30000 row +production tables and just taking out the txtidx column. Then I +inserted it into itself until it had 1.1 million rows. + +Then I created the GiST index - THAT took forever - seriously like 20 +mins or half an hour or something. + +Now, to find a word: + +select * from tsearchtest where ftiidx ## 'curry'; +Time: 9760.75 ms + +The AND of two words: +Time: 103.61 ms + +The AND of three words: +select * from tsearchtest where ftiidx ## 'curry&green&thai'; +Time: 61.86 ms + +And now a one word query now that buffers are cached: +select * from tsearchtest where ftiidx ## 'curry'; +Time: 444.89 ms + +So, I have no idea why you think it's slow? Perhaps you forgot the +'create index using gist' step? + +Also, if you use the NOT (!) operand, you can get yourself into a really +slow situation. + +Chris + + + + +From pgsql-performance-owner@postgresql.org Thu Nov 27 01:17:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9967D1B43C + for ; + Thu, 27 Nov 2003 05:17:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25728-07 + for ; + Thu, 27 Nov 2003 01:17:09 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FA97D1B441 + for ; + Thu, 27 Nov 2003 01:17:08 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 195A190000D; Wed, 26 Nov 2003 21:12:30 -0800 (PST) +Date: Wed, 26 Nov 2003 21:12:30 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +Message-ID: <20031127051230.GA6212@gp.word-to-the-wise.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FC58097.8090803@familyhealth.com.au> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/289 +X-Sequence-Number: 4849 + +On Thu, Nov 27, 2003 at 12:41:59PM +0800, Christopher Kings-Lynne wrote: +> >Does anyone have any metrics on how fast tsearch2 actually is? +> > +> >I tried it on a synthetic dataset of a million documents of a hundred +> >words each and while insertions were impressively fast I gave up on +> >the search after 10 minutes. +> > +> >Broken? Unusable slow? This was on the last 7.4 release candidate. +> +> I just created a 1.1million row dataset by copying one of our 30000 row +> production tables and just taking out the txtidx column. Then I +> inserted it into itself until it had 1.1 million rows. +> +> Then I created the GiST index - THAT took forever - seriously like 20 +> mins or half an hour or something. +> +> Now, to find a word: +> +> select * from tsearchtest where ftiidx ## 'curry'; +> Time: 9760.75 ms + +> So, I have no idea why you think it's slow? Perhaps you forgot the +> 'create index using gist' step? + +No, it was indexed. + +Thanks, that was the datapoint I was looking for. It _can_ run fast, so +I just need to work out what's going on. (It's hard to diagnose a slow +query when you've no idea whether it's really 'slow'). + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Thu Nov 27 04:44:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9C41D1B451 + for ; + Thu, 27 Nov 2003 08:41:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47479-07 + for ; + Thu, 27 Nov 2003 04:41:28 -0400 (AST) +Received: from ecbull20.frec.bull.fr (ecbull20.frec.bull.fr [129.183.4.3]) + by svr1.postgresql.org (Postfix) with ESMTP id BE283D1B43F + for ; + Thu, 27 Nov 2003 04:41:25 -0400 (AST) +Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) + by ecbull20.frec.bull.fr (8.9.2/8.9.1) with ESMTP id JAA20544; + Thu, 27 Nov 2003 09:42:29 +0100 +Received: from BULL.NET ([129.183.148.134]) + by ecn002.frec.bull.fr (Lotus Domino Release 5.0.12) + with ESMTP id 2003112709454775:638 ; Thu, 27 Nov 2003 09:45:47 +0100 +Message-ID: <3FC5B8F6.49A663E7@BULL.NET> +Date: Thu, 27 Nov 2003 09:42:30 +0100 +From: Thierry Missimilly +Organization: BSIS/R&D +X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) +X-Accept-Language: fr,en +MIME-Version: 1.0 +To: LIANHE SHAO +Cc: pgsql-performance@postgresql.org +Subject: Re: very large db performance question +References: <4cbacd4cb3c2.4cb3c24cbacd@jhmimail.jhmi.edu> +X-MIMETrack: Itemize by SMTP Server on ECN002/FR/BULL(Release 5.0.12 |February + 13, 2003) at 27/11/2003 09:45:47, + Serialize by Router on ECN002/FR/BULL(Release 5.0.12 |February 13, + 2003) at 27/11/2003 09:45:55, + Serialize complete at 27/11/2003 09:45:55 +Content-Type: multipart/mixed; boundary="------------F715D175693138A496FD42FA" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/290 +X-Sequence-Number: 4850 + +This is a multi-part message in MIME format. +--------------F715D175693138A496FD42FA +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +Hi, + +I have done some performance tests on 1Gb and 4 Gb Databases on a mono +Pentium 4 , 1 Gb RAM, IDE disk, SCSI disks and RAID0 LUN on DAS 5300 on +Linux RedHat 7.3. + +In each cases my tests make select, update and insert. +One of them is pgbench. You can find it in Postgres/contrib/pgbench. +The other one is DBT1 form OSDL. I have port it on Postgres and you can find +it in Source Forge. Jenny Wang is writting a better Postgres DBT1 based on C +transactions instead of PL/pgSQL Transactions. + +With this size of database, even after a fine tuning of Postgres the problem +is I/O Wait. So in you case with 100 Gb, you will have I/O Wait. +To resume my observations regarding diskss performances : +1) IDE disk are the slower. +2) SCSI disks are a little more faster but you can decrease I/O Wait by 25% +by creating a stripped volume group on 3 disks. +3) A RAID0 on 5 DAS5300 disks improve again performances by 20% as the DAS +Storage Processeur use internal caches + +One thing, very important in my case was the time of (hot) backup / restore. + +In that case the pgbench database schema is to simple to have an idea but +DBT1 schema is enough complex and on the RAID0 LUN the backup takes 12 min +but the restore takes 16 min + 10 min to recreate the indexes + 255 min to +recreate the Foreign Keys. So 4h41 for a 4Gb database. + +That means for a 100 Gb database, if your schema as Foreign keys and indexes +: about 5 hours to backup and 117 hours to restore (~5 days). +So, if your database in a critical database, it is better to use cold backup +with Snapshot tools. + +Regards, +Thierry Missimilly + +LIANHE SHAO wrote: + +> Hello All, +> We will have a very large database to store +> microarray data (may exceed 80-100G some day). now +> we have 1G RAM, 2G Hz Pentium 4, 1 CPU. and enough +> hard disk. +> +> I never touched such large database before. I ask +> several dbas if the hardware is ok, some said it is +> ok for the query, but I am not so convinced. Because +> I check the mailing list and learned that it is not +> unreasonable to take several minutes to do the +> query. But I want to query to be as fast as possible. +> +> Could anybody tell me that our hardware is an issue +> or not? do we really need better hardware to make +> real difference? +> +> Regards, +> William +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + +--------------F715D175693138A496FD42FA +Content-Type: text/x-vcard; charset=us-ascii; + name="THIERRY.MISSIMILLY.vcf" +Content-Description: Card for Thierry Missimilly +Content-Disposition: attachment; + filename="THIERRY.MISSIMILLY.vcf" +Content-Transfer-Encoding: 7bit + +begin:vcard +n:Missimilly;Thierry +tel;fax:+33 (0)4 76 29 78 78 +tel;work:+33 (0)4 76 29 74 54 +x-mozilla-html:FALSE +url:http:\\www.bull.com +org:BIS/R&D +adr:;;Bull SA, 1, rue de provence - BP 208;ECHIROLLES;;38432;FRANCE +version:2.1 +email;internet:Thierry.Missimilly@bull.net +x-mozilla-cpt:;-18184 +fn:Thierry Missimilly +end:vcard + +--------------F715D175693138A496FD42FA-- + + +From pgsql-performance-owner@postgresql.org Thu Nov 27 15:58:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18B76D1B47A + for ; + Thu, 27 Nov 2003 19:58:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 36366-03 + for ; + Thu, 27 Nov 2003 15:58:10 -0400 (AST) +Received: from smtp3.mail.be.easynet.net (bigglesworth.mail.be.easynet.net + [212.100.160.67]) + by svr1.postgresql.org (Postfix) with ESMTP id A2E71D1B450 + for ; + Thu, 27 Nov 2003 15:58:08 -0400 (AST) +Received: from 213-193-176-107.adsl.easynet.be ([213.193.176.107]) + by smtp3.mail.be.easynet.net with esmtp (Exim 4.22) + id 1APSH0-0003xL-Pw + for pgsql-performance@postgresql.org; Thu, 27 Nov 2003 20:57:58 +0100 +From: Stefan Champailler +Reply-To: schampailler@easynet.be +To: pgsql-performance@postgresql.org +Subject: Re: Impossibly slow DELETEs +Date: Thu, 27 Nov 2003 20:57:06 +0100 +User-Agent: KMail/1.5.3 +References: <200311252256.56433.schampailler@easynet.be> + <3FC3E984.3020508@potentialtech.com> +In-Reply-To: <3FC3E984.3020508@potentialtech.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200311272057.06718.schampailler@easynet.be> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/291 +X-Sequence-Number: 4851 + +I did not conduct much more test but from what I've seen, it looks like the +ODBC driver is in the doldrums, not PG. For example, when I run my software +on Windows rather than Linux, everything just works as expected. Sorry for +disturbing. + +And btw, I use ODBC because my target DB is Oracle and I've been requested to +access it throguh ODBC. So, because I don't have Oracle, I do most of my +development with PG and then I'll port to Oracle. Since I'm doing "simple" +stuff, PG is almost 100% compatible with Oracle. (and before you ask, no, +they don't give me the proper dev environment, bastards :)) + +Thanks for all the answers. + +Stefan + + +> Stefan Champailler wrote: +> > Dear You all, +> > +> > (please tell me if this has already been discussed, I was unable to find +> > any convincing information) +> > +> > I'm developing a small application, tied to a PG 7.4 beta 5 (i didn't +> > upgrade). The DB i use is roughly 20 tales each of them containing at +> > most 30 records (I'm still in development). I can provide a whole dump if +> > necessary. I access the DB throug IODBC (Suse Linux 8.1), through PHP. +> > The machine everything runs on is 512M of Ram, 2.5GHz speed. So I assume +> > it should be blazingly fast. +> > +> > So here's my trouble : some DELETE statement take up to 1 minute to +> > complete (but not always, sometimes it's fast, sometimes it's that slow). +> > Here's a typical one : DELETE FROM response_bool WHERE response_id = +> > '125' The response_bool table has no foreing key and no index on +> > response_id column. No foreign key reference the response_bool table. +> > There are 6 rows in the table (given that size, I assumed that an index +> > was not necessary). +> > +> > So 1 minute to complete look like I did something REALLY bad. +> > +> > It is my feeling that doing the same query with psql works without +> > problem, but I can't be sure. +> +> I think that last sentence is the crux of the problem. If you can +> establish for sure that the unreasonable delay is _only_ there when the +> command is issued through IODBC, then it's not a Postgresql problem. +> +> Out of curiosity, why are you using ODBC for PHP anyway? PHP has +> Postgresql libraries that work very well. I use them quite often without +> problems. + + +From pgsql-performance-owner@postgresql.org Fri Nov 28 01:09:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA2D0D1B46F + for ; + Fri, 28 Nov 2003 05:09:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82788-07 + for ; + Fri, 28 Nov 2003 01:08:59 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 30CE2D1B468 + for ; + Fri, 28 Nov 2003 01:08:58 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id C273C90000D; Thu, 27 Nov 2003 21:04:17 -0800 (PST) +Date: Thu, 27 Nov 2003 21:04:17 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +Message-ID: <20031128050417.GA14227@gp.word-to-the-wise.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031127051230.GA6212@gp.word-to-the-wise.com> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/292 +X-Sequence-Number: 4852 + +On Wed, Nov 26, 2003 at 09:12:30PM -0800, Steve Atkins wrote: +> On Thu, Nov 27, 2003 at 12:41:59PM +0800, Christopher Kings-Lynne wrote: +> > >Does anyone have any metrics on how fast tsearch2 actually is? +> > > +> > >I tried it on a synthetic dataset of a million documents of a hundred +> > >words each and while insertions were impressively fast I gave up on +> > >the search after 10 minutes. +> > > +> > >Broken? Unusable slow? This was on the last 7.4 release candidate. +> > +> > I just created a 1.1million row dataset by copying one of our 30000 row +> > production tables and just taking out the txtidx column. Then I +> > inserted it into itself until it had 1.1 million rows. +> > +> > Then I created the GiST index - THAT took forever - seriously like 20 +> > mins or half an hour or something. +> > +> > Now, to find a word: +> > +> > select * from tsearchtest where ftiidx ## 'curry'; +> > Time: 9760.75 ms +> +> > So, I have no idea why you think it's slow? Perhaps you forgot the +> > 'create index using gist' step? +> +> No, it was indexed. +> +> Thanks, that was the datapoint I was looking for. It _can_ run fast, so +> I just need to work out what's going on. (It's hard to diagnose a slow +> query when you've no idea whether it's really 'slow'). + +Looking at it further, something is very broken, possibly with GIST +indices, possibly with tsearch2s use of 'em. + +This is on a newly built 7.4 installation, built with 64 bit +datetimes, but completely stock other than that. Stock gcc 3.3.2, +Linux, somewhat elderly 2.4.18 kernel. Running on a 1.5GHz single +processor Athlon with a half gig of RAM. Configuration set to use 20% +of RAM as shared buffers (amongst other settings, this was the last of +a range I tried looking for variation). + +Software RAID0 across two 7200RPM SCSI drives, reiserfs (it's a +development box, not a production system). System completely idle +apart from postgresql. + +269000 rows, each row having 400 words. Analyzed. + +Running the select query given below appears to pause a process trying +to insert into the table completely (locking issue? I/O bandwidth?). + +top shows the select below consuming <2% of CPU and iostat shows it reading +~2800 blocks/second from each of the two RAID drives. + +Physical size of the database is under 3 gigs, including toast and index +tables. + +The select query takes around 6 minutes (consistently, even if the same +identical query is repeated). + +For entertainment, I turned off indexscan and the query takes 1 +minute with a simple seqscan. + +Any thoughts? + +Cheers, + Steve + +=> select count(*) from ftstest; + count +-------- + 269000 +(1 row) + +=> \d ftstest + Table "public.ftstest" + Column | Type | Modifiers +--------+----------+---------------------------------------------------------- + idx | integer | not null default nextval('public.ftstest_idx_seq'::text) + words | text | not null + idxfti | tsvector | not null +Indexes: + "ftstest_idx" gist (idxfti) + +=> explain analyze select idx from ftstest where idxfti @@ 'dominican'::tsquery; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ftstest_idx on ftstest (cost=0.00..515.90 rows=271 width=4) (actual time=219.694..376042.428 rows=4796 loops=1) + Index Cond: (idxfti @@ '\'dominican\''::tsquery) + Filter: (idxfti @@ '\'dominican\''::tsquery) + Total runtime: 376061.541 ms +(4 rows) + + +((Set enable_indexscan=false)) + + +=> explain analyze select idx from ftstest where idxfti @@ 'dominican'::tsquery; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------- + Seq Scan on ftstest (cost=0.00..5765.88 rows=271 width=4) (actual time=42.589..62158.285 rows=4796 loops=1) + Filter: (idxfti @@ '\'dominican\''::tsquery) + Total runtime: 62182.277 ms +(3 rows) + +From pgsql-performance-owner@postgresql.org Fri Nov 28 01:14:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AB67ED1B44D + for ; + Fri, 28 Nov 2003 05:14:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86782-02 + for ; + Fri, 28 Nov 2003 01:14:04 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 6057BD1B446 + for ; + Fri, 28 Nov 2003 01:14:02 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAS5DfoD062128; Fri, 28 Nov 2003 13:13:41 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC6DAB8.4080106@familyhealth.com.au> +Date: Fri, 28 Nov 2003 13:18:48 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Atkins +Cc: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> +In-Reply-To: <20031128050417.GA14227@gp.word-to-the-wise.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/293 +X-Sequence-Number: 4853 + + +> Any thoughts? + +Actually, I ran my tests using tsearch V1. I wonder if there has been +some weird regression between tsearch 1 and 2? + +hris + + + +From pgsql-performance-owner@postgresql.org Fri Nov 28 01:23:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F27FAD1B481 + for ; + Fri, 28 Nov 2003 05:22:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89056-01 + for ; + Fri, 28 Nov 2003 01:22:22 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C006D1B45E + for ; + Fri, 28 Nov 2003 01:22:21 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hAS5LioD062170; Fri, 28 Nov 2003 13:21:45 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FC6DC9B.4060904@familyhealth.com.au> +Date: Fri, 28 Nov 2003 13:26:51 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: Steve Atkins , + pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> +In-Reply-To: <3FC6DAB8.4080106@familyhealth.com.au> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/294 +X-Sequence-Number: 4854 + +>> Any thoughts? +> +> +> Actually, I ran my tests using tsearch V1. I wonder if there has been +> some weird regression between tsearch 1 and 2? + +I also ran my tests on 7.3.4 :( + +Chris + + + +From pgsql-performance-owner@postgresql.org Fri Nov 28 01:59:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 11AE0D1B493 + for ; + Fri, 28 Nov 2003 05:58:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78976-09 + for ; + Fri, 28 Nov 2003 01:58:28 -0400 (AST) +Received: from mail.delegated.net (nitro.ezprovider.net [66.199.148.100]) + by svr1.postgresql.org (Postfix) with SMTP id A91E2D1B45A + for ; + Fri, 28 Nov 2003 01:58:11 -0400 (AST) +Received: (qmail 32296 invoked from network); 28 Nov 2003 05:57:55 -0000 +Received: from h24-85-181-182.vn.shawcable.net (HELO delegated.net) + (24.85.181.182) + by nitro.ezprovider.net with SMTP; 28 Nov 2003 05:57:55 -0000 +Message-ID: <3FC6E405.5010509@delegated.net> +Date: Thu, 27 Nov 2003 21:58:29 -0800 +From: Jonathan Knopp +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6a) Gecko/20031030 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: simple left join slows query more than expected +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/295 +X-Sequence-Number: 4855 + +I'v spent a couple days playing with this problem and searching the mailing lists and +docs etc but come up with nothing. Any help would be much appreciated. + +Setup is postgres 7.3.2 on redhat 7.1 on a 1.3GHz Athlon machine with 1G pc133 ram and +SCSI. + +Here is the same query with the addition of a left join onto a list of contacts to +grab the last name of each connected contact. I'd think this should be real quick since +it jsut has to grab around 100 names from the list, and if its smart enough to grab just +distinct IDs, then it's just like 10 rows it has to grab using the primary field. But as +far as i can tell (and i may VERY well be reading the explain syntax wrong), it is +grabbing them all and joining them first, rather than doing the operation that limits +the result rows to a mere 100 and THEN doing the join to contacts. It would be faster +if i did a separate query using a big IN(id1,id2,...) condition, which makes no sense to +me. Plus i REALLY want to avoid this as the selected fields and the joins and conditions +are all variable and controlled (indirectly and transparently) by the user. + +Point is, why does a simple left join slow things down so much? in my experience +(primarily with mysql but also over a year with postgre) simple left joins are usually +quite quick. I can only guess that a bad plan is being chosen. PLEASE don't tell me i +need to store a copy of the names in the events table to get acceptable speed, cause +this would be plain sacrilegious in terms of DB design. Or is this simply as fast as +these queries can go? Just seems too long for the work that's being done IME. + +events table has 12355 rows +contacts has 20064 +event_managers has 8502 + +All fields with conditions (object_ids, contact, event_id, user_id, deleted_on) are indexed with btree. + +Here is the query with the left join. + +sauce=# explain analyze SELECT top.object_id , top.who, top.datetime, top.priority, top.subject, top.action, top_contact_.last_name, top.object_id, top_contact_.object_id + FROM event_managers AS managers + JOIN ONLY events AS top ON(managers.event_id=top.object_id) + LEFT JOIN contacts AS top_contact_ ON(top.contact=top_contact_.object_id and top_contact_.deleted_on IS NULL) + WHERE true AND managers.user_id=238; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------- +Merge Join (cost=5569.24..5671.22 rows=100 width=91) (actual time=485.95..526.25 rows=208 loops=1) + Merge Cond: ("outer".contact = "inner".object_id) + Join Filter: ("inner".deleted_on IS NULL) + -> Sort (cost=2467.17..2467.42 rows=100 width=60) (actual time=143.67..143.75 rows=208 loops=1) + Sort Key: top.contact + -> Hash Join (cost=143.63..2463.83 rows=100 width=60) (actual time=0.89..142.64 rows=208 loops=1) + Hash Cond: ("outer".object_id = "inner".event_id) + -> Seq Scan on events top (cost=0.00..1830.19 rows=12219 width=56) (actual time=0.05..131.33 rows=12219 loops=1) + -> Hash (cost=143.45..143.45 rows=69 width=4) (actual time=0.65..0.65 rows=0 loops=1) + -> Index Scan using event_managers_user_id on event_managers managers (cost=0.00..143.45 rows=69 width=4) (actual time=0.14..0.50 rows=139 loops=1) + Index Cond: (user_id = 238) + -> Sort (cost=3102.07..3152.23 rows=20064 width=31) (actual time=342.23..360.29 rows=19964 loops=1) + Sort Key: top_contact_.object_id + -> Append (cost=0.00..1389.64 rows=20064 width=31) (actual time=0.06..115.63 rows=20064 loops=1) + -> Seq Scan on contacts top_contact_ (cost=0.00..1383.43 rows=20043 width=31) (actual time=0.06..101.04 rows=20043 loops=1) + -> Seq Scan on users top_contact_ (cost=0.00..6.21 rows=21 width=31) (actual time=0.05..0.29 rows=21 loops=1) + Total runtime: 527.47 msec +(17 rows) + + +The same thing but without the left join. Much faster. Anything slower than +this would be unacceptable, especailly given how small the tables are at this +point. They are expected to grow ALOT bigger within a year. + +sauce=# explain analyze SELECT top.object_id , top.who, top.datetime, top.priority, top.subject, top.action, top.object_id + FROM event_managers AS managers + JOIN ONLY events AS top ON(managers.event_id=top.object_id) + WHERE true AND managers.user_id=238; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=143.63..2463.83 rows=100 width=56) (actual time=1.48..137.74 rows=208 loops=1) + Hash Cond: ("outer".object_id = "inner".event_id) + -> Seq Scan on events top (cost=0.00..1830.19 rows=12219 width=52) (actual time=0.06..125.80 rows=12219 loops=1) + -> Hash (cost=143.45..143.45 rows=69 width=4) (actual time=1.20..1.20 rows=0 loops=1) + -> Index Scan using event_managers_user_id on event_managers managers (cost=0.00..143.45 rows=69 width=4) (actual time=0.21..1.03 rows=139 loops=1) + Index Cond: (user_id = 238) + Total runtime: 137.96 msec +(7 rows) + +again, many thanks for any feedback! + + +From pgsql-performance-owner@postgresql.org Fri Nov 28 13:56:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 64A3CD1B433 + for ; + Fri, 28 Nov 2003 17:56:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67667-10 + for ; + Fri, 28 Nov 2003 13:55:40 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 71854D1B432 + for ; + Fri, 28 Nov 2003 13:55:39 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hASHtc19029110; + Fri, 28 Nov 2003 12:55:38 -0500 (EST) +To: Jonathan Knopp +Cc: pgsql-performance@postgresql.org +Subject: Re: simple left join slows query more than expected +In-reply-to: <3FC6E405.5010509@delegated.net> +References: <3FC6E405.5010509@delegated.net> +Comments: In-reply-to Jonathan Knopp + message dated "Thu, 27 Nov 2003 21:58:29 -0800" +Date: Fri, 28 Nov 2003 12:55:38 -0500 +Message-ID: <29109.1070042138@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/296 +X-Sequence-Number: 4856 + +Jonathan Knopp writes: +> I'v spent a couple days playing with this problem and searching the mailing lists and +> docs etc but come up with nothing. Any help would be much appreciated. + +Don't use inheritance to define the contacts table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Nov 28 16:58:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EEE08D1B435 + for ; + Fri, 28 Nov 2003 20:42:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95967-06 + for ; + Fri, 28 Nov 2003 16:41:43 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id EBCACD1B438 + for ; + Fri, 28 Nov 2003 16:41:39 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 8584190000D; Fri, 28 Nov 2003 12:37:00 -0800 (PST) +Date: Fri, 28 Nov 2003 12:37:00 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +Message-ID: <20031128203700.GA19831@gp.word-to-the-wise.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FC6DAB8.4080106@familyhealth.com.au> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/299 +X-Sequence-Number: 4859 + +On Fri, Nov 28, 2003 at 01:18:48PM +0800, Christopher Kings-Lynne wrote: +> +> >Any thoughts? +> +> Actually, I ran my tests using tsearch V1. I wonder if there has been +> some weird regression between tsearch 1 and 2? + +Maybe. tsearch2 doesn't seem production ready in other respects +(untsearch2.sql barfs with 'aggregate stat(tsvector) does not exist' +and the openfts mailing list, where this would be more appropriate, +doesn't appear to exist according to sourceforge). + +So, using the same data, modulo a few alter tables, I try tsearch, V1. +It's a little slower than V2, and again runs far faster without an +index than with it. Broken in the same way. + +I have 7.2.4 running on a Sun box, so I tried that too, with similar +results. tsearch just doesn't seem to work very well on this dataset +(or any other large dataset I've tried). + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Sun Nov 30 05:47:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 27965D1B46B + for ; + Sun, 30 Nov 2003 09:47:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20858-09 + for ; + Sun, 30 Nov 2003 05:46:37 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id C9DEDD1B457 + for ; + Sun, 30 Nov 2003 05:46:35 -0400 (AST) +Received: from [203.221.247.192] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #1) + id 1AQOA2-0005U9-00; Sun, 30 Nov 2003 20:46:38 +1100 +Message-ID: <3FC9BC76.2030308@familyhealth.com.au> +Date: Sun, 30 Nov 2003 17:46:30 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Atkins +Cc: pgsql-performance@postgresql.org +Subject: Re: For full text indexing, which is better, tsearch2 or +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> + <20031128203700.GA19831@gp.word-to-the-wise.com> +In-Reply-To: <20031128203700.GA19831@gp.word-to-the-wise.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200311/300 +X-Sequence-Number: 4860 + +> I have 7.2.4 running on a Sun box, so I tried that too, with similar +> results. tsearch just doesn't seem to work very well on this dataset +> (or any other large dataset I've tried). + +Well, as I've shown - works fine for me... + +I strongly suggest you repost your problem report to -hackers, since the +fact that the tsearch developers haven't chimed in implies to me that +they don't watch the performance list. + +BTW, read this about Gist indexes: + +http://www.postgresql.org/docs/current/static/limitations.html + +(Note lack of concurrency) + +Chris + +