From pgsql-performance-owner@postgresql.org Wed Oct 1 01:52:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8F5F2D1B57A for ; Wed, 1 Oct 2003 04:52:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 43135-10 for ; Wed, 1 Oct 2003 01:51:44 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 7911DD1B8BF for ; Wed, 1 Oct 2003 01:28:56 -0300 (ADT) 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 h914So6c025574; Wed, 1 Oct 2003 00:28:50 -0400 (EDT) To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Tuning/performance issue... In-reply-to: <057501c38790$d9b9aad0$6501a8c0@griffiths2> References: <057501c38790$d9b9aad0$6501a8c0@griffiths2> Comments: In-reply-to David Griffiths message dated "Tue, 30 Sep 2003 13:24:24 -0700" Date: Wed, 01 Oct 2003 00:28:50 -0400 Message-ID: <25573.1064982530@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/5 X-Sequence-Number: 3753 David Griffiths writes: > ... FROM commercial_entity, country, user_account, > address_list LEFT JOIN state_province ON address_list.state_province_id > = state_province.state_province_id > LEFT JOIN contact_info ON address_list.contact_info_id = > contact_info.contact_info_id > WHERE ... I believe what you're getting burnt by is that PG's planner interprets this as forcing the address_list * state_province * contact_info join to be done before it joins those tables to commercial_entity, country, and user_account --- for discussion see http://www.postgresql.org/docs/7.3/static/explicit-joins.html Unfortunately your WHERE-clause restriction conditions are on address_list, commercial_entity, and user_account; and it seems the address_list constraint is very weak. So the plan ends up forming a large fraction of the address_list * state_province * contact_info join, only to throw it away again when there's no matching rows selected from commercial_entity and user_account. The actual runtime and actual row counts from the EXPLAIN ANALYZE output show that this is what's happening. The most efficient way to handle this query would probably be to join the three tables with restrictions first, and then join the other tables to those. You could force this with not too much rewriting using something like (untested, but I think it's right) ... FROM commercial_entity CROSS JOIN user_account CROSS JOIN address_list LEFT JOIN state_province ON address_list.state_province_id = state_province.state_province_id LEFT JOIN contact_info ON address_list.contact_info_id = contact_info.contact_info_id CROSS JOIN country WHERE ... The explicit JOINs associate left-to-right, so this gives the intended join order. (In your original query, explicit JOIN binds more tightly than commas do.) The reason PG's planner doesn't discover this join order for itself is that it's written to not attempt to re-order outer joins from the syntactically defined ordering. In general, such reordering would change the results. It is possible to analyze the query and prove that certain reorderings are valid (don't change the results), but we don't currently have code to do that. > As a reference, our production Oracle database (exactly the same > hardware, but RAID-mirroring) with way more load can handle the query in > 1-2 seconds. I have MySQL 4.0.14 with InnoDB on the same machine > (shutdown when I am testing Postgres, and visa versa) and it does the > query in 0.20 seconds. I'm prepared to believe that Oracle contains code that actually does the analysis about which outer-join reorderings are valid, and is then able to find the right join order by deduction. The last I heard about MySQL, they have no join-order analysis at all; they unconditionally interpret this type of query left-to-right, ie as ... FROM ((((commercial_entity CROSS JOIN country) CROSS JOIN user_account) CROSS JOIN address_list) LEFT JOIN state_province ON ...) LEFT JOIN contact_info ON ... WHERE ... This is clearly at odds with the SQL spec's syntactically defined join order semantics. It's possible that it always yields the same results as the spec requires, but I'm not at all sure about that. In any case this strategy is certainly not "better" than ours, it just performs poorly on a different set of queries. Would I be out of line to speculate that your query was previously tuned to work well in MySQL? regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 1 02:41:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D4F1AD1B520 for ; Wed, 1 Oct 2003 05:41:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 44668-10 for ; Wed, 1 Oct 2003 02:40:50 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 59085D1B4EC for ; Wed, 1 Oct 2003 02:40:49 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id ; Tue, 30 Sep 2003 22:39:22 -0700 Received: from GRIFFITHS2 ([192.168.12.195]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TTY64QG8; Tue, 30 Sep 2003 22:39:17 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <074601c387df$b5939270$6501a8c0@griffiths2> References: <057501c38790$d9b9aad0$6501a8c0@griffiths2> <25573.1064982530@sss.pgh.pa.us> Subject: Re: Tuning/performance issue... Date: Tue, 30 Sep 2003 22:48:54 -0700 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 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/6 X-Sequence-Number: 3754 > The most efficient way to handle this query would probably be to join > the three tables with restrictions first, and then join the other tables > to those. You could force this with not too much rewriting using > something like (untested, but I think it's right) > > ... FROM commercial_entity CROSS JOIN user_account CROSS JOIN > address_list LEFT JOIN state_province ON address_list.state_province_id > = state_province.state_province_id > LEFT JOIN contact_info ON address_list.contact_info_id = > contact_info.contact_info_id > CROSS JOIN country > WHERE ... > > The explicit JOINs associate left-to-right, so this gives the intended > join order. (In your original query, explicit JOIN binds more tightly > than commas do.) Ok - that's interesting - I'll have to do some reading and more testing. > The reason PG's planner doesn't discover this join order for itself > is that it's written to not attempt to re-order outer joins from the > syntactically defined ordering. In general, such reordering would > change the results. It is possible to analyze the query and prove that > certain reorderings are valid (don't change the results), but we don't > currently have code to do that. Not sure I follow. Are you saying that, depending on when the outer-join is applied to the rows found at the time, you may end up with a different set of rows? I would have expected the optimizer to do the outer-joins last, as the extra data received by the outer-joins is not mandatory, and won't affect the rows that were retreived by joining user_account, address_list, and commercial_entity. An outer join would *never* be the most restrictive join in a query. I thought (from my readings on Oracle query tuning) that finding the most restrictive table/index was the first task of an optimizer. Reduce the result set as quickly as possible. That query has the line, "AND commercial_entity.commercial_entity_id=225528", which uses an index (primary key) and uses an "=". I would have expected that to be done first, then joined with the other inner-join tables, and finally have the outer-joins applied to the final result set to fill in the "might be there" data. Anyway, if the optimizer does the outer-joins first (address_list with state_province and contact_info), then it's picking the table with the most rows (address_list has 200K+ rows, where the other 3 big tables have 70K-90K). Would re-ordering the FROM clause (and LEFT JOIN portions) help? Could you give an example where applying an outer-join at a different time could result in different results? I think I can see at situation where you use part of the results in the outer-join in the where clause, but I am not sure. > I'm prepared to believe that Oracle contains code that actually does the > analysis about which outer-join reorderings are valid, and is then able > to find the right join order by deduction. I'm not sure about Oracle (other than what I stated above). In fact, about half the time, updating table stats to try to get the Oracle optimizer to do a better job on a query results in even worse performance. > ... FROM ((((commercial_entity CROSS JOIN country) CROSS JOIN > user_account) CROSS JOIN address_list) > LEFT JOIN state_province ON ...) > LEFT JOIN contact_info ON ... > WHERE ... > > This is clearly at odds with the SQL spec's syntactically defined join > order semantics. It's possible that it always yields the same results > as the spec requires, but I'm not at all sure about that. Again, I don't know. On the 3 queries based on these tables, Postgres and MySQL return the exact same data (they use the same data set). Do you have a link to the SQL spec's join-order requirements? > In any case > this strategy is certainly not "better" than ours, it just performs > poorly on a different set of queries. Would I be out of line to > speculate that your query was previously tuned to work well in MySQL? The query was pulled from our codebase (written for Oracle). I added a bit to it to make it slower, and then ported to MySQL and tested there first (just re-wrote the outer-join syntax). I found that re-ordering the tables in the from-clause on MySQL changed the time by 45-ish% (0.36 seconds to .20 seconds), but that's because I had forgotten to re-analyze the tables after refreshing the dataset. Now, table order doesn't make a difference in speed (or results). If anything, I've done more tuning for Postgres - added some extra indexes to try to help (country.country_id had a composite index with another column, but not an index for just it), etc. The dataset and schema is pure-Oracle. I extracted it out of the database, removed all Oracle-specific extensions, changed the column types, and migrated the indexes and foreign keys to MySQL and Postgres. Nothing more (other than an extra index or two for Postgres - nada for MySQL). This is all part of a "migrate away from Oracle" project. We are looking at 3 databases - MySQL (InnoDB), Postgres and Matisse (object oriented). We have alot of queries like this or worse, and I'm worried that many of them would need to be re-written. The developers know SQL, but nothing about tuning, etc. Thanks for the quick response - I will try explicit joining, and I'm looking forward to your comments on outer-joins and the optmizer (and anything else I've written). David. From pgsql-performance-owner@postgresql.org Wed Oct 1 04:04:21 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D50EBD1B506 for ; Wed, 1 Oct 2003 07:04:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62766-08 for ; Wed, 1 Oct 2003 04:03:33 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 83F2DD1B53C for ; Wed, 1 Oct 2003 04:03:30 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9176Eu5004435 for ; Wed, 1 Oct 2003 12:36:14 +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 h9176D1r004409; Wed, 1 Oct 2003 12:36:13 +0530 Message-ID: <3F7A7CBA.4060507@persistent.co.in> Date: Wed, 01 Oct 2003 12:35:30 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Tuning/performance issue.... References: <058d01c38791$0d0a91b0$6501a8c0@griffiths2> In-Reply-To: <058d01c38791$0d0a91b0$6501a8c0@griffiths2> 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: 200310/7 X-Sequence-Number: 3755 David Griffiths wrote: > And finally, > > Here's the contents of the postgresql.conf file (I've been playing with > these setting the last couple of days, and using the guide @ > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html to > make sure I didn't have it mis-tuned): > > tcpip_socket = true > max_connections = 500 # We will need quite a few connections; > currently only one connection to database, however > port = 5432 > shared_buffers = 5000 # I've tried 5000 to 80,000 with no > apparent difference > wal_buffers = 16 > sort_mem = 256 # decreased this due to the large # of > connectiosn > effective_cache_size = 50000 # read that this can improve performance; > hasn't done anything. Reading this whole thread, I think most of the improvement you would get would be from rethinking your schema from PG point of view and examine each query. After you changed your last query as Tom suggested for explicit join, how much improvement did it make? I noticed that you put 'commercial_entity.commercial_entity_id=225528' as a second codition. Does it make any difference to put it ahead in where clause list? HTH Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 1 07:34:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3222FD1B522 for ; Wed, 1 Oct 2003 10:34:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01733-07 for ; Wed, 1 Oct 2003 07:33:39 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id CC80CD1B4FF for ; Wed, 1 Oct 2003 07:33:35 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A4eIc-0001zW-00 for ; Wed, 01 Oct 2003 06:33:38 -0400 Received: by dba2 (Postfix, from userid 1019) id 452B3CB29; Wed, 1 Oct 2003 06:33:38 -0400 (EDT) Date: Wed, 1 Oct 2003 06:33:38 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: inferior SCSI performance Message-ID: <20031001103338.GA29293@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <3F688CC5.12621.4EBFDCC@localhost> <4693.1063825713@sss.pgh.pa.us> 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: 200310/8 X-Sequence-Number: 3756 On Wed, Sep 17, 2003 at 04:46:00PM -0400, Michael Adler wrote: > So the quesiton is whether it is ever sensible to use write-caching and > expect comparable persistence. Yes. If and only if you have a battery-backed cache. I know of no IDE drives that have that, but there's nothing about the spec which makes it impossible. 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 Oct 1 09:12:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6F3A8D1B4F2 for ; Wed, 1 Oct 2003 12:12:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22960-02 for ; Wed, 1 Oct 2003 09:11:36 -0300 (ADT) Received: from ns1.bee.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 4A4B3D1B51A for ; Wed, 1 Oct 2003 09:11:32 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bee.lt (8.11.6/8.11.6) with SMTP id h91CBYf00874 for ; Wed, 1 Oct 2003 15:11:35 +0300 Message-ID: <07c001c38815$29277b90$f20214ac@bite.lt> From: "Mindaugas Riauba" To: Subject: What is the fastest null WHERE Date: Wed, 1 Oct 2003 15:11:30 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" 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.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200310/9 X-Sequence-Number: 3757 Hello, While writing web application I found that it would be very nice for me to have "null" WHERE clause. Like WHERE 1=1. Then it is easy to concat additional conditions just using $query . " AND col=false" syntax. But which of the possible "null" clauses is the fastest one? Thanks, Mindaugas From pgsql-performance-owner@postgresql.org Wed Oct 1 09:24:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 085ACD1B542 for ; Wed, 1 Oct 2003 12:24:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23158-04 for ; Wed, 1 Oct 2003 09:23:28 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id B0B0ED1B4E5 for ; Wed, 1 Oct 2003 09:23:09 -0300 (ADT) Received: (qmail 22778 invoked from network); 1 Oct 2003 12:23:10 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 1 Oct 2003 12:23:10 -0000 Date: Wed, 1 Oct 2003 08:23:10 -0400 (EDT) From: Jeff To: David Griffiths Cc: "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... In-Reply-To: <074601c387df$b5939270$6501a8c0@griffiths2> 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: 200310/10 X-Sequence-Number: 3758 On Tue, 30 Sep 2003, David Griffiths wrote: > > This is all part of a "migrate away from Oracle" project. We are looking at > 3 databases - > MySQL (InnoDB), Postgres and Matisse (object oriented). We have alot of > queries like this > or worse, and I'm worried that many of them would need to be re-written. The > developers > know SQL, but nothing about tuning, etc. > There's a movement at my company to ditch several commercial db's in favor of a free one. I'm currently the big pg fan around here and I've actually written a rather lengthy presentation about pg features, why, tuning, etc. but another part was some comparisons to other db's.. I decided so I wouldn't be blinding flaming mysql to give it a whirl and loaded it up with the same dataset as pg. First thing I hit was lack of stored procedures. But I decided to code around that, giving mysql the benefit of the doubt. What I found was interesting. For 1-2 concurrent 'beaters' it screamed. ultra-fast. But.. If you increase the concurrent beaters up to say, 20 Mysql comes to a grinding halt.. Mysql and the machine itself become fairly unresponsive. And if you do cache unfriendly queries it becomes even worse. On PG - no problems at all. Scaled fine and dandy up. And with 40 concurrent beaters the machine was still responsive. (The numbers for 20 client was 220 seconds (pg) and 650 seconds (mysql)) So that is another test to try out - Given your configuration I expect you have lots of concurrent activity. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 1 09:31:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA93AD1B4E1 for ; Wed, 1 Oct 2003 12:30:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24557-01 for ; Wed, 1 Oct 2003 09:30:16 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 34424D1B4F2 for ; Wed, 1 Oct 2003 09:30:11 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h91CX1AK028519 for ; Wed, 1 Oct 2003 18:03:01 +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 h91CX0Nh028493; Wed, 1 Oct 2003 18:03:00 +0530 Message-ID: <3F7AC94E.1000407@persistent.co.in> Date: Wed, 01 Oct 2003 18:02:14 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mindaugas Riauba Cc: pgsql-performance@postgresql.org Subject: Re: What is the fastest null WHERE References: <07c001c38815$29277b90$f20214ac@bite.lt> In-Reply-To: <07c001c38815$29277b90$f20214ac@bite.lt> 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: 200310/11 X-Sequence-Number: 3759 Mindaugas Riauba wrote: > Hello, > > While writing web application I found that it would > be very nice for me to have "null" WHERE clause. Like > WHERE 1=1. Then it is easy to concat additional > conditions just using $query . " AND col=false" syntax. > > But which of the possible "null" clauses is the fastest > one? Rather than this approach, keep a flag which tells you whether or not it is first where condition. If it is not first where condition, add a 'and'. That would be simple, isn't it? Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 1 09:39:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AE588D1B4EC for ; Wed, 1 Oct 2003 12:39:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24711-03 for ; Wed, 1 Oct 2003 09:39:04 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id CFEBAD1B4F2 for ; Wed, 1 Oct 2003 09:39:00 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1A4gG0-000EOD-0V; Wed, 01 Oct 2003 13:39:04 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id E11C815A42; Wed, 1 Oct 2003 13:39:02 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 425C01599F; Wed, 1 Oct 2003 13:39:02 +0100 (BST) From: Richard Huxton To: "Mindaugas Riauba" , Subject: Re: What is the fastest null WHERE Date: Wed, 1 Oct 2003 13:39:01 +0100 User-Agent: KMail/1.5 References: <07c001c38815$29277b90$f20214ac@bite.lt> In-Reply-To: <07c001c38815$29277b90$f20214ac@bite.lt> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310011339.01707.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/12 X-Sequence-Number: 3760 On Wednesday 01 October 2003 13:11, Mindaugas Riauba wrote: > Hello, > > While writing web application I found that it would > be very nice for me to have "null" WHERE clause. Like > WHERE 1=1. Then it is easy to concat additional > conditions just using $query . " AND col=false" syntax. > > But which of the possible "null" clauses is the fastest > one? I suspect WHERE true, but is it really necessary. Most languages will have a join() operator that lets you do something like: $where_cond = join(' AND ', @list_of_tests) -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Wed Oct 1 09:52:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A1303D1B51D for ; Wed, 1 Oct 2003 12:52:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 26840-01 for ; Wed, 1 Oct 2003 09:51:30 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 3E208D1B526 for ; Wed, 1 Oct 2003 09:51:11 -0300 (ADT) Received: (qmail 5784 invoked from network); 1 Oct 2003 12:51:05 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 1 Oct 2003 12:51:05 -0000 Subject: Re: What is the fastest null WHERE From: Rod Taylor To: Mindaugas Riauba Cc: Postgresql Performance In-Reply-To: <07c001c38815$29277b90$f20214ac@bite.lt> References: <07c001c38815$29277b90$f20214ac@bite.lt> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-LoyjT9L9QCuLRJ620F4r" Message-Id: <1065012705.83185.78.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 01 Oct 2003 08:51:46 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/13 X-Sequence-Number: 3761 --=-LoyjT9L9QCuLRJ620F4r Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-10-01 at 08:11, Mindaugas Riauba wrote: > While writing web application I found that it would > be very nice for me to have "null" WHERE clause. Like > WHERE 1=3D1. Then it is easy to concat additional > conditions just using $query . " AND col=3Dfalse" syntax. >=20 > But which of the possible "null" clauses is the fastest > one? WHERE true AND .... --=-LoyjT9L9QCuLRJ620F4r Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/es3h6DETLow6vwwRAgyzAKCEExsWbRYslQU14sPzBPcGsxgEQgCcDXjI 74JTk9DH9yeFIwtLRU7G57g= =rm8u -----END PGP SIGNATURE----- --=-LoyjT9L9QCuLRJ620F4r-- From pgsql-performance-owner@postgresql.org Wed Oct 1 10:06:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1CA2AD1B545 for ; Wed, 1 Oct 2003 13:06:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 27807-03 for ; Wed, 1 Oct 2003 10:05:46 -0300 (ADT) Received: from ns1.bee.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 8E82FD1B540 for ; Wed, 1 Oct 2003 10:05:42 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bee.lt (8.11.6/8.11.6) with SMTP id h91D5jf01404 for ; Wed, 1 Oct 2003 16:05:45 +0300 Message-ID: <085401c3881c$bacfaca0$f20214ac@bite.lt> From: "Mindaugas Riauba" To: References: <07c001c38815$29277b90$f20214ac@bite.lt> <200310011339.01707.dev@archonet.com> Subject: Re: What is the fastest null WHERE Date: Wed, 1 Oct 2003 16:05:41 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" 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: 200310/14 X-Sequence-Number: 3762 > > While writing web application I found that it would > > be very nice for me to have "null" WHERE clause. Like > > WHERE 1=1. Then it is easy to concat additional > > conditions just using $query . " AND col=false" syntax. > > > > But which of the possible "null" clauses is the fastest > > one? > > I suspect WHERE true, but is it really necessary. Thanks. I'll use "WHERE true" for now. And of course it is not necessary it just simplifies code a bit. > Most languages will have a join() operator that lets you do something like: > > $where_cond = join(' AND ', @list_of_tests) That's not the case. Test may or may not be performed based on web form values. Mindaugas From pgsql-performance-owner@postgresql.org Wed Oct 1 10:22:12 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5CFE7D1B4E2 for ; Wed, 1 Oct 2003 13:22:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34683-02 for ; Wed, 1 Oct 2003 10:21:25 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id CBBBBD1B4E1 for ; Wed, 1 Oct 2003 10:21:17 -0300 (ADT) 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 h91DKFtN012191; Wed, 1 Oct 2003 07:20:16 -0600 (MDT) Date: Wed, 1 Oct 2003 07:14:32 -0600 (MDT) From: "scott.marlowe" To: Andrew Sullivan Cc: Subject: Re: inferior SCSI performance In-Reply-To: <20031001103338.GA29293@libertyrms.info> 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: 200310/15 X-Sequence-Number: 3763 On Wed, 1 Oct 2003, Andrew Sullivan wrote: > On Wed, Sep 17, 2003 at 04:46:00PM -0400, Michael Adler wrote: > > So the quesiton is whether it is ever sensible to use write-caching and > > expect comparable persistence. > > Yes. If and only if you have a battery-backed cache. I know of no > IDE drives that have that, but there's nothing about the spec which > makes it impossible. FYI, on a Dual PIV2800 with 2 gig ram and a single UDMA 80 gig hard drive, I from 420 tps to 22 tps when I disable write caching. WOW. A factor of about 20 times slower. (pgbench -c 4 -t 100) From pgsql-performance-owner@postgresql.org Wed Oct 1 10:29:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DF749D1B545 for ; Wed, 1 Oct 2003 13:29:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 35245-03 for ; Wed, 1 Oct 2003 10:29:12 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id C25A2D1B50B for ; Wed, 1 Oct 2003 10:29:08 -0300 (ADT) 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 h91DSptN012769; Wed, 1 Oct 2003 07:28:51 -0600 (MDT) Date: Wed, 1 Oct 2003 07:23:08 -0600 (MDT) From: "scott.marlowe" To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7604@postoffice.waterford.org> 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: 200310/17 X-Sequence-Number: 3765 On Tue, 30 Sep 2003, Oleg Lebedev wrote: > I continue struggling with the TPC-R benchmarks and wonder if anyone > could help me optimize the query below. ANALYZE statistics indicate that > the query should run relatively fast, but it takes hours to complete. I > attached the query plan to this posting. > Thanks. What are the differences between estimated and real rows and such of an explain analyze on that query? Are there any estimates that are just way off? From pgsql-performance-owner@postgresql.org Wed Oct 1 10:26:20 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 981AFD1B4E1 for ; Wed, 1 Oct 2003 13:26:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33796-10 for ; Wed, 1 Oct 2003 10:25:37 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 3A441D1B540 for ; Wed, 1 Oct 2003 10:25:33 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A4gz3-0004sz-00 for ; Wed, 01 Oct 2003 09:25:37 -0400 Received: by dba2 (Postfix, from userid 1019) id F3674CB29; Wed, 1 Oct 2003 09:25:36 -0400 (EDT) Date: Wed, 1 Oct 2003 09:25:36 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: inferior SCSI performance Message-ID: <20031001132536.GA30269@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20031001103338.GA29293@libertyrms.info> 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: 200310/16 X-Sequence-Number: 3764 On Wed, Oct 01, 2003 at 07:14:32AM -0600, scott.marlowe wrote: > FYI, on a Dual PIV2800 with 2 gig ram and a single UDMA 80 gig hard drive, > I from 420 tps to 22 tps when I disable write caching. WOW. A factor of > about 20 times slower. (pgbench -c 4 -t 100) That's completely consistent with tests Chris Browne has done here on cache-enabled and cache-disabled boxes that we have. It's a _really_ big difference. The combination of battery-backed write cache on your controller plus a real good UPS is quite possibly the number one thing you can do to improve performance. For what it's worth, I can't see how this is something special about Postgres: even raw-filesystem type systems have to make sure the disk actually has the data, and a write cache is bound to be a big help for that. 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 Oct 1 11:15:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED200D1B500 for ; Wed, 1 Oct 2003 14:15:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 36060-10 for ; Wed, 1 Oct 2003 11:14:54 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 5F644D1B52B for ; Wed, 1 Oct 2003 11:14:50 -0300 (ADT) 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 h91EER6c028833; Wed, 1 Oct 2003 10:14:27 -0400 (EDT) To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Tuning/performance issue... In-reply-to: <074601c387df$b5939270$6501a8c0@griffiths2> References: <057501c38790$d9b9aad0$6501a8c0@griffiths2> <25573.1064982530@sss.pgh.pa.us> <074601c387df$b5939270$6501a8c0@griffiths2> Comments: In-reply-to David Griffiths message dated "Tue, 30 Sep 2003 22:48:54 -0700" Date: Wed, 01 Oct 2003 10:14:26 -0400 Message-ID: <28832.1065017666@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/18 X-Sequence-Number: 3766 David Griffiths writes: >> The reason PG's planner doesn't discover this join order for itself >> is that it's written to not attempt to re-order outer joins from the >> syntactically defined ordering. In general, such reordering would >> change the results. It is possible to analyze the query and prove that >> certain reorderings are valid (don't change the results), but we don't >> currently have code to do that. > Not sure I follow. Are you saying that, depending on when the outer-join is > applied to the rows found at the time, you may end up with a different set > of rows? Here's an example showing that it's not always safe to rearrange join order in the presence of outer joins: jtest=# create table a (f1 int); CREATE TABLE jtest=# create table b (f1 int, f2 int); CREATE TABLE jtest=# create table c(f1 int, f2 int); CREATE TABLE jtest=# insert into a values (1); INSERT 431307 1 jtest=# insert into b values (10,10); INSERT 431308 1 jtest=# insert into b values (11,11); INSERT 431309 1 jtest=# insert into c values (1,10); INSERT 431310 1 jtest=# insert into c values (2,11); INSERT 431311 1 jtest=# SELECT * FROM a, b LEFT JOIN c ON b.f2 = c.f2 WHERE a.f1 = c.f1; f1 | f1 | f2 | f1 | f2 ----+----+----+----+---- 1 | 10 | 10 | 1 | 10 (1 row) Per spec the JOIN operator binds more tightly than comma, so this is equivalent to: jtest=# SELECT * FROM a JOIN (b LEFT JOIN c ON b.f2 = c.f2) ON a.f1 = c.f1; f1 | f1 | f2 | f1 | f2 ----+----+----+----+---- 1 | 10 | 10 | 1 | 10 (1 row) Now suppose we try to join A and C before joining to B: jtest=# SELECT * FROM b LEFT JOIN (a join c ON a.f1 = c.f1) ON b.f2 = c.f2; f1 | f2 | f1 | f1 | f2 ----+----+----+----+---- 10 | 10 | 1 | 1 | 10 11 | 11 | | | (2 rows) We get a different answer, because some C rows are eliminated before reaching the left join, causing null-extended B rows to be added. (I don't have a MySQL installation here to try, but if they still work the way they used to, they get the wrong answer on the first query.) The point of this example is just that there are cases where it'd be incorrect for the planner to change the ordering of joins from what is implied by the query syntax. It is always safe to change the join order when only inner joins are involved. There are cases where outer join order is safe to change too, but you need analysis code that checks the query conditions to prove that a particular rearrangement is safe. Right now, we don't have such code, and so we just follow the simple rule "never rearrange any outer joins". > I would have expected the optimizer to do the outer-joins last, as the > extra data received by the outer-joins is not mandatory, and won't > affect the rows that were retreived by joining user_account, > address_list, and commercial_entity. I think your example falls into the category of provably-safe rearrangements ... but as I said, the planner doesn't know that. > An outer join would *never* be the most restrictive > join in a query. Sure it can, if the restriction conditions are mainly on the outer join's tables. But that's not really the issue here. As best I can tell without seeing your data statistics, the most restrictive conditions in your query are the ones on commercial_entity.commercial_entity_id and user_account.user_role_id. The trick is to apply those before joining any other tables. regards, tom lane From pgsql-novice-owner@postgresql.org Wed Oct 1 12:14:08 2003 X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 72FE5D1B543 for ; Wed, 1 Oct 2003 15:14:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 49200-10 for ; Wed, 1 Oct 2003 12:13:17 -0300 (ADT) Received: from chimta03.algx.net (mta8.algx.net [67.92.168.237]) by svr1.postgresql.org (Postfix) with ESMTP id 645E6D1B50B for ; Wed, 1 Oct 2003 12:13:17 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx03.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HM300GWU3M318@chimmx03.algx.net> for pgsql-novice@postgresql.org; Wed, 01 Oct 2003 10:13:16 -0500 (CDT) Date: Wed, 01 Oct 2003 11:13:15 -0400 From: Jason Hihn Subject: Ideal Hardware? To: "Pgsql-Novice@Postgresql. Org" Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/12 X-Sequence-Number: 8449 We have an opportunity to purchase a new, top-notch database server. I am wondering what kind of hardware is recommended? We're on Linux platforms and kernels though. I remember a comment from Tom about how he was spending a lot of time debugging problems which turned out to be hardware-related. I of course would like to avoid that. In terms of numbers, we expect have an average of 100 active connections (most of which are idle 9/10ths of the time), with about 85% reading traffic. I expect the database with flow average 10-20kBps under moderate load. I hope to have one server host about 1000-2000 active databases, with the largest being about 60 meg (no blobs). Inactive databases will only be for reading (archival) purposes, and will seldom be accessed. Does any of this represent a problem for Postgres? The datasets are typically not that large, only a few queries on a few databases ever return over 1000 rows. I'm worried about being able to handle the times when there will be spikes in the traffic. The configuration that is going on in my head is: RAID 1, 200gig 1 server, 4g ram Linux 2.6 I was also wondering about storage units (IBM FAStT200) with giga-bit Ethernet to rack mount computer(s)... But would I need more than 1 CPU? If I did, how would I handle the file system? We only do a few joins, so I think most of it would be I/O latency. Thanks! Jason Hihn Paytime Payroll From pgsql-performance-owner@postgresql.org Wed Oct 1 13:15:06 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 930AAD1B4F2 for ; Wed, 1 Oct 2003 16:15:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 69638-05 for ; Wed, 1 Oct 2003 13:14:17 -0300 (ADT) Received: from travelers.mail.cornell.edu (travelers.mail.cornell.edu [132.236.56.13]) by svr1.postgresql.org (Postfix) with ESMTP id 2C105D1B4F1 for ; Wed, 1 Oct 2003 13:14:16 -0300 (ADT) Received: from travelers.mail.cornell.edu (travelers.mail.cornell.edu [132.236.56.13]) by travelers.mail.cornell.edu (8.9.3p2/8.9.3) with SMTP id MAA12504; Wed, 1 Oct 2003 12:14:13 -0400 (EDT) Date: Wed, 1 Oct 2003 12:14:13 -0400 (EDT) From: apb18@cornell.edu X-Sender: apb18@travelers.mail.cornell.edu To: pgsql-performance@postgreSQL.org Subject: Joins on inherited tables Message-ID: 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=1.7 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS, NO_REAL_NAME, USER_AGENT_PINE X-Spam-Level: * X-Archive-Number: 200310/19 X-Sequence-Number: 3767 Hi, In some situations, it looks like the optimizer does not chose efficient paths for joining inherited tables. For I created a rather trivial formulation to serve as an example. I created the table 'numbers' comprising of the columns id (int) and value (text). I also created the table 'evens' and 'odds' that inherit numbers, with no additional columns. Into 'evens' I placed 50000 entries, each one with an even (unique) id and random 'value'. Likewise, for 'odds', I created 50000 odd (and unique) id fields id fields and random 'value', and created index on all ID fields of every table that has any rows (and analyzed). so.. my tables look like this: Table "public.numbers" Column | Type | Modifiers --------+---------+----------- id | integer | value | text | Table "public.evens" Column | Type | Modifiers --------+---------+----------- id | integer | value | text | Indexes: "ei" btree (id) Inherits: numbers Table "public.odds" Column | Type | Modifiers --------+---------+----------- id | integer | value | text | Indexes: "oi" btree (id) Inherits: numbers As per the above construction, 'evens' and 'odds' both have 50000 rows. 'numbers' contains none. Now, I created a trivial query that would use 'numbers' as an inheritor table in a join (a very stupid one, but a join nevertheless) as follows, which produces a terrible, but correct, plan: select value from (SELECT 1::integer as id) as ids JOIN numbers on (numbers.id = ids.id); QUERY PLAN --------------------------------------------------------------------------- Hash Join (cost=0.02..2195.79 rows=501 width=19) Hash Cond: ("outer".id = "inner".id) -> Append (cost=0.00..1690.50 rows=100051 width=23) -> Seq Scan on numbers (cost=0.00..0.00 rows=1 width=23) -> Seq Scan on evens numbers (cost=0.00..845.25 rows=50025 width=23) -> Seq Scan on odds numbers (cost=0.00..845.25 rows=50025 width=23) -> Hash (cost=0.02..0.02 rows=1 width=4) -> Subquery Scan ids (cost=0.00..0.02 rows=1 width=4) -> Result (cost=0.00..0.01 rows=1 width=0) Now, I subsitute 'evens' for 'numbers', so I am now joining with a normal, non-inherited table. The plan is much better: select value from (SELECT 1::integer as id) as ids JOIN evens on (evens.id = ids.id); QUERY PLAN ----------------------------------------------------------------------- Nested Loop (cost=0.00..3.05 rows=2 width=19) -> Subquery Scan ids (cost=0.00..0.02 rows=1 width=4) -> Result (cost=0.00..0.01 rows=1 width=0) -> Index Scan using ei on evens (cost=0.00..3.01 rows=1 width=23) Index Cond: (evens.id = "outer".id) I would think that the ideal plan for the first query should be a nested loop like the second that considers indexes where possible, and it would look as follows: HYPOTHETICAL PLAN ------------------------------------------------------------------------ Nested Loop -> Subquery Scan ids -> Result -> Append -> Seq Scan on numbers -> Index Scan using ei on evens Index Cond: (evens.id = "outer.id") -> Index Scan using oi on odds Index Cond: (odds.id = "outer.id") So.. Why wouldn't postgres use such a plan? I could think of three reasons: - The planner wasn't considering this plan due to some fault of its own - That plan makes no sense and would not be able to be run in the executor, and therefore it would be wasteful to consider it. - It truly is more expensive than a hash join I've pretty much ruled out the third and I suspect the second is also untrue (though have not proven that to myself), leaving the first. If it is indeed the second, that the plan makes no sense, someone please let me know! OK, so I took a look into the optimizer and over time got a better understanding of what's going on, though I still don't understand it completely. Here's my theory as to what's happening: For this query, most of the path consideration takes place in match_unsorted_outer() in path/joinpath.c. For the 'good' query against the non-inherited 'evens' table, the good plan is generated in the line: bestinnerjoin = best_inner_indexscan(...); Since an inherited table doesn't have one single index over all its inherited tables, this call produces a null bestinnerjoin. Later on in match_unsorted_inner(), various access paths are considered for a nested loop. One is bestinnerjoin (when it exists), and that is how the 'good' query gets its nested loop with an index scan. Other paths considered for inclusion in the nested loop are 'inner_cheapest_total' and 'inner_cheapest_startup'; These plans, presumably, contain sequential scans, which are expensive enough in the nested loop that the nested loop plan is suboptimal compared to a hash join, which is what happens in the 'bad' query that joins against the inheritor table. Now, it seems to me as if the solution would be one of the following: - create a new bestinnerjoin plan when best_inner_indexscan returned null, yet the current relation is an inheritor. This bestinnerjoin plan will use the optimal Append plan that comprises of the optimal plans for the inherited tables that are relevant for the joins (as in the case of the hypothetical query above where the append consists of a number of index and sequential scans) - Consider the optimal Append path relevant to the join later on when considering paths for use in a nested loop. i.e. inner_cheapest_total or inner_cheapest_startup will have to be this good append plan. For 2, the problem seems to be that in creating the inner_cheapest_total, joininfo nodes for each child relation do not exist. I experimented by just copying the parents joininfo nodes to each child, and it looked like it was considering index scans somewhere along the line, but the final plan chosen did not use index scans. I didn't see where it failed. I'm kinda skeptical of 3 anyway, because the inner_cheapest_total in the 'good' query with out inheritance does not appear to involve index scans at all. So.. does anybody have any advice? Am I totally off base with my assertions that a better plan can exist when joining inherited tables? Does my analysis of the problem and possible solutions in the optimizer make any sense? I basically pored over the source code, read the documentation, and did little tests here and there to arrive at my conclusions, but cannot claim to have a good global view of how everything works. Thanks very much -Aaron From pgsql-performance-owner@postgresql.org Wed Oct 1 14:20:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7B7FDD1B4F2 for ; Wed, 1 Oct 2003 17:20:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82685-04 for ; Wed, 1 Oct 2003 14:20:03 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 842F0D1B537 for ; Wed, 1 Oct 2003 14:19:13 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h91HJDQh057723 for ; Wed, 1 Oct 2003 17:19:13 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h91HA11r056646 for pgsql-performance@postgresql.org; Wed, 1 Oct 2003 17:10:01 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: inferior SCSI performance Date: Wed, 01 Oct 2003 12:21:53 -0400 Organization: Hub.Org Networking Services Lines: 50 Message-ID: <60brt1szby.fsf@dev6.int.libertyrms.info> References: <20031001103338.GA29293@libertyrms.info> <20031001132536.GA30269@libertyrms.info> 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 (Rational FORTRAN, linux) Cancel-Lock: sha1:bUE3mqLO62jxXEix1280L1wMp2M= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/24 X-Sequence-Number: 3772 andrew@libertyrms.info (Andrew Sullivan) writes: > On Wed, Oct 01, 2003 at 07:14:32AM -0600, scott.marlowe wrote: >> FYI, on a Dual PIV2800 with 2 gig ram and a single UDMA 80 gig hard drive, >> I from 420 tps to 22 tps when I disable write caching. WOW. A factor of >> about 20 times slower. (pgbench -c 4 -t 100) > > That's completely consistent with tests Chris Browne has done here on > cache-enabled and cache-disabled boxes that we have. > > It's a _really_ big difference. The combination of battery-backed > write cache on your controller plus a real good UPS is quite possibly > the number one thing you can do to improve performance. For what > it's worth, I can't see how this is something special about Postgres: > even raw-filesystem type systems have to make sure the disk actually > has the data, and a write cache is bound to be a big help for that. Indeed. When I ran the tests, I found that JFS was preferable to XFS and ext3 on Linux on the machine with the big battery backed cache. (And the side-effect that it was getting yes, probably about 20x the performance of systems without the cache.) The FS-related result appeared surprising, as the "stories" I had heard suggested that JFS hadn't been particularly heavily tuned on Linux, whereas XFS was supposed to be the "speed demon." It is entirely possible that the result I saw was one that would reverse partially or even totally on a system LACKING that cache. XFS might "play better" when we're cacheless; the (perhaps only fabled) demerits of JFS being more than totally hidden if we add the cache. What I find disappointing is that it isn't possible to get SSD cards that are relatively inexpensive. A similarly fabulous performance increase _ought_ to be attainable if you could stick pg_xlog and pg_clog on a 256MB (or bigger!) battery-backed SSD, ideally one that plugs into a PCI slot. This should have the further benefit of diminishing the amount of mechanical activity going on, as WAL activity would no longer involve ANY i/o operations. Unfortunately, while there are companies hawking SSDs, they are in the "you'll have to talk to our salescritter for pricing" category, which means that they must be ferociously expensive. :-(. -- output = ("cbbrowne" "@" "libertyrms.info") Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Wed Oct 1 13:54:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B602AD1B4E1 for ; Wed, 1 Oct 2003 16:54:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73338-06 for ; Wed, 1 Oct 2003 13:53:13 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id 1EAFAD1B509 for ; Wed, 1 Oct 2003 13:53:11 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Wed, 1 Oct 2003 10:51:54 -0600 From: Oleg Lebedev To: Jeff Cc: "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... Date: Wed, 1 Oct 2003 10:51:52 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7614@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/20 X-Sequence-Number: 3768 Jeff, I would really appreciate if you could send me that lengthy presentation that you've written on pg/other dbs comparison. Thanks. Oleg -----Original Message----- From: Jeff [mailto:threshar@torgo.978.org]=20 Sent: Wednesday, October 01, 2003 6:23 AM To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Tuning/performance issue... Importance: Low On Tue, 30 Sep 2003, David Griffiths wrote: > > This is all part of a "migrate away from Oracle" project. We are=20 > looking at 3 databases - MySQL (InnoDB), Postgres and Matisse (object=20 > oriented). We have alot of queries like this > or worse, and I'm worried that many of them would need to be re-written. The > developers > know SQL, but nothing about tuning, etc. > There's a movement at my company to ditch several commercial db's in favor of a free one. I'm currently the big pg fan around here and I've actually written a rather lengthy presentation about pg features, why, tuning, etc. but another part was some comparisons to other db's.. I decided so I wouldn't be blinding flaming mysql to give it a whirl and loaded it up with the same dataset as pg. First thing I hit was lack of stored procedures. But I decided to code around that, giving mysql the benefit of the doubt. What I found was interesting. For 1-2 concurrent 'beaters' it screamed. ultra-fast. But.. If you increase the concurrent beaters up to say, 20 Mysql comes to a grinding halt.. Mysql and the machine itself become fairly unresponsive. And if you do cache unfriendly queries it becomes even worse. On PG - no problems at all. Scaled fine and dandy up. And with 40 concurrent beaters the machine was still responsive. (The numbers for 20 client was 220 seconds (pg) and 650 seconds (mysql)) So that is another test to try out - Given your configuration I expect you have lots of concurrent activity. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Wed Oct 1 13:56:45 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DDA25D1B547 for ; Wed, 1 Oct 2003 16:56:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73430-05 for ; Wed, 1 Oct 2003 13:55:55 -0300 (ADT) Received: from web80215.mail.yahoo.com (web80215.mail.yahoo.com [66.218.79.50]) by svr1.postgresql.org (Postfix) with SMTP id 2596ED1B4FF for ; Wed, 1 Oct 2003 13:55:54 -0300 (ADT) Message-ID: <20031001165553.22593.qmail@web80215.mail.yahoo.com> Received: from [199.217.234.6] by web80215.mail.yahoo.com via HTTP; Wed, 01 Oct 2003 09:55:53 PDT Date: Wed, 1 Oct 2003 09:55:53 -0700 (PDT) From: George Essig Subject: Re: TPC-R benchmarks To: Tom Lane Cc: Oleg Lebedev , Mary Edie Meredith , Jenny Zhang , pgsql-performance MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/21 X-Sequence-Number: 3769 Tom Lane wrote: > When benchmarking with data sets considerably larger than available > buffer cache, I rather doubt that small random_page_cost would be a > good idea. Still, you might as well experiment to see. From experience, I know the difference in response time can be huge when postgres incorrectly chooses a sequential scan over an index scan. In practice, do people experience as great a difference when postgres incorrectly chooses an index scan over a sequential scan? My intuition is that the speed difference is a lot less for incorrectly choosing an index scan. If this is the case, it would be safer to chose a small value for random_page_cost. George Essig From pgsql-performance-owner@postgresql.org Wed Oct 1 14:10:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B5131D1B54A for ; Wed, 1 Oct 2003 17:10:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81044-05 for ; Wed, 1 Oct 2003 14:10:00 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 8BE64D1B51A for ; Wed, 1 Oct 2003 14:09:59 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3703584; Wed, 01 Oct 2003 10:10:22 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 10:08:50 -0700 User-Agent: KMail/1.4.3 References: <993DBE5B4D02194382EC8DF8554A52731D7604@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7604@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310011008.50491.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/22 X-Sequence-Number: 3770 Oleg, > I continue struggling with the TPC-R benchmarks and wonder if anyone > could help me optimize the query below. ANALYZE statistics indicate that > the query should run relatively fast, but it takes hours to complete. I > attached the query plan to this posting. Even though it takes hours to complete, I think we need you to run EXPLAIN ANALYZE instead of just EXPLAIN. Without the real-time statistics, we simply can't see what's slowing the query down. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 1 14:15:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 18C16D1B573 for ; Wed, 1 Oct 2003 17:15:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81588-06 for ; Wed, 1 Oct 2003 14:14:25 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B9C1FD1B510 for ; Wed, 1 Oct 2003 14:14:23 -0300 (ADT) 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 h91HEL6c000865; Wed, 1 Oct 2003 13:14:21 -0400 (EDT) To: apb18@cornell.edu Cc: pgsql-performance@postgresql.org Subject: Re: Joins on inherited tables In-reply-to: References: Comments: In-reply-to apb18@cornell.edu message dated "Wed, 01 Oct 2003 12:14:13 -0400" Date: Wed, 01 Oct 2003 13:14:21 -0400 Message-ID: <864.1065028461@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, IN_REP_TO, MAILTO_TO_SPAM_ADDR, RCVD_IN_OSIRUSOFT_COM, REFERENCES, REPLY_WITH_QUOTES X-Spam-Level: X-Archive-Number: 200310/23 X-Sequence-Number: 3771 apb18@cornell.edu writes: > So.. does anybody have any advice? Look at set_inherited_rel_pathlist() in allpaths.c --- it forms the best plan for fully scanning the inheritance-tree table. Currently that's the *only* plan considered, and it does not make any use of join clauses. It's possible that something could be done with providing a similar routine for best inner indexscans taken across the whole inheritance tree. You'd have to figure out how to locate the applicable joinclauses though. I think they'd be attached to the inheritance-tree parent relation and not to the individual inheritance tree member relations. Also, if you are wondering why best_inner_indexscan() is so tense about caching its results, that's because it gets called *a lot* in large join problems. If you don't achieve a similar level of efficiency then you'll be seeing some nasty performance problems in larger queries. I think you'd find there is executor work to do as well; I'm not sure how the outer-relation values would get propagated down into the indexscans when there's an Append node between. Maybe the existing code would Just Work, but I bet not. Not sure if this will help you, but: Once upon a time the planner did the APPEND for an inheritance tree at the top of the plan not the bottom. (It still does when the tree is the target of an update/delete query.) In 7.0 for example I get a plan like this: create table pt (f1 int primary key); create table ct1 (f2 int) inherits (pt); create table ct2 (f2 int) inherits (pt); create index ct1i on ct1(f1); create table bar(f1 int); explain select * from pt*, bar where pt.f1 = bar.f1; NOTICE: QUERY PLAN: Append (cost=69.83..474.33 rows=30000 width=8) -> Merge Join (cost=69.83..154.83 rows=10000 width=8) -> Index Scan using pt_pkey on pt (cost=0.00..60.00 rows=1000 width=4) -> Sort (cost=69.83..69.83 rows=1000 width=4) -> Seq Scan on bar (cost=0.00..20.00 rows=1000 width=4) -> Merge Join (cost=69.83..154.83 rows=10000 width=8) -> Index Scan using ct1i on ct1 pt (cost=0.00..60.00 rows=1000 width=4) -> Sort (cost=69.83..69.83 rows=1000 width=4) -> Seq Scan on bar (cost=0.00..20.00 rows=1000 width=4) -> Merge Join (cost=139.66..164.66 rows=10000 width=8) -> Sort (cost=69.83..69.83 rows=1000 width=4) -> Seq Scan on bar (cost=0.00..20.00 rows=1000 width=4) -> Sort (cost=69.83..69.83 rows=1000 width=4) -> Seq Scan on ct2 pt (cost=0.00..20.00 rows=1000 width=4) whereas the same test in CVS tip produces QUERY PLAN ---------------------------------------------------------------------------- Merge Join (cost=303.09..353.09 rows=3000 width=8) Merge Cond: ("outer".f1 = "inner".f1) -> Sort (cost=69.83..72.33 rows=1000 width=4) Sort Key: bar.f1 -> Seq Scan on bar (cost=0.00..20.00 rows=1000 width=4) -> Sort (cost=233.26..240.76 rows=3000 width=4) Sort Key: public.pt.f1 -> Append (cost=0.00..60.00 rows=3000 width=4) -> Seq Scan on pt (cost=0.00..20.00 rows=1000 width=4) -> Seq Scan on ct1 pt (cost=0.00..20.00 rows=1000 width=4) -> Seq Scan on ct2 pt (cost=0.00..20.00 rows=1000 width=4) The fact that 7.0 could actually adapt to different index sets for different child tables was kinda cool, but the append-at-the-top strategy failed completely for outer joins, so we had to abandon it. In practice I think the generated plan was usually worse anyway (note that bar gets scanned three times in 7.0's plan), but for the specific case where the inheritance tree is on the inside of a nestloop that could be indexed, the new approach is not as good. If you can come up with a fix that doesn't break things in other respects, it'd be great. [digs in CVS logs] The patch that altered the APPEND-at-the-top behavior was this one: 2000-11-11 19:36 tgl * src/: backend/commands/command.c, backend/commands/copy.c, backend/commands/explain.c, backend/executor/execMain.c, backend/executor/execQual.c, backend/executor/execTuples.c, backend/executor/execUtils.c, backend/executor/functions.c, backend/executor/nodeAppend.c, backend/executor/nodeSeqscan.c, backend/nodes/copyfuncs.c, backend/nodes/equalfuncs.c, backend/nodes/outfuncs.c, backend/nodes/readfuncs.c, backend/optimizer/path/allpaths.c, backend/optimizer/path/pathkeys.c, backend/optimizer/plan/createplan.c, backend/optimizer/plan/planmain.c, backend/optimizer/plan/planner.c, backend/optimizer/prep/prepunion.c, backend/optimizer/util/pathnode.c, backend/optimizer/util/relnode.c, backend/parser/parse_clause.c, backend/tcop/pquery.c, include/catalog/catversion.h, include/executor/executor.h, include/executor/tuptable.h, include/nodes/execnodes.h, include/nodes/nodes.h, include/nodes/parsenodes.h, include/nodes/plannodes.h, include/nodes/relation.h, include/optimizer/pathnode.h, include/optimizer/planmain.h, include/optimizer/planner.h, include/optimizer/prep.h, backend/optimizer/README: Restructure handling of inheritance queries so that they work with outer joins, and clean things up a good deal at the same time. Append plan node no longer hacks on rangetable at runtime --- instead, all child tables are given their own RT entries during planning. Concept of multiple target tables pushed up into execMain, replacing bug-prone implementation within nodeAppend. Planner now supports generating Append plans for inheritance sets either at the top of the plan (the old way) or at the bottom. Expanding at the bottom is appropriate for tables used as sources, since they may appear inside an outer join; but we must still expand at the top when the target of an UPDATE or DELETE is an inheritance set, because we actually need a different targetlist and junkfilter for each target table in that case. Fortunately a target table can't be inside an outer join... Bizarre mutual recursion between union_planner and prepunion.c is gone --- in fact, union_planner doesn't really have much to do with union queries anymore, so I renamed it grouping_planner. Not sure if studying that diff would teach you anything useful, but there it is... regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 1 14:31:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4CBDCD1B550 for ; Wed, 1 Oct 2003 17:31:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82540-10 for ; Wed, 1 Oct 2003 14:30:41 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0D0D1D1B500 for ; Wed, 1 Oct 2003 14:30:39 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Wed, 1 Oct 2003 11:29:22 -0600 From: Oleg Lebedev To: "scott.marlowe" Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 11:29:21 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7615@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/25 X-Sequence-Number: 3773 The output of the query should contain about 200 rows. So, I guess the planer is off assuming that the query should return 1 row. I will start EXPLAIN ANALYZE now. Thanks. Oleg -----Original Message----- From: scott.marlowe [mailto:scott.marlowe@ihs.com]=20 Sent: Wednesday, October 01, 2003 7:23 AM To: Oleg Lebedev Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks On Tue, 30 Sep 2003, Oleg Lebedev wrote: > I continue struggling with the TPC-R benchmarks and wonder if anyone=20 > could help me optimize the query below. ANALYZE statistics indicate=20 > that the query should run relatively fast, but it takes hours to=20 > complete. I attached the query plan to this posting. Thanks. What are the differences between estimated and real rows and such of an=20 explain analyze on that query? Are there any estimates that are just way=20 off? ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Wed Oct 1 14:31:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A9405D1B500 for ; Wed, 1 Oct 2003 17:31:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82389-09 for ; Wed, 1 Oct 2003 14:30:48 -0300 (ADT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 205E7D1B4EF for ; Wed, 1 Oct 2003 14:30:47 -0300 (ADT) Received: (qmail 13938 invoked by uid 0); 1 Oct 2003 17:30:47 -0000 Received: from 212.202.242.130 by www60.gmx.net with HTTP; Wed, 1 Oct 2003 19:30:47 +0200 (MEST) Date: Wed, 1 Oct 2003 19:30:47 +0200 (MEST) From: "Dimitri Nagiev" To: pgsql-performance@postgresql.org MIME-Version: 1.0 Subject: Optimizing >= and <= for numbers and dates X-Priority: 3 (Normal) X-Authenticated: #19654632 Message-ID: <24741.1065029447@www60.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 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.9 tagged_above=0.0 required=5.0 tests=RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/26 X-Sequence-Number: 3774 Hi all, I haven't found any official documentation about the postgres sql optimizer on the web, so please forgive me if there is such a document and point me to the right direction. I've got the following problem: I cannot make the postgres SQL Optimizer use an index on a date field to filter out a date range, e.g. select * from mytable where mydate >= '2003-10-01'; Seq Scan on mytable (cost=0.00..2138.11 rows=12203 width=543) Filter: (mydate >= '2003-09-01'::date) the index is created as follows: create index query on mytable(mydate); Testing for equality gives me the index optimization: select * from mytable where mydate = '2003-10-01'; Index Scan using query on mytable (cost=0.00..54.93 rows=44 width=543) Index Cond: (mydate = '2003-09-01'::date) I have run vacuum analyze on the table. Also the table contains 25.000 records, so the index should be used in my opinion. Am I missing something ? The same seems to apply to integers. Thank you very much in advance Dimi PS The postgres version is as follows: PostgreSQL 7.3.2 on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.2.2 20030213 (Red Hat Linux 8.0 3.2.2-1) -- NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse f�r Mail, Message, More! +++ From pgsql-performance-owner@postgresql.org Wed Oct 1 14:38:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C54D5D1B54F for ; Wed, 1 Oct 2003 17:38:10 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 84484-02 for ; Wed, 1 Oct 2003 14:37:24 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 5DDCBD1B4E5 for ; Wed, 1 Oct 2003 14:37:23 -0300 (ADT) Received: (qmail 19823 invoked from network); 1 Oct 2003 17:37:38 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 1 Oct 2003 17:37:38 -0000 Subject: Re: Optimizing >= and <= for numbers and dates From: Rod Taylor To: Dimitri Nagiev Cc: Postgresql Performance In-Reply-To: <24741.1065029447@www60.gmx.net> References: <24741.1065029447@www60.gmx.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-zuPSl545AakUU0rt42yb" Message-Id: <1065029881.85344.138.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 01 Oct 2003 13:38:02 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/27 X-Sequence-Number: 3775 --=-zuPSl545AakUU0rt42yb Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-10-01 at 13:30, Dimitri Nagiev wrote: > Hi all, >=20 > I haven't found any official documentation about the postgres sql optimiz= er > on the web, so please forgive me if there is such a document and point me= to > the right direction. >=20 > I've got the following problem: I cannot make the postgres SQL Optimizer = use > an index on a date field to filter out a date range, e.g. >=20 > select * from mytable where mydate >=3D '2003-10-01'; >=20 > Seq Scan on mytable (cost=3D0.00..2138.11 rows=3D12203 width=3D543) > Filter: (mydate >=3D '2003-09-01'::date) EXPLAIN ANALYZE output please. --=-zuPSl545AakUU0rt42yb Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/exD56DETLow6vwwRArBBAJ9+A8EnmV4yp6jFzlHa95G4jsVDpgCeKxxv tD2P2Io1t7eEU47WUtjPVfw= =xbyL -----END PGP SIGNATURE----- --=-zuPSl545AakUU0rt42yb-- From pgsql-novice-owner@postgresql.org Wed Oct 1 14:44:21 2003 X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3B6F3D1B51A; Wed, 1 Oct 2003 17:44:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 84630-05; Wed, 1 Oct 2003 14:43:33 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9ABA1D1B4F1; Wed, 1 Oct 2003 14:43:31 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3703708; Wed, 01 Oct 2003 10:40:24 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jason Hihn , "Pgsql-Novice@Postgresql. Org" Subject: Re: Ideal Hardware? Date: Wed, 1 Oct 2003 10:38:53 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310011038.53024.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/14 X-Sequence-Number: 8451 Jason, Your question is really suited to the PERFORMANCE list, not NOVICE, so I have cross-posted it there. I reccomend that you subscribe to performance, and drop novice from your replies. There are lots of hardware geeks on performance, but few on novice. > We have an opportunity to purchase a new, top-notch database server. I am > wondering what kind of hardware is recommended? We're on Linux platforms > and kernels though. I remember a comment from Tom about how he was spending > a lot of time debugging problems which turned out to be hardware-related. I > of course would like to avoid that. > > In terms of numbers, we expect have an average of 100 active connections > (most of which are idle 9/10ths of the time), with about 85% reading > traffic. I expect the database with flow average 10-20kBps under moderate > load. I hope to have one server host about 1000-2000 active databases, with > the largest being about 60 meg (no blobs). Inactive databases will only be > for reading (archival) purposes, and will seldom be accessed. Is that 100 concurrent connections *total*, or per-database? If the connections are idle 90% of the time, then are they open, or do they get re-established with each query? Have you considered connection pooling for the read-only queries? > Does any of this represent a problem for Postgres? The datasets are > typically not that large, only a few queries on a few databases ever return > over 1000 rows. I'm worried about being able to handle the times when there > will be spikes in the traffic. It's all possible, it just requires careful application design and lots of hardware. You should also cost things out; sometimes it's cheaper to have several good servers instead of one uber-server. The latter also helps with hardware replacement. > The configuration that is going on in my head is: > RAID 1, 200gig RAID 1+0 can be good for Postgres. However, if you have a budget, RAID 5 with 6 or more disks can be better some of the time, particularly when read queries are the vast majority of the load. There are, as yet, no difinitive statistics, but OSDL is working on it! More important than the RAID config is the RAID card; once again, with money, multi-channel RAID cards with a battery-backed write cache are your best bet; some cards even allow you to span RAID1 between cards of the same model. See the discussion about LSI MegaRaid in the PERFORMANCE list archives over the last 2 weeks. > 1 server, 4g ram > Linux 2.6 You're very brave. Me, I'm not adopting 2.6 in production until 2.6.03 is out, at least. > I was also wondering about storage units (IBM FAStT200) with giga-bit > Ethernet to rack mount computer(s)... But would I need more than 1 CPU? If > I did, how would I handle the file system? We only do a few joins, so I > think most of it would be I/O latency. PostgreSQL will make use of multiple processors. If you are worried about peak time loads, having 2-4 processors to distribute queries across would be very useful. Also, I'm concerned about the "we only do a few joins". What that says to me is "we don't really know how to write complex queries, so we pull a lot of redundant data." Simple queries can be far less efficient than complex ones if they result in you pulling entire tables across to the client. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 1 14:47:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A18F3D1B4E1 for ; Wed, 1 Oct 2003 17:47:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85702-02 for ; Wed, 1 Oct 2003 14:46:53 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 97A41D1B500 for ; Wed, 1 Oct 2003 14:46:52 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3703721; Wed, 01 Oct 2003 10:43:31 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "scott.marlowe" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 10:41:59 -0700 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" References: <993DBE5B4D02194382EC8DF8554A52731D7615@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7615@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310011041.59348.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/32 X-Sequence-Number: 3780 Oleg, > The output of the query should contain about 200 rows. So, I guess the > planer is off assuming that the query should return 1 row. Oh, also did you post the query before? Can you re-post it with the planner results? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 1 14:42:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C5382D1B4E1 for ; Wed, 1 Oct 2003 17:42:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85173-02 for ; Wed, 1 Oct 2003 14:42:13 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 6E8AED1B549 for ; Wed, 1 Oct 2003 14:42:10 -0300 (ADT) Received: (qmail 24380 invoked from network); 1 Oct 2003 17:42:15 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 1 Oct 2003 17:42:15 -0000 Date: Wed, 1 Oct 2003 13:42:15 -0400 (EDT) From: Jeff To: Oleg Lebedev Cc: "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7614@postoffice.waterford.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: 200310/28 X-Sequence-Number: 3776 On Wed, 1 Oct 2003, Oleg Lebedev wrote: > Jeff, > I would really appreciate if you could send me that lengthy presentation > that you've written on pg/other dbs comparison. > Thanks. > After I give the presentation at work and collect comments from my coworkers (and remove some information you folks don't need to know :) I will be very willing to post it for people to see. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 1 14:45:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2D91ED1B502 for ; Wed, 1 Oct 2003 17:45:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83290-10 for ; Wed, 1 Oct 2003 14:44:26 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id E27AED1B4E5 for ; Wed, 1 Oct 2003 14:44:24 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Wed, 1 Oct 2003 11:43:12 -0600 From: Oleg Lebedev To: Jeff Cc: "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... Date: Wed, 1 Oct 2003 11:43:12 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7616@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/30 X-Sequence-Number: 3778 That would be great! When do you think this would be ready for us to see ;?) -----Original Message----- From: Jeff [mailto:threshar@torgo.978.org]=20 Sent: Wednesday, October 01, 2003 11:42 AM To: Oleg Lebedev Cc: pgsql-performance@postgresql.org Subject: RE: [PERFORM] Tuning/performance issue... On Wed, 1 Oct 2003, Oleg Lebedev wrote: > Jeff, > I would really appreciate if you could send me that lengthy=20 > presentation that you've written on pg/other dbs comparison. Thanks. > After I give the presentation at work and collect comments from my coworkers (and remove some information you folks don't need to know :) I will be very willing to post it for people to see. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Wed Oct 1 14:46:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8064CD1B55C for ; Wed, 1 Oct 2003 17:46:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85951-01 for ; Wed, 1 Oct 2003 14:45:30 -0300 (ADT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 02414D1B503 for ; Wed, 1 Oct 2003 14:45:29 -0300 (ADT) Received: (qmail 10891 invoked by uid 0); 1 Oct 2003 17:45:29 -0000 Received: from 212.202.242.130 by www60.gmx.net with HTTP; Wed, 1 Oct 2003 19:45:29 +0200 (MEST) Date: Wed, 1 Oct 2003 19:45:29 +0200 (MEST) From: "Dimitri Nagiev" To: pgsql-performance@postgresql.org MIME-Version: 1.0 References: <1065029881.85344.138.camel@jester> Subject: Re: Optimizing >= and <= for numbers and dates X-Priority: 3 (Normal) X-Authenticated: #19654632 Message-ID: <3603.1065030329@www60.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 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.5 tagged_above=0.0 required=5.0 tests=QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, REFERENCES X-Spam-Level: X-Archive-Number: 200310/31 X-Sequence-Number: 3779 here goes the EXPLAIN ANALYZE output: template1=# VACUUM analyze mytable; VACUUM template1=# explain analyze select * from mytable where mydate>='2003-09-01'; QUERY PLAN --------------------------------------------------------------------------------------------------------------- Seq Scan on mytable (cost=0.00..2209.11 rows=22274 width=562) (actual time=0.06..267.30 rows=22677 loops=1) Filter: (mydate >= '2003-09-01'::date) Total runtime: 307.71 msec (3 rows) template1=# explain analyze select * from mytable where mydate='2003-09-01'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ Index Scan using mytable_query on mytable (cost=0.00..148.56 rows=43 width=562) (actual time=41.22..41.27 rows=4 loops=1) Index Cond: (mydate = '2003-09-01'::date) Total runtime: 41.34 msec (3 rows) > On Wed, 2003-10-01 at 13:30, Dimitri Nagiev wrote: > > Hi all, > > > > I haven't found any official documentation about the postgres sql > optimiz > er > > on the web, so please forgive me if there is such a document and point > me > to > > the right direction. > > > > I've got the following problem: I cannot make the postgres SQL Optimizer > use > > an index on a date field to filter out a date range, e.g. > > > > select * from mytable where mydate >= '2003-10-01'; > > > > Seq Scan on mytable (cost=0.00..2138.11 rows=12203 width=543) > > Filter: (mydate >= '2003-09-01'::date) > > EXPLAIN ANALYZE output please. > -- NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse f�r Mail, Message, More! +++ From pgsql-performance-owner@postgresql.org Wed Oct 1 15:02:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8C842D1B4E1 for ; Wed, 1 Oct 2003 18:01:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86649-06 for ; Wed, 1 Oct 2003 15:01:13 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id 4F2F5D1B54F for ; Wed, 1 Oct 2003 15:01:12 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Wed, 1 Oct 2003 12:00:00 -0600 From: Oleg Lebedev To: Josh Berkus , "scott.marlowe" Cc: "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 11:59:59 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7618@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=MIME_BOUND_NEXTPART, MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/33 X-Sequence-Number: 3781 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Sure, below is the query. I attached the plan to this posting. select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey =3D l_suppkey and ps_suppkey =3D l_suppkey and ps_partkey =3D l_partkey and p_partkey =3D l_partkey and o_orderkey =3D l_orderkey and s_nationkey =3D n_nationkey and p_name like '%green%' ) as profit group by nation, o_year order by nation, o_year desc; -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Wednesday, October 01, 2003 11:42 AM To: Oleg Lebedev; scott.marlowe Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Oleg, > The output of the query should contain about 200 rows. So, I guess the > planer is off assuming that the query should return 1 row. Oh, also did you post the query before? Can you re-post it with the planner=20 results? --=20 Josh Berkus Aglio Database Solutions San Francisco ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="plan.txt" Content-Disposition: attachment; filename="plan.txt" Content-Transfer-Encoding: base64 ICAgLT4gIFNvcnQgIChjb3N0PTU0NTk3LjQ5Li41NDU5Ny41MCByb3dzPTEg d2lkdGg9MTIxKQ0KICAgICAgICAgU29ydCBLZXk6IG5hdGlvbi5uX25hbWUs IGRhdGVfcGFydCgneWVhcic6OnRleHQsb3JkZXJzLm9fb3JkZXJkYXRlKQ0K ICAgICAgICAgLT4gIEFnZ3JlZ2F0ZSAgKGNvc3Q9NTQ1OTcuNDUuLjU0NTk3 LjQ4IHJvd3M9MSB3aWR0aD0xMjEpDQogICAgICAgICAgICAgICAtPiAgR3Jv dXAgIChjb3N0PTU0NTk3LjQ1Li41NDU5Ny40NyByb3dzPTMgd2lkdGg9MTIx KQ0KICAgICAgICAgICAgICAgICAgICAgLT4gIFNvcnQgIChjb3N0PTU0NTk3 LjQ1Li41NDU5Ny40NiByb3dzPTMgd2lkdGg9MTIxKQ0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgU29ydCBLZXk6IG5hdGlvbi5uX25hbWUsIGRhdGVf cGFydCgneWVhcic6OnRleHQsIG9yZGVycy5vX29yZGVyZGF0ZSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTU0 NTk2LjAwLi41NDU5Ny40MiByb3dzPTMgd2lkdGg9MTIxKQ0KICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgSGFzaCBDb25kOiAoIm91dGVyIi5u X25hdGlvbmtleSA9ICJpbm5lciIuc19uYXRpb25rZXkpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbmF0aW9u ICAoY29zdD0wLjAwLi4xLjI1IHJvd3M9MjUgd2lkdGg9MzMpDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCAgKGNvc3Q9NTQ1 OTYuMDAuLjU0NTk2LjAwIHJvd3M9MyB3aWR0aD04OCkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAo Y29zdD0wLjAwLi41NDU5Ni4wMCByb3dzPTMgd2lkdGg9ODgpDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBKb2luIEZp bHRlcjogKCJpbm5lciIuc19zdXBwa2V5ID0gIm91dGVyIi5sX3N1cHBrZXkp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAtPiAgTmVzdGVkIExvb3AgKGNvc3Q9MC4wMC4uNTQ1ODYuMTggcm93cz0z IHdpZHRoPTgwKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wIChjb3N0PTAuMDAu LjU0NTc1LjQ3IHJvd3M9NCB3aWR0aD02OCkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEpvaW4g RmlsdGVyOiAoIm91dGVyIi5wX3BhcnRrZXkgPSAiaW5uZXIiLnBzX3BhcnRr ZXkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAtPiAgTmVzdGVkIExvb3AgKGNvc3Q9MC4wMC4u MjI3NTMuMzMgcm93cz05MzQzIHdpZHRoPTQ5KQ0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgLT4gIFNlcSBTY2FuIG9uIHBhcnQgIChjb3N0PTAuMDAuLjc4NjguMDAg cm93cz0zMjAgd2lkdGg9NCkgDQpGaWx0ZXI6IChwX25hbWUgfn4gJyVncmVl biUnOjp0ZXh0KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4g dXNpbmcgaV9sX3BhcnRrZXkgb24gbGluZWl0ZW0gIChjb3N0PTAuMDAuLjQ2 LjE1IHJvd3M9Mjkgd2lkdGg9NDUpDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBJbmRleA0KQ29uZDogKCJvdXRlciIucF9wYXJ0a2V5ID0gbGluZWl0ZW0u bF9wYXJ0a2V5KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4IFNjYW4gdXNpbmcg cGtfcGFydHN1cHAgb24gcGFydHN1cHAgIChjb3N0PTAuMDAuLjMuMzkgcm93 cz0xIHdpZHRoPTE5KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDog KChwYXJ0c3VwcC5wc19wYXJ0a2V5ID0gIm91dGVyIi5sX3BhcnRrZXkpIEFO RCAocGFydHN1cHAucHNfc3VwcGtleSA9DQoib3V0ZXIiLmxfc3VwcGtleSkp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyBwa19vcmRlcnMgb24gb3Jk ZXJzICAoY29zdD0wLjAwLi4zLjAxIHJvd3M9MSB3aWR0aD0xMikNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIEluZGV4IENvbmQ6IChvcmRlcnMub19vcmRlcmtleSA9ICJvdXRl ciIubF9vcmRlcmtleSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIHBrX3N1cHBs aWVyIG9uIHN1cHBsaWVyICAoY29zdD0wLjAwLi4zLjAxIHJvd3M9MSB3aWR0 aD04KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgSW5kZXggQ29uZDogKCJvdXRlciIucHNfc3VwcGtleSA9 IHN1cHBsaWVyLnNfc3VwcGtleSkgKDI3IHJvd3MpDQoNCg== --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Wed Oct 1 15:36:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 83B42D1B503 for ; Wed, 1 Oct 2003 18:36:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96354-02 for ; Wed, 1 Oct 2003 15:35:57 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 677B4D1B500 for ; Wed, 1 Oct 2003 15:35:56 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 84BBF1D65; Wed, 1 Oct 2003 14:35:56 -0400 (EDT) Subject: Re: Optimizing >= and <= for numbers and dates From: Neil Conway To: Dimitri Nagiev Cc: PostgreSQL Performance In-Reply-To: <3603.1065030329@www60.gmx.net> References: <1065029881.85344.138.camel@jester> <3603.1065030329@www60.gmx.net> Content-Type: text/plain Message-Id: <1065033355.381.97.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 01 Oct 2003 14:35:55 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/34 X-Sequence-Number: 3782 On Wed, 2003-10-01 at 13:45, Dimitri Nagiev wrote: > template1=# explain analyze select * from mytable where > mydate>='2003-09-01'; > QUERY PLAN > > > --------------------------------------------------------------------------------------------------------------- > Seq Scan on mytable (cost=0.00..2209.11 rows=22274 width=562) (actual > time=0.06..267.30 rows=22677 loops=1) > Filter: (mydate >= '2003-09-01'::date) > Total runtime: 307.71 msec > (3 rows) It may well be the case that a seqscan is faster than an index scan for this query. Try disabling sequential scans (SET enable_seqscan = false) and re-running EXPLAIN ANALYZE: see if the total runtime is smaller or larger. -Neil From pgsql-performance-owner@postgresql.org Wed Oct 1 16:10:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ABF19D1B503 for ; Wed, 1 Oct 2003 19:10:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97243-05 for ; Wed, 1 Oct 2003 16:10:12 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 94C06D1B522 for ; Wed, 1 Oct 2003 16:10:10 -0300 (ADT) 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 h91J96Qc012613; Wed, 1 Oct 2003 13:09:06 -0600 (MDT) Date: Wed, 1 Oct 2003 13:03:21 -0600 (MDT) From: "scott.marlowe" To: Dimitri Nagiev Cc: Subject: Re: Optimizing >= and <= for numbers and dates In-Reply-To: <3603.1065030329@www60.gmx.net> 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: 200310/36 X-Sequence-Number: 3784 On Wed, 1 Oct 2003, Dimitri Nagiev wrote: > here goes the EXPLAIN ANALYZE output: > > > template1=# VACUUM analyze mytable; > VACUUM > template1=# explain analyze select * from mytable where > mydate>='2003-09-01'; > QUERY PLAN > > > --------------------------------------------------------------------------------------------------------------- > Seq Scan on mytable (cost=0.00..2209.11 rows=22274 width=562) (actual > time=0.06..267.30 rows=22677 loops=1) > Filter: (mydate >= '2003-09-01'::date) > Total runtime: 307.71 msec > (3 rows) How many rows are there in this table? If the number is only two or three times as many as the number of rows returned (22677) then a seq scan is preferable. The way to tune your random_page_cost is to keep making your range more selective until you get an index scan. Then, see what the difference is in speed between the two queries that sit on either side of that number, i.e. if a query that returns 1000 rows switches to index scan, and takes 100 msec, while one that returns 1050 uses seq scan and takes 200 msec, then you might want to lower your random page cost. Ideally, what should happen is that as the query returns more and more rows, the switch to seq scan should happen so that it's taking about the same amount of time as the index scan, maybe just a little more. From pgsql-performance-owner@postgresql.org Wed Oct 1 16:12:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F8C8D1B4EF for ; Wed, 1 Oct 2003 19:12:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 95806-10 for ; Wed, 1 Oct 2003 16:11:57 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 67368D1B53E for ; Wed, 1 Oct 2003 16:11:55 -0300 (ADT) 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 h91JAfQc012674; Wed, 1 Oct 2003 13:10:42 -0600 (MDT) Date: Wed, 1 Oct 2003 13:04:56 -0600 (MDT) From: "scott.marlowe" To: Dimitri Nagiev Cc: Subject: Re: Optimizing >= and <= for numbers and dates In-Reply-To: <3603.1065030329@www60.gmx.net> 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-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=IN_REP_TO, RCVD_IN_OSIRUSOFT_COM, USER_AGENT_PINE X-Spam-Level: X-Archive-Number: 200310/37 X-Sequence-Number: 3785 Oh, to followup on my previously sent post, make sure you've got effective_cache_size set right BEFORE you go trying to set random_page_cost, and you might wanna run a select * from table to load the table into kernel buffer cache before testing, then also test it with the cache cleared out (select * from a_different_really_huge_table will usually do that.) From pgsql-performance-owner@postgresql.org Wed Oct 1 16:10:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8711ED1B51A for ; Wed, 1 Oct 2003 19:10:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 98141-04 for ; Wed, 1 Oct 2003 16:09:20 -0300 (ADT) Received: from tatiana.utanet.at (tatiana.utanet.at [213.90.36.46]) by svr1.postgresql.org (Postfix) with ESMTP id AA351D1B51C for ; Wed, 1 Oct 2003 16:09:11 -0300 (ADT) Received: from plenty.utanet.at ([213.90.36.9]) by tatiana.utanet.at with esmtp (Exim 4.12) id 1A4mLX-0003x5-00; Wed, 01 Oct 2003 21:09:11 +0200 Received: from micht2-133-145.utaonline.at ([212.152.133.145] helo=fermat.Koizar.inf) by plenty.utanet.at with smtp (Exim 4.12) id 1A4mLX-0004Z8-00; Wed, 01 Oct 2003 21:09:11 +0200 From: Manfred Koizar To: "Dimitri Nagiev" Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing >= and <= for numbers and dates Date: Wed, 01 Oct 2003 21:06:17 +0200 Message-ID: References: <1065029881.85344.138.camel@jester> <3603.1065030329@www60.gmx.net> In-Reply-To: <3603.1065030329@www60.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: 200310/35 X-Sequence-Number: 3783 On Wed, 1 Oct 2003 19:45:29 +0200 (MEST), "Dimitri Nagiev" wrote: >template1=# explain analyze select * from mytable where >mydate>='2003-09-01'; > Seq Scan on mytable (cost=0.00..2209.11 rows=22274 width=562) (actual time=0.06..267.30 rows=22677 loops=1) > Filter: (mydate >= '2003-09-01'::date) > Total runtime: 307.71 msec Didn't you say that there are 25000 rows in the table? I can't believe that for selecting 90% of all rows an index scan would be faster. Try SET enable_seqscan = 0; explain analyze select * from mytable where mydate>='2003-09-01'; If you find the index scan to be faster, there might be lots of dead tuples in which case you should VACUUM FULL mytable; Servus Manfred From pgsql-performance-owner@postgresql.org Wed Oct 1 18:04:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DC230D1B522 for ; Wed, 1 Oct 2003 21:04:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19438-03 for ; Wed, 1 Oct 2003 18:04:03 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id D3A22D1B4F1 for ; Wed, 1 Oct 2003 18:03:58 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Wed, 1 Oct 2003 15:02:44 -0600 From: Oleg Lebedev To: Josh Berkus , "scott.marlowe" Cc: "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 15:02:43 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=MIME_BOUND_NEXTPART, MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/38 X-Sequence-Number: 3786 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable All right, my query just finished running with EXPLAIN ANALYZE. I show the plan below and also attached it as a file. Any ideas? -> Sort (cost=3D54597.49..54597.50 rows=3D1 width=3D121) (actual time=3D6674562.03..6674562.15 rows=3D175 loops=3D1) Sort Key: nation.n_name, date_part('year'::text, orders.o_orderdate) -> Aggregate (cost=3D54597.45..54597.48 rows=3D1 width=3D121) (actual time=3D6668919.41..6674522.48 rows=3D175 loops=3D1) -> Group (cost=3D54597.45..54597.47 rows=3D3 width=3D121) (actual time=3D6668872.68..6672136.96 rows=3D348760 loops=3D1) -> Sort (cost=3D54597.45..54597.46 rows=3D3 width=3D121) (actual time=3D6668872.65..6669499.95 rows=3D348760 loops=3D1) Sort Key: nation.n_name, date_part('year'::text, orders.o_orderdate) -> Hash Join (cost=3D54596.00..54597.42 rows=3D3 width=3D121) (actual time=3D6632768.89..6650192.67 rows=3D348760 loops=3D1) Hash Cond: ("outer".n_nationkey =3D "inner".s_nationkey) -> Seq Scan on nation (cost=3D0.00..1.25 rows=3D25 width=3D33) (actual time=3D6.75..7.13 rows=3D25 loops=3D1) -> Hash (cost=3D54596.00..54596.00 rows=3D3 width=3D88) (actual time=3D6632671.96..6632671.96 rows=3D0 loops=3D1) -> Nested Loop (cost=3D0.00..54596.00 rows=3D3 width=3D88) (actual time=3D482.41..6630601.= 46 rows=3D348760 loops=3D1) Join Filter: ("inner".s_suppkey =3D "outer".l_suppkey) -> Nested Loop (cost=3D0.00..54586.18 rows=3D3 width=3D80) (actual time=3D383.87..6594984.= 40 rows=3D348760 loops=3D1) -> Nested Loop (cost=3D0.00..54575.47 rows=3D4 width=3D68) (actual time=3D199.95..3580882.= 07 rows=3D348760 loops=3D1) Join Filter: ("outer".p_partkey =3D "inner".ps_partkey) -> Nested Loop (cost=3D0.00..22753.33 rows=3D9343 width=3D49) (actual time=3D146.85..35414= 33.10 rows=3D348760 loops=3D1) -> Seq Scan on part (cost=3D0.00..7868.00 rows=3D320 width=3D4) (actual time=3D33.64..15651.90 rows=3D11637 loops=3D1) Filter: (p_name ~~ '%green%'::text) -> Index Scan using i_l_partkey on lineitem (cost=3D0.00..46.15 rows=3D29 width=3D4= 5) (actual time=3D10.71..302.67 rows=3D30 loops=3D11637) =20 Index Cond: ("outer".p_partkey =3D lineitem.l_partkey) -> Index Scan using pk_partsupp on partsupp (cost=3D0.00..3.39 rows=3D1 width=3D19) (act= ual time=3D0.09..0.09 rows=3D1 loops=3D348760) Index Cond: ((partsupp.ps_partkey =3D "outer".l_partkey) AND (partsupp.ps_suppkey =3D "outer".l_suppkey)) -> Index Scan using pk_orders on orders (cost=3D0.00..3.01 rows=3D1 width=3D12) (actual time=3D8.62..8.62 rows=3D1 loops=3D348760) Index Cond: (orders.o_orderkey =3D "outer".l_orderkey) -> Index Scan using pk_supplier on supplier (cost=3D0.00..3.01 rows=3D1 width=3D8) (actual time=3D0.08..0.08 rows=3D1 loops=3D348760) Index Cond: ("outer".ps_suppkey =3D supplier.s_suppkey) Total runtime: 6674724.23 msec (28 rows) -----Original Message----- From: Oleg Lebedev=20 Sent: Wednesday, October 01, 2003 12:00 PM To: Josh Berkus; scott.marlowe Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Importance: Low Sure, below is the query. I attached the plan to this posting. select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey =3D l_suppkey and ps_suppkey =3D l_suppkey and ps_partkey =3D l_partkey and p_partkey =3D l_partkey and o_orderkey =3D l_orderkey and s_nationkey =3D n_nationkey and p_name like '%green%' ) as profit group by nation, o_year order by nation, o_year desc; -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Wednesday, October 01, 2003 11:42 AM To: Oleg Lebedev; scott.marlowe Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Oleg, > The output of the query should contain about 200 rows. So, I guess the > planer is off assuming that the query should return 1 row. Oh, also did you post the query before? Can you re-post it with the planner=20 results? --=20 Josh Berkus Aglio Database Solutions San Francisco ************************************* This e-mail may contain privileged or confidential material intended for the named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using information in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="plan_explained.txt" Content-Disposition: attachment; filename="plan_explained.txt" Content-Transfer-Encoding: base64 ICAgLT4gIFNvcnQgIChjb3N0PTU0NTk3LjQ5Li41NDU5Ny41MCByb3dzPTEg d2lkdGg9MTIxKSAoYWN0dWFsIHRpbWU9NjY3NDU2Mi4wMy4uNjY3NDU2Mi4x NSByb3dzPTE3NSBsb29wcz0xKQ0KICAgICAgICAgU29ydCBLZXk6IG5hdGlv bi5uX25hbWUsIGRhdGVfcGFydCgneWVhcic6OnRleHQsDQpvcmRlcnMub19v cmRlcmRhdGUpDQogICAgICAgICAtPiAgQWdncmVnYXRlICAoY29zdD01NDU5 Ny40NS4uNTQ1OTcuNDggcm93cz0xIHdpZHRoPTEyMSkgKGFjdHVhbCB0aW1l PTY2Njg5MTkuNDEuLjY2NzQ1MjIuNDggcm93cz0xNzUgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgIC0+ICBHcm91cCAgKGNvc3Q9NTQ1OTcuNDUuLjU0NTk3 LjQ3IHJvd3M9MyB3aWR0aD0xMjEpIChhY3R1YWwgdGltZT02NjY4ODcyLjY4 Li42NjcyMTM2Ljk2IHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAtPiAgU29ydCAgKGNvc3Q9NTQ1OTcuNDUuLjU0NTk3LjQ2 IHJvd3M9MyB3aWR0aD0xMjEpIChhY3R1YWwgdGltZT02NjY4ODcyLjY1Li42 NjY5NDk5Ljk1IHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQogICAgICAgICAgICAg ICAgICAgICAgICAgICBTb3J0IEtleTogbmF0aW9uLm5fbmFtZSwgZGF0ZV9w YXJ0KCd5ZWFyJzo6dGV4dCwgb3JkZXJzLm9fb3JkZXJkYXRlKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9NTQ1 OTYuMDAuLjU0NTk3LjQyIHJvd3M9Mw0Kd2lkdGg9MTIxKSAoYWN0dWFsIHRp bWU9NjYzMjc2OC44OS4uNjY1MDE5Mi42NyByb3dzPTM0ODc2MCBsb29wcz0x KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSGFzaCBDb25k OiAoIm91dGVyIi5uX25hdGlvbmtleSA9DQoiaW5uZXIiLnNfbmF0aW9ua2V5 KQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIFNlcSBT Y2FuIG9uIG5hdGlvbiAgKGNvc3Q9MC4wMC4uMS4yNSByb3dzPTI1IHdpZHRo PTMzKSAoYWN0dWFsIHRpbWU9Ni43NS4uNy4xMyByb3dzPTI1IGxvb3BzPTEp DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCAg KGNvc3Q9NTQ1OTYuMDAuLjU0NTk2LjAwIHJvd3M9Mw0Kd2lkdGg9ODgpIChh Y3R1YWwgdGltZT02NjMyNjcxLjk2Li42NjMyNjcxLjk2IHJvd3M9MCBsb29w cz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg LT4gIE5lc3RlZCBMb29wIChjb3N0PTAuMDAuLjU0NTk2LjAwIHJvd3M9MyB3 aWR0aD04OCkgKGFjdHVhbCB0aW1lPTQ4Mi40MS4uNjYzMDYwMS40NiByb3dz PTM0ODc2MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0ZXI6ICgiaW5uZXIiLnNfc3Vw cGtleSA9ICJvdXRlciIubF9zdXBwa2V5KQ0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wIChj b3N0PTAuMDAuLjU0NTg2LjE4IHJvd3M9MyB3aWR0aD04MCkgKGFjdHVhbCB0 aW1lPTM4My44Ny4uNjU5NDk4NC40MCByb3dzPTM0ODc2MCBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIE5lc3RlZCBMb29wIChjb3N0PTAuMDAuLjU0NTc1LjQ3IHJv d3M9NCB3aWR0aD02OCkgKGFjdHVhbCB0aW1lPTE5OS45NS4uMzU4MDg4Mi4w NyByb3dzPTM0ODc2MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSm9pbiBGaWx0 ZXI6ICgib3V0ZXIiLnBfcGFydGtleSA9ICJpbm5lciIucHNfcGFydGtleSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAoY29zdD0wLjAwLi4yMjc1 My4zMyByb3dzPTkzNDMgd2lkdGg9NDkpIChhY3R1YWwgdGltZT0xNDYuODUu LjM1NDE0MzMuMTAgcm93cz0zNDg3NjAgbG9vcHM9MSkNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIC0+ICBTZXEgU2NhbiBvbiBwYXJ0ICAoY29zdD0wLjAwLi43ODY4 LjAwIHJvd3M9MzIwIHdpZHRoPTQpIChhY3R1YWwgdGltZT0zMy42NC4uMTU2 NTEuOTAgcm93cz0xMTYzNyBsb29wcz0xKQ0KDQpGaWx0ZXI6IChwX25hbWUg fn4gJyVncmVlbiUnOjp0ZXh0KQ0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIElu ZGV4IFNjYW4gdXNpbmcgaV9sX3BhcnRrZXkgb24gbGluZWl0ZW0gIChjb3N0 PTAuMDAuLjQ2LjE1IHJvd3M9Mjkgd2lkdGg9NDUpIChhY3R1YWwgdGltZT0x MC43MS4uMzAyLjY3IHJvd3M9MzAgbG9vcHM9MTE2MzcpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBJbmRleA0KQ29uZDogKCJvdXRlciIucF9wYXJ0a2V5 ID0gbGluZWl0ZW0ubF9wYXJ0a2V5KQ0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4 IFNjYW4gdXNpbmcgcGtfcGFydHN1cHAgb24gcGFydHN1cHAgIChjb3N0PTAu MDAuLjMuMzkgcm93cz0xIHdpZHRoPTE5KSAoYWN0dWFsIHRpbWU9MC4wOS4u MC4wOSByb3dzPTEgbG9vcHM9MzQ4NzYwKQ0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg SW5kZXggQ29uZDogKChwYXJ0c3VwcC5wc19wYXJ0a2V5ID0gIm91dGVyIi5s X3BhcnRrZXkpIEFORCAocGFydHN1cHAucHNfc3VwcGtleSA9DQoib3V0ZXIi Lmxfc3VwcGtleSkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyBwa19v cmRlcnMgb24gb3JkZXJzICAoY29zdD0wLjAwLi4zLjAxIHJvd3M9MSB3aWR0 aD0xMikgKGFjdHVhbCB0aW1lPTguNjIuLjguNjIgcm93cz0xIGxvb3BzPTM0 ODc2MCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6IChvcmRlcnMub19vcmRl cmtleSA9ICJvdXRlciIubF9vcmRlcmtleSkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVz aW5nIHBrX3N1cHBsaWVyIG9uIHN1cHBsaWVyICAoY29zdD0wLjAwLi4zLjAx IHJvd3M9MSB3aWR0aD04KSAoYWN0dWFsIHRpbWU9MC4wOC4uMC4wOCByb3dz PTEgbG9vcHM9MzQ4NzYwKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCJvdXRlciIu cHNfc3VwcGtleSA9IHN1cHBsaWVyLnNfc3VwcGtleSkgIFRvdGFsIHJ1bnRp bWU6IDY2NzQ3MjQuMjMgbXNlYyAoMjggcm93cykNCg0K --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Wed Oct 1 19:07:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1DB30D1B4E1 for ; Wed, 1 Oct 2003 22:07:28 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32429-02 for ; Wed, 1 Oct 2003 19:06:43 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 39A0ED1B502 for ; Wed, 1 Oct 2003 19:06:37 -0300 (ADT) 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 h91M5QUY026208; Wed, 1 Oct 2003 16:05:31 -0600 (MDT) Date: Wed, 1 Oct 2003 15:59:41 -0600 (MDT) From: "scott.marlowe" To: Oleg Lebedev Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> 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: 200310/39 X-Sequence-Number: 3787 For troubleshooting, can you try it with "set enable_nestloop = false" and rerun the query and see how long it takes? It looks like the estimates of rows returned is WAY off (estimate is too low compared to what really comes back.) Also, you might try to alter the table.column to have a higher target on the rows p_partkey and ps_partkey and any others where the estimate is so far off of the reality. On Wed, 1 Oct 2003, Oleg Lebedev wrote: > All right, my query just finished running with EXPLAIN ANALYZE. > I show the plan below and also attached it as a file. > Any ideas? > > -> Sort (cost=54597.49..54597.50 rows=1 width=121) (actual > time=6674562.03..6674562.15 rows=175 loops=1) > Sort Key: nation.n_name, date_part('year'::text, > orders.o_orderdate) > -> Aggregate (cost=54597.45..54597.48 rows=1 width=121) > (actual time=6668919.41..6674522.48 rows=175 loops=1) > -> Group (cost=54597.45..54597.47 rows=3 width=121) > (actual time=6668872.68..6672136.96 rows=348760 loops=1) > -> Sort (cost=54597.45..54597.46 rows=3 > width=121) (actual time=6668872.65..6669499.95 rows=348760 loops=1) > Sort Key: nation.n_name, > date_part('year'::text, orders.o_orderdate) > -> Hash Join (cost=54596.00..54597.42 > rows=3 > width=121) (actual time=6632768.89..6650192.67 rows=348760 loops=1) > Hash Cond: ("outer".n_nationkey = > "inner".s_nationkey) > -> Seq Scan on nation > (cost=0.00..1.25 rows=25 width=33) (actual time=6.75..7.13 rows=25 > loops=1) > -> Hash (cost=54596.00..54596.00 > rows=3 > width=88) (actual time=6632671.96..6632671.96 rows=0 loops=1) > -> Nested Loop > (cost=0.00..54596.00 rows=3 width=88) (actual time=482.41..6630601.46 > rows=348760 loops=1) > Join Filter: > ("inner".s_suppkey = "outer".l_suppkey) > -> Nested Loop > (cost=0.00..54586.18 rows=3 width=80) (actual time=383.87..6594984.40 > rows=348760 loops=1) > -> Nested Loop > (cost=0.00..54575.47 rows=4 width=68) (actual time=199.95..3580882.07 > rows=348760 loops=1) > Join Filter: > ("outer".p_partkey = "inner".ps_partkey) > -> Nested Loop > (cost=0.00..22753.33 rows=9343 width=49) (actual time=146.85..3541433.10 > rows=348760 loops=1) > -> Seq > Scan on part (cost=0.00..7868.00 rows=320 width=4) (actual > time=33.64..15651.90 rows=11637 loops=1) > > Filter: (p_name ~~ '%green%'::text) > -> Index > Scan using i_l_partkey on lineitem (cost=0.00..46.15 rows=29 width=45) > (actual time=10.71..302.67 rows=30 loops=11637) > > Index > Cond: ("outer".p_partkey = lineitem.l_partkey) > -> Index Scan > using pk_partsupp on partsupp (cost=0.00..3.39 rows=1 width=19) (actual > time=0.09..0.09 rows=1 loops=348760) > Index > Cond: ((partsupp.ps_partkey = "outer".l_partkey) AND > (partsupp.ps_suppkey = > "outer".l_suppkey)) > -> Index Scan using > pk_orders on orders (cost=0.00..3.01 rows=1 width=12) (actual > time=8.62..8.62 rows=1 loops=348760) > Index Cond: > (orders.o_orderkey = "outer".l_orderkey) > -> Index Scan using > pk_supplier on supplier (cost=0.00..3.01 rows=1 width=8) (actual > time=0.08..0.08 rows=1 loops=348760) > Index Cond: > ("outer".ps_suppkey = supplier.s_suppkey) Total runtime: 6674724.23 > msec (28 rows) > > > -----Original Message----- > From: Oleg Lebedev > Sent: Wednesday, October 01, 2003 12:00 PM > To: Josh Berkus; scott.marlowe > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks > Importance: Low > > > Sure, below is the query. I attached the plan to this posting. > > select > nation, > o_year, > sum(amount) as sum_profit > from > ( > select > n_name as nation, > extract(year from o_orderdate) as o_year, > l_extendedprice * (1 - l_discount) - > ps_supplycost * l_quantity as amount > from > part, > supplier, > lineitem, > partsupp, > orders, > nation > where > s_suppkey = l_suppkey > and ps_suppkey = l_suppkey > and ps_partkey = l_partkey > and p_partkey = l_partkey > and o_orderkey = l_orderkey > and s_nationkey = n_nationkey > and p_name like '%green%' > ) as profit > group by > nation, > o_year > order by > nation, > o_year desc; > > > -----Original Message----- > From: Josh Berkus [mailto:josh@agliodbs.com] > Sent: Wednesday, October 01, 2003 11:42 AM > To: Oleg Lebedev; scott.marlowe > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks > > > Oleg, > > > The output of the query should contain about 200 rows. So, I guess the > > > planer is off assuming that the query should return 1 row. > > Oh, also did you post the query before? Can you re-post it with the > planner > results? > > From pgsql-performance-owner@postgresql.org Wed Oct 1 19:20:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 611E1D1B52A for ; Wed, 1 Oct 2003 22:20:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 28867-08 for ; Wed, 1 Oct 2003 19:19:47 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 34012D1B50B for ; Wed, 1 Oct 2003 19:19:44 -0300 (ADT) 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 h91MJhhn010131; Wed, 1 Oct 2003 18:19:43 -0400 (EDT) To: Oleg Lebedev Cc: Josh Berkus , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks In-reply-to: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> References: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> Comments: In-reply-to Oleg Lebedev message dated "Wed, 01 Oct 2003 15:02:43 -0600" Date: Wed, 01 Oct 2003 18:19:43 -0400 Message-ID: <10130.1065046783@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/40 X-Sequence-Number: 3788 Oleg Lebedev writes: > All right, my query just finished running with EXPLAIN ANALYZE. > I show the plan below and also attached it as a file. > Any ideas? Uh, have you done an ANALYZE (or VACUUM ANALYZE) on this database? It sure looks like the planner thinks the tables are a couple of orders of magnitude smaller than they actually are. Certainly the estimated sizes of the joins are way off :-( If you did analyze, it might help to increase the statistics target and re-analyze. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 1 19:25:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 376B4D1B4EC for ; Wed, 1 Oct 2003 22:25:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 28824-09 for ; Wed, 1 Oct 2003 19:25:07 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 11ACED1B4E1 for ; Wed, 1 Oct 2003 19:25:04 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3704793; Wed, 01 Oct 2003 15:25:38 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Oleg Lebedev , "scott.marlowe" Subject: Re: TPC-R benchmarks Date: Wed, 1 Oct 2003 15:23:12 -0700 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" References: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D761E@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310011523.12895.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/41 X-Sequence-Number: 3789 Oleg, > All right, my query just finished running with EXPLAIN ANALYZE. > I show the plan below and also attached it as a file. > Any ideas? Yes. Your problem appears to be right here: > -> Nested Loop > (cost=3D0.00..54596.00 rows=3D3 width=3D88) (actual time=3D482.41..663060= 1.46 > rows=3D348760 loops=3D1) > Join Filter: > ("inner".s_suppkey =3D "outer".l_suppkey) > -> Nested Loop > (cost=3D0.00..54586.18 rows=3D3 width=3D80) (actual time=3D383.87..659498= 4.40 > rows=3D348760 loops=3D1) > -> Nested Loop > (cost=3D0.00..54575.47 rows=3D4 width=3D68) (actual time=3D199.95..358088= 2.07 > rows=3D348760 loops=3D1) > Join Filter: > ("outer".p_partkey =3D "inner".ps_partkey) > -> Nested Loop > (cost=3D0.00..22753.33 rows=3D9343 width=3D49) (actual time=3D146.85..354= 1433.10 > rows=3D348760 loops=3D1) For some reason, the row estimate on the supplier --> lineitem join is bad,= as=20 is the estimate on part --> partsupp. Let me first check two things: 1) You have an index on l_suppkey and on ps_partkey. 2) you have run ANALYZE on your whole database before the query If both of those are true, I'd like to see the lines in pg_stats that apply= to=20 ps_partkey and l_suppkey; please do a: SELECT * FROM pg_stats WHERE attname =3D 'l_suppkey' or attname =3D 'ps_par= tkey' --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-novice-owner@postgresql.org Wed Oct 1 21:21:53 2003 X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EA6C4D1B560 for ; Thu, 2 Oct 2003 00:21:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51894-09 for ; Wed, 1 Oct 2003 21:21:05 -0300 (ADT) Received: from ecnlns1.ecn.ab.ca (unknown [198.161.206.10]) by svr1.postgresql.org (Postfix) with ESMTP id CA13AD1B573 for ; Wed, 1 Oct 2003 21:19:23 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ecnlns1.ecn.ab.ca (Postfix) with ESMTP id C353E6536A; Wed, 1 Oct 2003 18:29:32 -0600 (MDT) Received: from fn2.freenet.edmonton.ab.ca (fn2.freenet.edmonton.ab.ca [198.161.206.7]) by ecnlns1.ecn.ab.ca (Postfix) with ESMTP id 9ADF36500F; Wed, 1 Oct 2003 18:29:32 -0600 (MDT) Received: from localhost (ghaverla@localhost) by fn2.freenet.edmonton.ab.ca (8.12.0/8.7.3) with SMTP id h920JLFf054174; Wed, 1 Oct 2003 18:19:21 -0600 Date: Wed, 1 Oct 2003 18:19:21 -0600 (MDT) From: To: Jason Hihn Cc: "Pgsql-Novice@Postgresql. Org" Subject: Re: Ideal Hardware? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS snapshot-20020531 on ECN X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, IN_REP_TO, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200310/19 X-Sequence-Number: 8456 On Wed, 1 Oct 2003, Jason Hihn wrote: > We have an opportunity to purchase a new, top-notch database server. I am > wondering what kind of hardware is recommended? We're on Linux platforms and > kernels though. [...] > The configuration that is going on in my head is: > RAID 1, 200gig > 1 server, 4g ram > Linux 2.6 I vaguely remember someone (Tom?) mentioning that one of the log files probably might want to go on its own partition. Sometime in the last 2 weeks. I am not pushing dbase stuff here, but my system is about your size. About 120 GB of my disk is RAID on a promiseware card, using the kernel software RAID (apparently software RAID on Linux is faster than the promisecard does it in hardware). I have a bunch of different things using software RAID: /tmp is a RAID 0 with ext2 /home is a RAID 5 with ext3 /usr, /var, /usr/local is RAID 10 with ext3 /var/lib/postgres is on a real SCSI 10k, on ext3 with noatime So, my postgres isn't on the RAID(s). I just got finished rebuilding my RAIDs for the second time (failed disk). I ended up rebuilding things in single user mode, so I can't set tasks in parallel. I don't know if you can do this in multi-user mode and/or in parallel. I'm being paranoid. Rebuilding RAID 5 is fast, rebuilding RAID 1 is a pain in the butt! My biggest RAID 10 is about 10 GB, bundling the new partition from the new disk into the RAID 0 is fast, rebuilding the mirror (RAID 1 part) takes 10 hours! Dual athlon 1.6's and 1 GB of RAM, so I have lots of horsepower. Maybe you are going with better RAID than I have, but it seems to me that RAID 5 (with spares) is going to be better if you ever have to rebuild. Gord From pgsql-novice-owner@postgresql.org Wed Oct 1 22:13:11 2003 X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 74B7ED1B510 for ; Thu, 2 Oct 2003 01:13:10 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62332-06 for ; Wed, 1 Oct 2003 22:12:27 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 356E3D1B513 for ; Wed, 1 Oct 2003 22:12:23 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3705295; Wed, 01 Oct 2003 18:12:58 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: , Jason Hihn Subject: Re: Ideal Hardware? Date: Wed, 1 Oct 2003 18:10:31 -0700 User-Agent: KMail/1.4.3 Cc: "Pgsql-Novice@Postgresql. Org" References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310011810.32006.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/20 X-Sequence-Number: 8457 Gord, > I vaguely remember someone (Tom?) mentioning that one of the log > files probably might want to go on its own partition.=20 That's general knowledge, but not really applicable to a fast RAID system.= =20=20=20 It's more imporant to regular-disk systems; with 4+ disk RAID, nobody has= =20 been able to demonstrate a gain from having the disk separation. > fast, rebuilding RAID 1 is a pain in the butt! My biggest RAID 10 > is about 10 GB, bundling the new partition from the new disk into > the RAID 0 is fast, rebuilding the mirror (RAID 1 part) takes 10 > hours! Dual athlon 1.6's and 1 GB of RAM, so I have lots of > horsepower. Maybe you are going with better RAID than I have, > but it seems to me that RAID 5 (with spares) is going to be better > if you ever have to rebuild. Also depends on the number of disks, the controller, and the balance of rea= d=20 vs. write activity. I've found RAID 5 with no cache to be dog-slow for OL= TP=20 (heavy write transaction) databases, and use RAID 1 for that. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 2 04:14:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C12EED1B551 for ; Thu, 2 Oct 2003 07:14:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 35670-01 for ; Thu, 2 Oct 2003 04:13:59 -0300 (ADT) 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 DD835D1B555 for ; Thu, 2 Oct 2003 04:13:56 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h927Dsrw003636; Thu, 2 Oct 2003 10:13:55 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h927DrjW003634; Thu, 2 Oct 2003 10:13:53 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: inferior SCSI performance From: Hannu Krosing To: Christopher Browne Cc: pgsql-performance@postgresql.org In-Reply-To: <60brt1szby.fsf@dev6.int.libertyrms.info> References: <20031001103338.GA29293@libertyrms.info> <20031001132536.GA30269@libertyrms.info> <60brt1szby.fsf@dev6.int.libertyrms.info> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1065078832.3166.77.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 02 Oct 2003 10:13:53 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/42 X-Sequence-Number: 3790 Christopher Browne kirjutas K, 01.10.2003 kell 19:21: > > The FS-related result appeared surprising, as the "stories" I had > heard suggested that JFS hadn't been particularly heavily tuned on > Linux, whereas XFS was supposed to be the "speed demon." Gentoo linux recommends XFS only for SAN+fibre channel + good ups for anything but database use ;) > It is entirely possible that the result I saw was one that would > reverse partially or even totally on a system LACKING that cache. XFS > might "play better" when we're cacheless; the (perhaps only fabled) > demerits of JFS being more than totally hidden if we add the cache. > > What I find disappointing is that it isn't possible to get SSD cards > that are relatively inexpensive. A similarly fabulous performance > increase _ought_ to be attainable if you could stick pg_xlog and > pg_clog on a 256MB (or bigger!) battery-backed SSD, ideally one that > plugs into a PCI slot. For really cheap and for small-size transactions you could experiment with USB2 memory sticks (some of them claim 34MB/s write speed), perhaps in striped/mirrored configuration. You would just need something counting writes in the driver layer to alert you when you are reaching the x00k "writes" limit and have to plug in new sticks :) OTOH, articles I found through quick googling suggest only 2.4MB/s write and 7MB/s read speeds for USB 2.0 memory sticks, so the 34MB is proably just sales pitch and refers to bus speed, not actual write speed ;( > Unfortunately, while there are companies hawking SSDs, they are in the > "you'll have to talk to our salescritter for pricing" category, which > means that they must be ferociously expensive. :-(. the cheapest I found was the one with external backup power was ~1.8k$ for 2GB PCI device http://www.cdw.com/shop/search/Results.aspx?key=platypus&x=0&y=0 An external 16GB one with battery backup and write-t-small-ide-drives-on-power-failure was ~25k$ ----------------- Hannu From pgsql-performance-owner@postgresql.org Thu Oct 2 05:01:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 70793D1B555 for ; Thu, 2 Oct 2003 08:01:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 35600-10 for ; Thu, 2 Oct 2003 05:00:46 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 59BCED1B502 for ; Thu, 2 Oct 2003 05:00:44 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 4EBF036A7E; Thu, 2 Oct 2003 04:00:23 -0400 (EDT) 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 1A4yNr-0001YQ-00; Thu, 02 Oct 2003 04:00:23 -0400 To: Hannu Krosing Cc: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: inferior SCSI performance References: <20031001103338.GA29293@libertyrms.info> <20031001132536.GA30269@libertyrms.info> <60brt1szby.fsf@dev6.int.libertyrms.info> <1065078832.3166.77.camel@fuji.krosing.net> In-Reply-To: <1065078832.3166.77.camel@fuji.krosing.net> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 02 Oct 2003 04:00:22 -0400 Message-ID: <87lls483xl.fsf@stark.dyndns.tv> Lines: 25 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: 200310/43 X-Sequence-Number: 3791 > > Unfortunately, while there are companies hawking SSDs, they are in the > > "you'll have to talk to our salescritter for pricing" category, which > > means that they must be ferociously expensive. :-(. > > the cheapest I found was the one with external backup power was ~1.8k$ > for 2GB PCI device > > http://www.cdw.com/shop/search/Results.aspx?key=platypus&x=0&y=0 That is pretty neat. > An external 16GB one with battery backup and > write-t-small-ide-drives-on-power-failure was ~25k$ And they scale up from there. This company has one that goes up to 1TB RAM. 4.5kW power consumption? I hate to see what kind of heat that thing generates. http://www.imperialtech.com/pdf/MRSpec_021803.pdf I have no idea what price the monster unit is, but someone described the price of one of the *lesser* units as "made me physically ill". So I can only imagine. -- greg From pgsql-performance-owner@postgresql.org Thu Oct 2 05:52:42 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 780A4D1B52A for ; Thu, 2 Oct 2003 08:52:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 46914-06 for ; Thu, 2 Oct 2003 05:51:56 -0300 (ADT) Received: from cerebro.int-bytecraft.com (unknown [219.93.229.26]) by svr1.postgresql.org (Postfix) with ESMTP id D7D61D1B554 for ; Thu, 2 Oct 2003 05:51:52 -0300 (ADT) Received: from bytecraft.com.my (home.int-bytecraft.com [127.0.0.1]) by cerebro.int-bytecraft.com (8.11.6/8.11.6) with ESMTP id h928oRM10865; Thu, 2 Oct 2003 16:50:28 +0800 Message-ID: <3F7BE7B1.5090005@bytecraft.com.my> Date: Thu, 02 Oct 2003 16:54:09 +0800 From: Ang Chin Han User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: inferior SCSI performance References: <3F688CC5.12621.4EBFDCC@localhost> <4693.1063825713@sss.pgh.pa.us> <20031001103338.GA29293@libertyrms.info> In-Reply-To: <20031001103338.GA29293@libertyrms.info> X-Enigmail-Version: 0.76.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig78C486BCA5B58DFCB52BC8A0" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/44 X-Sequence-Number: 3792 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig78C486BCA5B58DFCB52BC8A0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Andrew Sullivan wrote: > Yes. If and only if you have a battery-backed cache. I know of no > IDE drives that have that, but there's nothing about the spec which > makes it impossible. http://www.ussg.iu.edu/hypermail/linux/kernel/0103.0/1084.html Relevant section: Maybe that is why there is a vender disk-cache dump zone on the edge of the platters...just maybe you need to buy your drives from somebody that does this and has a predictive sector stretcher as the energy from the inertia by the DC three-phase motor executes the dump. Ever wondered why modern drives have open collectors on the databuss? Maybe to disconnect the power draw so that the motor now generator provides the needed power to complete the data dump... SEEMS to imply that some IDE drives at least have enough power left after power's off to store the write-cached data to disk. The rest of the email's not very reassuring, though, but note that this email's two years old. Anyone want to test? :) -- Linux homer 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux 4:30pm up 280 days, 8:00, 8 users, load average: 6.05, 6.01, 6.02 --------------enig78C486BCA5B58DFCB52BC8A0 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE/e+e1NYbTUIgzwfARAjjcAJ42ODNKuUZhif7LbuE6UXb4PGZAIwCg1UvR YXV2n7yeU5E4EjfWHKoF3Nk= =kdzz -----END PGP SIGNATURE----- --------------enig78C486BCA5B58DFCB52BC8A0-- From pgsql-novice-owner@postgresql.org Thu Oct 2 06:29:40 2003 X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5C730D1B4E1; Thu, 2 Oct 2003 09:29:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48682-07; Thu, 2 Oct 2003 06:28:49 -0300 (ADT) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by svr1.postgresql.org (Postfix) with ESMTP id 6A4EFD1B4F0; Thu, 2 Oct 2003 06:28:46 -0300 (ADT) 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 <20031002092843.VSTZ23248.lakemtao01.cox.net@lhosts>; Thu, 2 Oct 2003 05:28:43 -0400 Subject: basket, eggs & NAS (was eggs Re: Ideal Hardware?) From: Ron Johnson To: PgSQL Performance ML , PgSQL Novice ML In-Reply-To: References: Content-Type: text/plain Message-Id: <1065086923.27013.15.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Thu, 02 Oct 2003 04:28:43 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/24 X-Sequence-Number: 8461 On Wed, 2003-10-01 at 10:13, Jason Hihn wrote: > We have an opportunity to purchase a new, top-notch database server. I am > wondering what kind of hardware is recommended? We're on Linux platforms and > kernels though. I remember a comment from Tom about how he was spending a > lot of time debugging problems which turned out to be hardware-related. I of > course would like to avoid that. > > In terms of numbers, we expect have an average of 100 active connections > (most of which are idle 9/10ths of the time), with about 85% reading > traffic. I expect the database with flow average 10-20kBps under moderate > load. I hope to have one server host about 1000-2000 active databases, with > the largest being about 60 meg (no blobs). Inactive databases will only be > for reading (archival) purposes, and will seldom be accessed. Whoever mentioned using multiple servers instead of one uber-server is very right. You're putting all your eggs in one basket that way, and unless that "basket" has hot-swap CPUs, memory boards, etc, etc, then if you have a hardware problem, your whole business goes down. Buy 3 or 4 smaller systems, and distribute any possible pain from down time. It seems like I'm going to contravene what I just said about eggs in a basket when I suggest that the disks could possibly be concen- trated into a NAS, so that you could get 1 big, honkin fast *hot- swappable* (dual-redundant U320 storage controllers w/ 512MB battery- backed cache each, for a total of 1GB cache are easily available) disk subsystem for however many smaller CPU-boxes you get. (They could be kept un-shared by making separate partitions, and each machine only mounts one partition.) -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "Adventure is a sign of incompetence" Stephanson, great polar explorer From pgsql-performance-owner@postgresql.org Thu Oct 2 11:24:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BEBCFD1B4FB for ; Thu, 2 Oct 2003 13:40:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 93668-06 for ; Thu, 2 Oct 2003 10:39:20 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id 85C1BD1B4EE for ; Thu, 2 Oct 2003 10:39:14 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h92DdDlB063937 for ; Thu, 2 Oct 2003 16:39:14 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h92DdBiB063934 for ; Thu, 2 Oct 2003 16:39:13 +0300 (EEST) (envelope-from ant@imt.com.ua) X-Authentication-Warning: pool.imt.com.ua: ant owned process doing -bs Date: Thu, 2 Oct 2003 16:39:11 +0300 (EEST) From: Andriy Tkachuk To: pgsql-performance@postgresql.org Subject: runtime of the same query in function differs on 2 degree! Message-ID: <20031002163005.N53420-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/47 X-Sequence-Number: 3795 Hi folks. What's wrong with planner that executes my query in function?: (i mean no explanation but runtime) tele=# EXPLAIN analyze select calc_total(6916799, 1062363600, 1064955599); QUERY PLAN ------------------------------------------------------------------------------------------ Result (cost=0.00..0.01 rows=1 width=0) (actual time=36919.37..36919.37 rows=1 loops=1) Total runtime: 36919.40 msec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tele=# \df+ calc_total ... declare usr alias for $1; d1 alias for $2; d2 alias for $3; res integer; begin select sum(cost) into res from bills where (parent(user_id) = usr or user_id = usr) and dat >= d1 and dat < d2; if res is not null then return res; else return 0; end if; end; tele=# EXPLAIN analyze select sum(cost) from bills where (parent(user_id) = 6916799 or user_id = 6916799) and dat >= 1062363600 and dat < 10649555 99; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ Aggregate (cost=17902.80..17902.80 rows=1 width=4) (actual time=101.04..101.04 rows=1 loops=1) -> Index Scan using bills_parent_user_id_idx, bills_userid_dat_idx on bills (cost=0.00..17901.11 rows=679 width=4) (actual time=101.03..101.0 3 rows=0 loops=1) Index Cond: ((parent(user_id) = 6916799) OR ((user_id = 6916799) AND (dat >= 1062363600) AND (dat < 1064955599))) Filter: (((parent(user_id) = 6916799) OR (user_id = 6916799)) AND (dat >= 1062363600) AND (dat < 1064955599)) Total runtime: 101.14 msec ^^^^^^^^^^^^^^^^^^^^^^^^^^ So the query is the same as in calc_total(usr,d1,d2) function, but execute time extremely differs. Is it normal? Thanks, Andriy Tkachuk. From pgsql-performance-owner@postgresql.org Thu Oct 2 11:34:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 12EC5D1B51D for ; Thu, 2 Oct 2003 14:31:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96998-09 for ; Thu, 2 Oct 2003 11:31:13 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id A972FD1B542 for ; Thu, 2 Oct 2003 11:31:08 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Thu, 2 Oct 2003 08:29:52 -0600 From: Oleg Lebedev Cc: Josh Berkus , "scott.marlowe" , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 08:29:52 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731E783A@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/49 X-Sequence-Number: 3797 I ran VACUUM FULL ANALYZE yesterday and the re-ran the query with EXPLAIN ANALYZE. I got the same query plan and execution time.=20 -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Wednesday, October 01, 2003 4:20 PM To: Oleg Lebedev Cc: Josh Berkus; scott.marlowe; pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Oleg Lebedev writes: > All right, my query just finished running with EXPLAIN ANALYZE. I show > the plan below and also attached it as a file. Any ideas? Uh, have you done an ANALYZE (or VACUUM ANALYZE) on this database? It sure looks like the planner thinks the tables are a couple of orders of magnitude smaller than they actually are. Certainly the estimated sizes of the joins are way off :-( If you did analyze, it might help to increase the statistics target and re-analyze. regards, tom lane ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Thu Oct 2 12:31:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4EA20D1B4F2 for ; Thu, 2 Oct 2003 15:31:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17850-02 for ; Thu, 2 Oct 2003 12:30:45 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 42C8BD1B4E1 for ; Thu, 2 Oct 2003 12:30:45 -0300 (ADT) 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 h92FUVhn027543; Thu, 2 Oct 2003 11:30:31 -0400 (EDT) To: Andriy Tkachuk Cc: pgsql-performance@postgresql.org Subject: Re: runtime of the same query in function differs on 2 degree! In-reply-to: <20031002163005.N53420-100000@pool.imt.com.ua> References: <20031002163005.N53420-100000@pool.imt.com.ua> Comments: In-reply-to Andriy Tkachuk message dated "Thu, 02 Oct 2003 16:39:11 +0300" Date: Thu, 02 Oct 2003 11:30:31 -0400 Message-ID: <27542.1065108631@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/50 X-Sequence-Number: 3798 Andriy Tkachuk writes: > What's wrong with planner that executes my query in function?: > tele=# EXPLAIN analyze select sum(cost) from bills where (parent(user_id) = 6916799 or user_id = 6916799) and dat >= 1062363600 and dat < 10649555 > 99; In the function case, the planner will not have access to the specific values that "dat" is being compared to --- it'll see something like ... and dat >= $1 and dat < $2 In this case it has to fall back on a default estimate of how many rows will be selected, and I suspect it's guessing that a seqscan will be faster. The trouble is that for a sufficiently large range of d1/d2, a seqscan *will* be faster. You might find that the best solution is to use FOR ... EXECUTE and plug the parameters into the query string so that the planner can see their values. This will mean re-planning on every function call, but the advantage is the plan will adapt to the actual range of d1/d2. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 2 13:20:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 63FB0D1B53F for ; Thu, 2 Oct 2003 16:20:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 27920-06 for ; Thu, 2 Oct 2003 13:19:29 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id 95FC8D1B552 for ; Thu, 2 Oct 2003 13:19:12 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Thu, 2 Oct 2003 10:18:00 -0600 From: Oleg Lebedev To: "scott.marlowe" Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 10:18:00 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7624@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=MIME_BOUND_NEXTPART, MIME_SUSPECT_NAME, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/51 X-Sequence-Number: 3799 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable As Scott recommended, I did the following: # set enable_nestloop =3D false; # vacuum full analyze; After this I re-ran the query and its execution time went down from 2 hours to 2 minutes. I attached the new query plan to this posting. Is there any way to optimize it even further? What should I do to make this query run fast without hurting the performance of the other queries? Thanks. Oleg -----Original Message----- From: scott.marlowe [mailto:scott.marlowe@ihs.com]=20 Sent: Wednesday, October 01, 2003 4:00 PM To: Oleg Lebedev Cc: Josh Berkus; pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks For troubleshooting, can you try it with "set enable_nestloop =3D false" and=20 rerun the query and see how long it takes?=20=20 It looks like the estimates of rows returned is WAY off (estimate is too low compared to what really comes back.) Also, you might try to alter the table.column to have a higher target on the rows p_partkey and ps_partkey and any others where the estimate is so=20 far off of the reality. On Wed, 1 Oct 2003, Oleg Lebedev wrote: > All right, my query just finished running with EXPLAIN ANALYZE. I show > the plan below and also attached it as a file. Any ideas? >=20 > -> Sort (cost=3D54597.49..54597.50 rows=3D1 width=3D121) (actual=20 > time=3D6674562.03..6674562.15 rows=3D175 loops=3D1) > Sort Key: nation.n_name, date_part('year'::text, > orders.o_orderdate) > -> Aggregate (cost=3D54597.45..54597.48 rows=3D1 width=3D121)= =20 > (actual time=3D6668919.41..6674522.48 rows=3D175 loops=3D1) > -> Group (cost=3D54597.45..54597.47 rows=3D3 width=3D121= )=20 > (actual time=3D6668872.68..6672136.96 rows=3D348760 loops=3D1) > -> Sort (cost=3D54597.45..54597.46 rows=3D3 > width=3D121) (actual time=3D6668872.65..6669499.95 rows=3D348760 loops=3D= 1) > Sort Key: nation.n_name,=20 > date_part('year'::text, orders.o_orderdate) > -> Hash Join (cost=3D54596.00..54597.42=20 > rows=3D3 > width=3D121) (actual time=3D6632768.89..6650192.67 rows=3D348760 loops=3D= 1) > Hash Cond: ("outer".n_nationkey =3D > "inner".s_nationkey) > -> Seq Scan on nation=20 > (cost=3D0.00..1.25 rows=3D25 width=3D33) (actual time=3D6.75..7.13 rows= =3D25 > loops=3D1) > -> Hash (cost=3D54596.00..54596.00=20 > rows=3D3 > width=3D88) (actual time=3D6632671.96..6632671.96 rows=3D0 loops=3D1) > -> Nested Loop=20 > (cost=3D0.00..54596.00 rows=3D3 width=3D88) (actual time=3D482.41..663060= 1.46=20 > rows=3D348760 loops=3D1) > Join Filter:=20 > ("inner".s_suppkey =3D "outer".l_suppkey) > -> Nested Loop=20 > (cost=3D0.00..54586.18 rows=3D3 width=3D80) (actual time=3D383.87..659498= 4.40=20 > rows=3D348760 loops=3D1) > -> Nested Loop=20 > (cost=3D0.00..54575.47 rows=3D4 width=3D68) (actual time=3D199.95..358088= 2.07=20 > rows=3D348760 loops=3D1) > Join Filter:=20 > ("outer".p_partkey =3D "inner".ps_partkey) > -> Nested=20 > Loop (cost=3D0.00..22753.33 rows=3D9343 width=3D49) (actual=20 > time=3D146.85..3541433.10 rows=3D348760 loops=3D1) > -> Seq > Scan on part (cost=3D0.00..7868.00 rows=3D320 width=3D4) (actual=20 > time=3D33.64..15651.90 rows=3D11637 loops=3D1) >=20 > Filter: (p_name ~~ '%green%'::text) > ->=20=20 > Index Scan using i_l_partkey on lineitem (cost=3D0.00..46.15 rows=3D29= =20 > width=3D45) (actual time=3D10.71..302.67 rows=3D30 loops=3D11637) >=20=20 > Index > Cond: ("outer".p_partkey =3D lineitem.l_partkey) > -> Index=20 > Scan using pk_partsupp on partsupp (cost=3D0.00..3.39 rows=3D1 width=3D1= 9)=20 > (actual time=3D0.09..0.09 rows=3D1 loops=3D348760) > Index > Cond: ((partsupp.ps_partkey =3D "outer".l_partkey) AND=20 > (partsupp.ps_suppkey =3D > "outer".l_suppkey)) > -> Index Scan=20 > using pk_orders on orders (cost=3D0.00..3.01 rows=3D1 width=3D12) (actua= l=20 > time=3D8.62..8.62 rows=3D1 loops=3D348760) > Index Cond:=20 > (orders.o_orderkey =3D "outer".l_orderkey) > -> Index Scan using=20 > pk_supplier on supplier (cost=3D0.00..3.01 rows=3D1 width=3D8) (actual= =20 > time=3D0.08..0.08 rows=3D1 loops=3D348760) > Index Cond:=20 > ("outer".ps_suppkey =3D supplier.s_suppkey) Total runtime: 6674724.23=20 > msec (28 rows) >=20 >=20 > -----Original Message----- > From: Oleg Lebedev > Sent: Wednesday, October 01, 2003 12:00 PM > To: Josh Berkus; scott.marlowe > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks > Importance: Low >=20 >=20 > Sure, below is the query. I attached the plan to this posting. >=20 > select > nation, > o_year, > sum(amount) as sum_profit > from > ( > select > n_name as nation, > extract(year from o_orderdate) as o_year, > l_extendedprice * (1 - l_discount) - > ps_supplycost * l_quantity as amount > from > part, > supplier, > lineitem, > partsupp, > orders, > nation > where > s_suppkey =3D l_suppkey > and ps_suppkey =3D l_suppkey > and ps_partkey =3D l_partkey > and p_partkey =3D l_partkey > and o_orderkey =3D l_orderkey > and s_nationkey =3D n_nationkey > and p_name like '%green%' > ) as profit > group by > nation, > o_year > order by > nation, > o_year desc; >=20 >=20 > -----Original Message----- > From: Josh Berkus [mailto:josh@agliodbs.com] > Sent: Wednesday, October 01, 2003 11:42 AM > To: Oleg Lebedev; scott.marlowe > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks >=20 >=20 > Oleg, >=20 > > The output of the query should contain about 200 rows. So, I guess=20 > > the >=20 > > planer is off assuming that the query should return 1 row. >=20 > Oh, also did you post the query before? Can you re-post it with the > planner > results? >=20 >=20 ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="new_plan_explained.txt" Content-Disposition: attachment; filename="new_plan_explained.txt" Content-Transfer-Encoding: base64 LT4gIFNvcnQgIChjb3N0PTM2MDYzMC4xNi4uMzYwNjMwLjE2IHJvd3M9MSB3 aWR0aD0xMjEpIChhY3R1YWwgdGltZT0xMTkwMzkuMTUuLjExOTAzOS4yNyBy b3dzPTE3NSBsb29wcz0xKQ0KICAgICAgICAgU29ydCBLZXk6IG5hdGlvbi5u X25hbWUsIGRhdGVfcGFydCgneWVhcic6OnRleHQsDQpvcmRlcnMub19vcmRl cmRhdGUpDQogICAgICAgICAtPiAgQWdncmVnYXRlICAoY29zdD0zNjA2MzAu MTMuLjM2MDYzMC4xNSByb3dzPTEgd2lkdGg9MTIxKSAoYWN0dWFsIHRpbWU9 MTEzNTE1Ljk2Li4xMTkwMzcuNTAgcm93cz0xNzUgbG9vcHM9MSkNCiAgICAg ICAgICAgICAgIC0+ICBHcm91cCAgKGNvc3Q9MzYwNjMwLjEzLi4zNjA2MzAu MTQgcm93cz0yIHdpZHRoPTEyMSkgKGFjdHVhbCB0aW1lPTExMzQ4MS4xMi4u MTE2NzI4LjM4IHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQogICAgICAgICAgICAg ICAgICAgICAtPiAgU29ydCAgKGNvc3Q9MzYwNjMwLjEzLi4zNjA2MzAuMTMg cm93cz0yDQp3aWR0aD0xMjEpIChhY3R1YWwgdGltZT0xMTM0ODEuMTAuLjEx NDA5NS45NCByb3dzPTM0ODc2MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgU29ydCBLZXk6IG5hdGlvbi5uX25hbWUsIGRhdGVfcGFy dCgneWVhcic6OnRleHQsIG9yZGVycy5vX29yZGVyZGF0ZSkNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTM2MDYy OC43Mi4uMzYwNjMwLjEyIHJvd3M9MiB3aWR0aD0xMjEpIChhY3R1YWwgdGlt ZT05MjQzMC4xOS4uOTUyMzAuNjggcm93cz0zNDg3NjAgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJv dXRlciIubl9uYXRpb25rZXkgPQ0KImlubmVyIi5zX25hdGlvbmtleSkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBv biBuYXRpb24gIChjb3N0PTAuMDAuLjEuMjUgcm93cz0yNSB3aWR0aD0zMykg KGFjdHVhbCB0aW1lPTkuNTUuLjkuOTcgcm93cz0yNSBsb29wcz0xKQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEhhc2ggIChjb3N0 PTM2MDYyOC43Mi4uMzYwNjI4LjcyIHJvd3M9MiB3aWR0aD04OCkgKGFjdHVh bCB0aW1lPTkyNDIwLjQ0Li45MjQyMC40NCByb3dzPTAgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBIYXNo IEpvaW4gKGNvc3Q9MzA2NjY5LjY5Li4zNjA2MjguNzIgcm93cz0yIHdpZHRo PTg4KSAoYWN0dWFsIHRpbWU9NTM0NzQuNTEuLjkxMzU1Ljc0IHJvd3M9MzQ4 NzYwIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLm9fb3JkZXJrZXkg PSAiaW5uZXIiLmxfb3JkZXJrZXkpDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gb3JkZXJz IChjb3N0PTAuMDAuLjQ2NDU5LjAwIHJvd3M9MTUwMDAwMCB3aWR0aD0xMikg KGFjdHVhbCB0aW1lPTEwLjg3Li42Mjk4LjYyIHJvd3M9MTUwMDAwMCBsb29w cz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIEhhc2ggKGNvc3Q9MzA2NjY5LjY5Li4zMDY2NjkuNjkgcm93 cz0yIHdpZHRoPTc2KSAoYWN0dWFsIHRpbWU9NTM0NjMuNDMuLjUzNDYzLjQz IHJvd3M9MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEhhc2ggSm9pbiAoY29zdD00 MDYxOC45MS4uMzA2NjY5LjY5IHJvd3M9MiB3aWR0aD03NikgKGFjdHVhbCB0 aW1lPTU2MzMuNjAuLjUyMjkxLjc4IHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLmxfcGFydGtleSA9ICJp bm5lciIucHNfcGFydGtleSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEpvaW4gRmlsdGVyOiAo ImlubmVyIi5zX3N1cHBrZXkgPSAib3V0ZXIiLmxfc3VwcGtleSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIC0+ICBTZXEgU2NhbiBvbiBsaW5laXRlbSAoY29zdD0wLjAwLi4y MzU2MjAuMTUgcm93cz02MDAxMjE1IHdpZHRoPTQ1KSAoYWN0dWFsIHRpbWU9 MjEuMTAuLjI1Njg2LjIwIHJvd3M9NjAwMTIxNSBsb29wcz0xKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIEhhc2ggKGNvc3Q9NDA2MTUuNzYuLjQwNjE1Ljc2IHJvd3M9 MTI2MSB3aWR0aD0zMSkgKGFjdHVhbCB0aW1lPTU2MTIuMDYuLjU2MTIuMDYg cm93cz0wIGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSGFzaCBK b2luICAoY29zdD00MDE3NC4wMC4uNDA2MTUuNzYgcm93cz0xMjYxIHdpZHRo PTMxKSAoYWN0dWFsIHRpbWU9NTIzNS4xOC4uNTUyOC41NSByb3dzPTQ2NTQ4 IGxvb3BzPTEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBIYXNoDQpDb25k OiAoIm91dGVyIi5zX3N1cHBrZXkgPSAiaW5uZXIiLnBzX3N1cHBrZXkpDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAtPiBTZXEgU2NhbiBvbiBzdXBwbGll ciAgKGNvc3Q9MC4wMC4uMzUxLjAwIHJvd3M9MTAwMDAgd2lkdGg9OCkgKGFj dHVhbCB0aW1lPTI0LjYwLi4xNzAuODEgcm93cz0xMDAwMCBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLT4gSGFzaCAgKGNvc3Q9NDAxNzAu ODAuLjQwMTcwLjgwIHJvd3M9MTI4MCB3aWR0aD0yMykgKGFjdHVhbCB0aW1l PTUyMTAuMjQuLjUyMTAuMjQgcm93cz0wIGxvb3BzPTEpDQoNCi0+ICBIYXNo IEpvaW4gIChjb3N0PTc4NjcuODAuLjQwMTcwLjgwIHJvd3M9MTI4MCB3aWR0 aD0yMykgKGFjdHVhbA0KdGltZT0xMjE1Ljk2Li41MTA4LjM1IHJvd3M9NDY1 NDggbG9vcHM9MSkNCg0KSGFzaCBDb25kOiAoIm91dGVyIi5wc19wYXJ0a2V5 ID0gImlubmVyIi5wX3BhcnRrZXkpDQoNCi0+ICBTZXEgU2NhbiBvbiBwYXJ0 c3VwcCAgKGNvc3Q9MC4wMC4uMjYyODcuMDAgcm93cz04MDAwMDAgd2lkdGg9 MTkpDQooYWN0dWFsIHRpbWU9MC4wMS4uMjc4NC4xMiByb3dzPTgwMDAwMCBs b29wcz0xKQ0KDQotPiAgSGFzaCAgKGNvc3Q9Nzg2Ny4wMC4uNzg2Ny4wMCBy b3dzPTMyMCB3aWR0aD00KSAoYWN0dWFsDQp0aW1lPTEyMTUuMzguLjEyMTUu Mzggcm93cz0wIGxvb3BzPTEpDQoNCiAgICAtPiAgU2VxIFNjYW4gb24gcGFy dCAgKGNvc3Q9MC4wMC4uNzg2Ny4wMCByb3dzPTMyMCB3aWR0aD00KSAoYWN0 dWFsIHRpbWU9MTEuNjQuLjExODcuMzcgcm93cz0xMTYzNyBsb29wcz0xKQ0K DQogICAgICAgICAgRmlsdGVyOiAocF9uYW1lIH5+ICclZ3JlZW4lJzo6dGV4 dCkNCiBUb3RhbCBydW50aW1lOiAxMTkwNTguMzQgbXNlYw0KKDMxIHJvd3Mp DQoNCg== --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Thu Oct 2 13:24:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 12F45D1B508 for ; Thu, 2 Oct 2003 16:24:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29206-01 for ; Thu, 2 Oct 2003 13:23:27 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D5415D1B514 for ; Thu, 2 Oct 2003 13:23:26 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3707275; Thu, 02 Oct 2003 09:24:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 09:22:20 -0700 User-Agent: KMail/1.4.3 Cc: "scott.marlowe" , "pgsql-performance@postgresql.org" References: <993DBE5B4D02194382EC8DF8554A52731E783A@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731E783A@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310020922.20124.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/52 X-Sequence-Number: 3800 Oleg, > I ran VACUUM FULL ANALYZE yesterday and the re-ran the query with > EXPLAIN ANALYZE. > I got the same query plan and execution time. How about my question? Those rows from pg_stats would be really useful in diagnosing the problem. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 2 13:38:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3A445D1B54C for ; Thu, 2 Oct 2003 16:38:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 28649-05 for ; Thu, 2 Oct 2003 13:37:43 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id C5D3ED1B50D for ; Thu, 2 Oct 2003 13:37:42 -0300 (ADT) 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 h92GZnGQ019368; Thu, 2 Oct 2003 10:35:49 -0600 (MDT) Date: Thu, 2 Oct 2003 10:29:09 -0600 (MDT) From: "scott.marlowe" To: Oleg Lebedev Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7624@postoffice.waterford.org> 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: 200310/53 X-Sequence-Number: 3801 Have you tried increasing the statistics target for those columns that are getting bad estimates yet and then turning back on enable_nestloop and rerunning analyze and seeing how the query does? The idea being to try and get a good enough estimate of your statistics so the planner stops using nestloops on its own rather than forcing it to with enable_nestloop = false. On Thu, 2 Oct 2003, Oleg Lebedev wrote: > As Scott recommended, I did the following: > # set enable_nestloop = false; > # vacuum full analyze; > > After this I re-ran the query and its execution time went down from 2 > hours to 2 minutes. I attached the new query plan to this posting. > Is there any way to optimize it even further? > What should I do to make this query run fast without hurting the > performance of the other queries? > Thanks. > > Oleg > > -----Original Message----- > From: scott.marlowe [mailto:scott.marlowe@ihs.com] > Sent: Wednesday, October 01, 2003 4:00 PM > To: Oleg Lebedev > Cc: Josh Berkus; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks > > > For troubleshooting, can you try it with "set enable_nestloop = false" > and > rerun the query and see how long it takes? > > It looks like the estimates of rows returned is WAY off (estimate is too > > low compared to what really comes back.) > > Also, you might try to alter the table.column to have a higher target on > > the rows p_partkey and ps_partkey and any others where the estimate is > so > far off of the reality. > > On Wed, 1 Oct 2003, Oleg Lebedev wrote: > > > All right, my query just finished running with EXPLAIN ANALYZE. I show > > > the plan below and also attached it as a file. Any ideas? > > > > -> Sort (cost=54597.49..54597.50 rows=1 width=121) (actual > > time=6674562.03..6674562.15 rows=175 loops=1) > > Sort Key: nation.n_name, date_part('year'::text, > > orders.o_orderdate) > > -> Aggregate (cost=54597.45..54597.48 rows=1 width=121) > > (actual time=6668919.41..6674522.48 rows=175 loops=1) > > -> Group (cost=54597.45..54597.47 rows=3 width=121) > > (actual time=6668872.68..6672136.96 rows=348760 loops=1) > > -> Sort (cost=54597.45..54597.46 rows=3 > > width=121) (actual time=6668872.65..6669499.95 rows=348760 loops=1) > > Sort Key: nation.n_name, > > date_part('year'::text, orders.o_orderdate) > > -> Hash Join (cost=54596.00..54597.42 > > rows=3 > > width=121) (actual time=6632768.89..6650192.67 rows=348760 loops=1) > > Hash Cond: ("outer".n_nationkey = > > "inner".s_nationkey) > > -> Seq Scan on nation > > (cost=0.00..1.25 rows=25 width=33) (actual time=6.75..7.13 rows=25 > > loops=1) > > -> Hash (cost=54596.00..54596.00 > > rows=3 > > width=88) (actual time=6632671.96..6632671.96 rows=0 loops=1) > > -> Nested Loop > > (cost=0.00..54596.00 rows=3 width=88) (actual time=482.41..6630601.46 > > rows=348760 loops=1) > > Join Filter: > > ("inner".s_suppkey = "outer".l_suppkey) > > -> Nested Loop > > (cost=0.00..54586.18 rows=3 width=80) (actual time=383.87..6594984.40 > > rows=348760 loops=1) > > -> Nested Loop > > (cost=0.00..54575.47 rows=4 width=68) (actual time=199.95..3580882.07 > > rows=348760 loops=1) > > Join Filter: > > ("outer".p_partkey = "inner".ps_partkey) > > -> Nested > > Loop (cost=0.00..22753.33 rows=9343 width=49) (actual > > time=146.85..3541433.10 rows=348760 loops=1) > > -> Seq > > > Scan on part (cost=0.00..7868.00 rows=320 width=4) (actual > > time=33.64..15651.90 rows=11637 loops=1) > > > > Filter: (p_name ~~ '%green%'::text) > > -> > > Index Scan using i_l_partkey on lineitem (cost=0.00..46.15 rows=29 > > width=45) (actual time=10.71..302.67 rows=30 loops=11637) > > > > Index > > Cond: ("outer".p_partkey = lineitem.l_partkey) > > -> Index > > Scan using pk_partsupp on partsupp (cost=0.00..3.39 rows=1 width=19) > > (actual time=0.09..0.09 rows=1 loops=348760) > > Index > > Cond: ((partsupp.ps_partkey = "outer".l_partkey) AND > > (partsupp.ps_suppkey = > > "outer".l_suppkey)) > > -> Index Scan > > using pk_orders on orders (cost=0.00..3.01 rows=1 width=12) (actual > > time=8.62..8.62 rows=1 loops=348760) > > Index Cond: > > (orders.o_orderkey = "outer".l_orderkey) > > -> Index Scan using > > pk_supplier on supplier (cost=0.00..3.01 rows=1 width=8) (actual > > time=0.08..0.08 rows=1 loops=348760) > > Index Cond: > > ("outer".ps_suppkey = supplier.s_suppkey) Total runtime: 6674724.23 > > msec (28 rows) > > > > > > -----Original Message----- > > From: Oleg Lebedev > > Sent: Wednesday, October 01, 2003 12:00 PM > > To: Josh Berkus; scott.marlowe > > Cc: pgsql-performance@postgresql.org > > Subject: Re: [PERFORM] TPC-R benchmarks > > Importance: Low > > > > > > Sure, below is the query. I attached the plan to this posting. > > > > select > > nation, > > o_year, > > sum(amount) as sum_profit > > from > > ( > > select > > n_name as nation, > > extract(year from o_orderdate) as o_year, > > l_extendedprice * (1 - l_discount) - > > ps_supplycost * l_quantity as amount > > from > > part, > > supplier, > > lineitem, > > partsupp, > > orders, > > nation > > where > > s_suppkey = l_suppkey > > and ps_suppkey = l_suppkey > > and ps_partkey = l_partkey > > and p_partkey = l_partkey > > and o_orderkey = l_orderkey > > and s_nationkey = n_nationkey > > and p_name like '%green%' > > ) as profit > > group by > > nation, > > o_year > > order by > > nation, > > o_year desc; > > > > > > -----Original Message----- > > From: Josh Berkus [mailto:josh@agliodbs.com] > > Sent: Wednesday, October 01, 2003 11:42 AM > > To: Oleg Lebedev; scott.marlowe > > Cc: pgsql-performance@postgresql.org > > Subject: Re: [PERFORM] TPC-R benchmarks > > > > > > Oleg, > > > > > The output of the query should contain about 200 rows. So, I guess > > > the > > > > > planer is off assuming that the query should return 1 row. > > > > Oh, also did you post the query before? Can you re-post it with the > > planner > > results? > > > > > > ************************************* > > This e-mail may contain privileged or confidential material intended for the named recipient only. > If you are not the named recipient, delete this message and all attachments. > Unauthorized reviewing, copying, printing, disclosing, or otherwise using information in this e-mail is prohibited. > We reserve the right to monitor e-mail sent through our network. > > ************************************* > From pgsql-performance-owner@postgresql.org Fri Oct 3 11:55:05 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 21CBFD1B4E2 for ; Thu, 2 Oct 2003 17:04:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32891-07 for ; Thu, 2 Oct 2003 14:03:18 -0300 (ADT) Received: from cbnsitar.cbnco.com (unknown [207.164.182.16]) by svr1.postgresql.org (Postfix) with ESMTP id 98634D1B4FB for ; Thu, 2 Oct 2003 14:03:15 -0300 (ADT) Received: (from root@localhost) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) id h92H1pD12196 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 13:01:51 -0400 Received: from mail.cbnco.com (hermes.cbnco.com [207.164.182.47]) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) with SMTP id h92H1oi12189 for ; Thu, 2 Oct 2003 13:01:50 -0400 From: rwu.cbnco.com@cbnco.com Received: from 207.164.182.8 (SquirrelMail authenticated user rwu.cbnco.com) by mail.cbnco.com with HTTP; Thu, 2 Oct 2003 13:03:13 -0400 (EDT) Message-ID: <33197.207.164.182.8.1065114193.squirrel@mail.cbnco.com> Date: Thu, 2 Oct 2003 13:03:13 -0400 (EDT) Subject: low cardinality column 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-Scanned-By: MIMEDefang 2.24 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS 0.3.12pre6 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, PRIORITY_NO_NAME, USER_AGENT X-Spam-Level: * X-Archive-Number: 200310/86 X-Sequence-Number: 3834 Hi, I have a select like this: SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; in the query: transactionid is the primary key of cbntransaction table, But transactiontypeid is a low cardinality column, there're over 100,000 records has the same trnsactiontypeid. I was trying to create an index on (transactiontypeid, transactionid), but no luck on that, postgresql will still scan the table. I'm wondering if there's solution for this query: Maybe something like if I can partition the table using transactiontypeid, and do a local index on transactionid on each partition, but I couldnt' find any doc on postgresql to do that. Thanks in advance, rong :-) From pgsql-performance-owner@postgresql.org Thu Oct 2 15:30:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6897BD1B522 for ; Thu, 2 Oct 2003 18:30:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 43380-10 for ; Thu, 2 Oct 2003 15:30:02 -0300 (ADT) Received: from cbnsitar.cbnco.com (unknown [207.164.182.16]) by svr1.postgresql.org (Postfix) with ESMTP id 51666D1B533 for ; Thu, 2 Oct 2003 15:30:01 -0300 (ADT) Received: (from root@localhost) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) id h92IScV14418 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 14:28:38 -0400 Received: from mail.cbnco.com (hermes.cbnco.com [207.164.182.47]) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) with SMTP id h92ISbi14410 for ; Thu, 2 Oct 2003 14:28:37 -0400 Received: from 207.164.182.8 (SquirrelMail authenticated user rwu.cbnco.com) by mail.cbnco.com with HTTP; Thu, 2 Oct 2003 14:30:01 -0400 (EDT) Message-ID: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> Date: Thu, 2 Oct 2003 14:30:01 -0400 (EDT) Subject: low cardinality column From: "Rong Wu" To: pgsql-performance@postgresql.org Reply-To: rwu@cbnco.com 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-Scanned-By: MIMEDefang 2.24 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS 0.3.12pre6 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME, USER_AGENT X-Spam-Level: X-Archive-Number: 200310/54 X-Sequence-Number: 3802 Hi, I have a select like this: SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; in the query: transactionid is the primary key of cbntransaction table, But transactiontypeid is a low cardinality column, there're over 100,000 records has the same trnsactiontypeid. I was trying to create an index on (transactiontypeid, transactionid), but no luck on that, postgresql will still scan the table. I'm wondering if there's solution for this query: Maybe something like if I can partition the table using transactiontypeid, and do a local index on transactionid on each partition, but I couldnt' find any doc on postgresql to do that. Thanks in advance, rong :-) From pgsql-performance-owner@postgresql.org Thu Oct 2 15:40:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 84AB1D1B514 for ; Thu, 2 Oct 2003 18:40:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53979-01 for ; Thu, 2 Oct 2003 15:40:07 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 16945D1B4EF for ; Thu, 2 Oct 2003 15:40:06 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3707726; Thu, 02 Oct 2003 11:39:50 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: rwu@cbnco.com, pgsql-performance@postgresql.org Subject: Re: low cardinality column Date: Thu, 2 Oct 2003 11:37:22 -0700 User-Agent: KMail/1.4.3 References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> In-Reply-To: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310021137.22119.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/55 X-Sequence-Number: 3803 Rong, > I have a select like this: >=20 > SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=3D0; Simple workaround: Create an mulit-column index on transactiontypeid, transactionid. SELECT transactionid FROM cbtransaction=20 WHERE transactiontypeid=3D0 ORDER BY transactionid DESC LIMIT 1; This approach will use the index. Of course, if the reason you are selecting the max id is to get the next id= ,=20 there are much better ways to do that. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 2 15:51:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EBC75D1B4F6 for ; Thu, 2 Oct 2003 18:51:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53753-06 for ; Thu, 2 Oct 2003 15:50:37 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id A09D5D1B4EA for ; Thu, 2 Oct 2003 15:50:20 -0300 (ADT) Received: (qmail 26071 invoked from network); 2 Oct 2003 18:50:06 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 2 Oct 2003 18:50:06 -0000 Subject: Re: low cardinality column From: Rod Taylor To: rwu@cbnco.com Cc: Postgresql Performance In-Reply-To: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-w0mXFtaGiVZsl8Aqdhey" Message-Id: <1065120643.89807.40.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 02 Oct 2003 14:50:44 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/56 X-Sequence-Number: 3804 --=-w0mXFtaGiVZsl8Aqdhey Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-10-02 at 14:30, Rong Wu wrote: > Hi, >=20 > I have a select like this: >=20 > SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=3D0; For various reasons (primarily MVCC and the ability to make custom aggregates making it difficult) MAX() is not optimized in this fashion. Try: SELECT transactionid FROM ... WHERE ... ORDER BY transactionid DESC LIMIT 1; --=-w0mXFtaGiVZsl8Aqdhey Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/fHOD6DETLow6vwwRAvQ9AJ93uI6ST8WDbKxNzUHf67xHwAOL6QCfd2y8 vQJfn+GLC/XEjy0+358IQxc= =42Nw -----END PGP SIGNATURE----- --=-w0mXFtaGiVZsl8Aqdhey-- From pgsql-performance-owner@postgresql.org Thu Oct 2 16:01:28 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4CC84D1B4EA for ; Thu, 2 Oct 2003 19:01:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53374-09 for ; Thu, 2 Oct 2003 16:00:40 -0300 (ADT) Received: from mta9.adelphia.net (mta9.adelphia.net [68.168.78.199]) by svr1.postgresql.org (Postfix) with ESMTP id 19FA2D1B522 for ; Thu, 2 Oct 2003 16:00:24 -0300 (ADT) Received: from potentialtech.com ([24.53.179.151]) by mta9.adelphia.net (InterMail vM.5.01.05.32 201-253-122-126-132-20030307) with ESMTP id <20031002190022.URU20786.mta9.adelphia.net@potentialtech.com>; Thu, 2 Oct 2003 15:00:22 -0400 Message-ID: <3F7C75C3.4060904@potentialtech.com> Date: Thu, 02 Oct 2003 15:00:19 -0400 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3) Gecko/20030429 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: rwu@cbnco.com, Postgresql Performance Subject: Re: low cardinality column References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> <1065120643.89807.40.camel@jester> In-Reply-To: <1065120643.89807.40.camel@jester> 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: 200310/57 X-Sequence-Number: 3805 Rod Taylor wrote: > On Thu, 2003-10-02 at 14:30, Rong Wu wrote: > >>Hi, >> >>I have a select like this: >> >>SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; > > > For various reasons (primarily MVCC and the ability to make custom > aggregates making it difficult) MAX() is not optimized in this fashion. > > Try: > > SELECT transactionid > FROM ... > WHERE ... > ORDER BY transactionid DESC > LIMIT 1; Despite this good suggestion, if you're using this technique to generate the next transaction ID, you're going to have errors as concurrency rises. Use a SERIAL, which guarantees that you won't have two processes generate the same number. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Thu Oct 2 16:16:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0AFDCD1B4EF for ; Thu, 2 Oct 2003 19:16:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64020-01 for ; Thu, 2 Oct 2003 16:16:03 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id EB6E1D1B552 for ; Thu, 2 Oct 2003 16:16:01 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id DB4745FE8 for ; Thu, 2 Oct 2003 19:15:47 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h92JFl9d094291 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 12:15:47 -0700 (PDT) (envelope-from dror) Date: Thu, 2 Oct 2003 12:15:47 -0700 From: Dror Matalon To: "pgsql-performance@postgresql.org" Subject: count(*) slow on large tables Message-ID: <20031002191547.GZ87525@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200310/58 X-Sequence-Number: 3806 Hi, I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a count(*) takes around 40 seconds. Looks like the count(*) fetches the table from disk and goes through it. Made me wonder, why the optimizer doesn't just choose the smallest index which in my case is around 60 Megs and goes through it, which it could do in a fraction of the time. Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Oct 2 16:43:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3D440D1B514 for ; Thu, 2 Oct 2003 19:43:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64293-07 for ; Thu, 2 Oct 2003 16:42:45 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id DE400D1B4E1 for ; Thu, 2 Oct 2003 16:42:43 -0300 (ADT) 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 h92JfvGQ005589 for ; Thu, 2 Oct 2003 13:41:58 -0600 (MDT) Date: Thu, 2 Oct 2003 13:34:16 -0600 (MDT) From: "scott.marlowe" To: Postgresql Performance Subject: further testing on IDE drives 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-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=RCVD_IN_OSIRUSOFT_COM, USER_AGENT_PINE X-Spam-Level: X-Archive-Number: 200310/62 X-Sequence-Number: 3810 I was testing to get some idea of how to speed up the speed of pgbench with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 /dev/hdx). The only parameter that seems to make a noticeable difference was setting wal_sync_method = open_sync. With it set to either fsync, or fdatasync, the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync it jumped to the range of 45 to 52 tps. with write cache on I was getting 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only about 5 times slower, much better. Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord and see if the data gets corrupted with write caching turned on, i.e. do my hard drives have the ability to write at least some of their cache during spin down. From pgsql-performance-owner@postgresql.org Thu Oct 2 16:39:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7AC9BD1B533 for ; Thu, 2 Oct 2003 19:39:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64538-04 for ; Thu, 2 Oct 2003 16:38:55 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id EBBB8D1B4E1 for ; Thu, 2 Oct 2003 16:38:50 -0300 (ADT) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 9CB8C2B3CC; Thu, 2 Oct 2003 21:37:13 +0200 (CEST) Message-ID: <3F7C7E4A.9080803@klaster.net> Date: Thu, 02 Oct 2003 21:36:42 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5) Gecko/20030916 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Dror Matalon Cc: "pgsql-performance@postgresql.org" Subject: Re: count(*) slow on large tables References: <20031002191547.GZ87525@rlx11.zapatec.com> In-Reply-To: <20031002191547.GZ87525@rlx11.zapatec.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT_MOZILLA_UA X-Spam-Level: X-Archive-Number: 200310/60 X-Sequence-Number: 3808 > Hi, > > I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a > count(*) takes around 40 seconds. > > Looks like the count(*) fetches the table from disk and goes through it. > Made me wonder, why the optimizer doesn't just choose the smallest index > which in my case is around 60 Megs and goes through it, which it could > do in a fraction of the time. > > Dror Just like other aggregate functions, count(*) won't use indexes when counting whole table. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Thu Oct 2 16:32:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6417AD1B51D for ; Thu, 2 Oct 2003 19:32:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 56864-09 for ; Thu, 2 Oct 2003 16:31:50 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 0C6F6D1B4E1 for ; Thu, 2 Oct 2003 16:31:48 -0300 (ADT) Received: (qmail 18747 invoked by uid 500); 2 Oct 2003 19:39:05 -0000 Date: Thu, 2 Oct 2003 14:39:05 -0500 From: Bruno Wolff III To: Dror Matalon Cc: "pgsql-performance@postgresql.org" Subject: Re: count(*) slow on large tables Message-ID: <20031002193905.GD18417@wolff.to> Mail-Followup-To: Dror Matalon , "pgsql-performance@postgresql.org" References: <20031002191547.GZ87525@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031002191547.GZ87525@rlx11.zapatec.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/59 X-Sequence-Number: 3807 On Thu, Oct 02, 2003 at 12:15:47 -0700, Dror Matalon wrote: > Hi, > > I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a > count(*) takes around 40 seconds. > > Looks like the count(*) fetches the table from disk and goes through it. > Made me wonder, why the optimizer doesn't just choose the smallest index > which in my case is around 60 Megs and goes through it, which it could > do in a fraction of the time. Because it can't tell from the index if a tuple is visible to the current transaction and would still have to hit the table to check this. So that performance would be a lot worse instead of better. From pgsql-performance-owner@postgresql.org Thu Oct 2 16:41:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9BF41D1B514 for ; Thu, 2 Oct 2003 19:41:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64498-05 for ; Thu, 2 Oct 2003 16:41:09 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id D7B4DD1B533 for ; Thu, 2 Oct 2003 16:41:06 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Thu, 2 Oct 2003 13:39:56 -0600 From: Oleg Lebedev To: "scott.marlowe" Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 13:39:55 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7627@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/61 X-Sequence-Number: 3809 This is a multi part message in MIME format. --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I was trying to get the pg_stats information to Josh and decided to recreate the indexes on all my tables. After that I ran vacuum full analyze, re-enabled nestloop and ran explain analyze on the query. It ran in about 2 minutes. I attached the new query plan. I am not sure what did the trick, but 2 minutes is much better than 2 hours. But then again, I can't take long lunches anymore :) Is there any way to make this query run even faster without increasing the memory dedicated to postgres? Thanks. Oleg -----Original Message----- From: scott.marlowe [mailto:scott.marlowe@ihs.com]=20 Sent: Thursday, October 02, 2003 10:29 AM To: Oleg Lebedev Cc: Josh Berkus; pgsql-performance@postgresql.org Subject: RE: [PERFORM] TPC-R benchmarks Have you tried increasing the statistics target for those columns that are=20 getting bad estimates yet and then turning back on enable_nestloop and=20 rerunning analyze and seeing how the query does?=20=20 The idea being to try and get a good enough estimate of your statistics so=20 the planner stops using nestloops on its own rather than forcing it to=20 with enable_nestloop =3D false. On Thu, 2 Oct 2003, Oleg Lebedev wrote: > As Scott recommended, I did the following: > # set enable_nestloop =3D false; > # vacuum full analyze; >=20 > After this I re-ran the query and its execution time went down from 2=20 > hours to 2 minutes. I attached the new query plan to this posting. Is=20 > there any way to optimize it even further? What should I do to make=20 > this query run fast without hurting the performance of the other=20 > queries? Thanks. >=20 > Oleg >=20 > -----Original Message----- > From: scott.marlowe [mailto:scott.marlowe@ihs.com] > Sent: Wednesday, October 01, 2003 4:00 PM > To: Oleg Lebedev > Cc: Josh Berkus; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] TPC-R benchmarks >=20 >=20 > For troubleshooting, can you try it with "set enable_nestloop =3D false" > and rerun the query and see how long it takes? >=20 > It looks like the estimates of rows returned is WAY off (estimate is=20 > too >=20 > low compared to what really comes back.) >=20 > Also, you might try to alter the table.column to have a higher target=20 > on >=20 > the rows p_partkey and ps_partkey and any others where the estimate is > so far off of the reality. >=20 > On Wed, 1 Oct 2003, Oleg Lebedev wrote: >=20 > > All right, my query just finished running with EXPLAIN ANALYZE. I=20 > > show >=20 > > the plan below and also attached it as a file. Any ideas? > >=20 > > -> Sort (cost=3D54597.49..54597.50 rows=3D1 width=3D121) (actual > > time=3D6674562.03..6674562.15 rows=3D175 loops=3D1) > > Sort Key: nation.n_name, date_part('year'::text, > > orders.o_orderdate) > > -> Aggregate (cost=3D54597.45..54597.48 rows=3D1 width=3D121= )=20 > > (actual time=3D6668919.41..6674522.48 rows=3D175 loops=3D1) > > -> Group (cost=3D54597.45..54597.47 rows=3D3 width=3D1= 21) > > (actual time=3D6668872.68..6672136.96 rows=3D348760 loops=3D1) > > -> Sort (cost=3D54597.45..54597.46 rows=3D3 > > width=3D121) (actual time=3D6668872.65..6669499.95 rows=3D348760 loops= =3D1) > > Sort Key: nation.n_name,=20 > > date_part('year'::text, orders.o_orderdate) > > -> Hash Join (cost=3D54596.00..54597.42=20 > > rows=3D3 > > width=3D121) (actual time=3D6632768.89..6650192.67 rows=3D348760 loops= =3D1) > > Hash Cond: ("outer".n_nationkey =3D > > "inner".s_nationkey) > > -> Seq Scan on nation=20 > > (cost=3D0.00..1.25 rows=3D25 width=3D33) (actual time=3D6.75..7.13 rows= =3D25 > > loops=3D1) > > -> Hash (cost=3D54596.00..54596.00= =20 > > rows=3D3 > > width=3D88) (actual time=3D6632671.96..6632671.96 rows=3D0 loops=3D1) > > -> Nested Loop=20 > > (cost=3D0.00..54596.00 rows=3D3 width=3D88) (actual time=3D482.41..6630601.46=20 > > rows=3D348760 loops=3D1) > > Join Filter:=20 > > ("inner".s_suppkey =3D "outer".l_suppkey) > > -> Nested Loop=20 > > (cost=3D0.00..54586.18 rows=3D3 width=3D80) (actual time=3D383.87..6594984.40=20 > > rows=3D348760 loops=3D1) > > -> Nested Loop=20 > > (cost=3D0.00..54575.47 rows=3D4 width=3D68) (actual time=3D199.95..3580882.07=20 > > rows=3D348760 loops=3D1) > > Join Filter:=20 > > ("outer".p_partkey =3D "inner".ps_partkey) > > -> Nested=20 > > Loop (cost=3D0.00..22753.33 rows=3D9343 width=3D49) (actual=20 > > time=3D146.85..3541433.10 rows=3D348760 loops=3D1) > > -> Seq >=20 > > Scan on part (cost=3D0.00..7868.00 rows=3D320 width=3D4) (actual > > time=3D33.64..15651.90 rows=3D11637 loops=3D1) > >=20 > > Filter: (p_name ~~ '%green%'::text) > > -> > > Index Scan using i_l_partkey on lineitem (cost=3D0.00..46.15 rows=3D29= =20 > > width=3D45) (actual time=3D10.71..302.67 rows=3D30 loops=3D11637) > >=20=20 > > Index > > Cond: ("outer".p_partkey =3D lineitem.l_partkey) > > -> Index > > Scan using pk_partsupp on partsupp (cost=3D0.00..3.39 rows=3D1 width=3D19)=20 > > (actual time=3D0.09..0.09 rows=3D1 loops=3D348760) > > Index > > Cond: ((partsupp.ps_partkey =3D "outer".l_partkey) AND=20 > > (partsupp.ps_suppkey =3D > > "outer".l_suppkey)) > > -> Index Scan=20 > > using pk_orders on orders (cost=3D0.00..3.01 rows=3D1 width=3D12) (act= ual > > time=3D8.62..8.62 rows=3D1 loops=3D348760) > > Index Cond: > > (orders.o_orderkey =3D "outer".l_orderkey) > > -> Index Scan using=20 > > pk_supplier on supplier (cost=3D0.00..3.01 rows=3D1 width=3D8) (actual= =20 > > time=3D0.08..0.08 rows=3D1 loops=3D348760) > > Index Cond:=20 > > ("outer".ps_suppkey =3D supplier.s_suppkey) Total runtime: 6674724.23 > > msec (28 rows) > >=20 > >=20 > > -----Original Message----- > > From: Oleg Lebedev > > Sent: Wednesday, October 01, 2003 12:00 PM > > To: Josh Berkus; scott.marlowe > > Cc: pgsql-performance@postgresql.org > > Subject: Re: [PERFORM] TPC-R benchmarks > > Importance: Low > >=20 > >=20 > > Sure, below is the query. I attached the plan to this posting. > >=20 > > select > > nation, > > o_year, > > sum(amount) as sum_profit > > from > > ( > > select > > n_name as nation, > > extract(year from o_orderdate) as o_year, > > l_extendedprice * (1 - l_discount) - > > ps_supplycost * l_quantity as amount > > from > > part, > > supplier, > > lineitem, > > partsupp, > > orders, > > nation > > where > > s_suppkey =3D l_suppkey > > and ps_suppkey =3D l_suppkey > > and ps_partkey =3D l_partkey > > and p_partkey =3D l_partkey > > and o_orderkey =3D l_orderkey > > and s_nationkey =3D n_nationkey > > and p_name like '%green%' > > ) as profit > > group by > > nation, > > o_year > > order by > > nation, > > o_year desc; > >=20 > >=20 > > -----Original Message----- > > From: Josh Berkus [mailto:josh@agliodbs.com] > > Sent: Wednesday, October 01, 2003 11:42 AM > > To: Oleg Lebedev; scott.marlowe > > Cc: pgsql-performance@postgresql.org > > Subject: Re: [PERFORM] TPC-R benchmarks > >=20 > >=20 > > Oleg, > >=20 > > > The output of the query should contain about 200 rows. So, I guess > > > the > >=20 > > > planer is off assuming that the query should return 1 row. > >=20 > > Oh, also did you post the query before? Can you re-post it with the > > planner > > results? > >=20 > >=20 >=20 > ************************************* >=20 > This e-mail may contain privileged or confidential material intended=20 > for the named recipient only. If you are not the named recipient,=20 > delete this message and all attachments. Unauthorized reviewing,=20 > copying, printing, disclosing, or otherwise using information in this=20 > e-mail is prohibited. We reserve the right to monitor e-mail sent=20 > through our network. >=20 > ************************************* >=20 ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb Content-Type: text/text; name="new_plan_explained.txt" Content-Disposition: attachment; filename="new_plan_explained.txt" Content-Transfer-Encoding: base64 ICAgLT4gIFNvcnQgIChjb3N0PTI3NTUxNS44NC4uMjc1NTE1Ljg1IHJvd3M9 MSB3aWR0aD0xMjEpIChhY3R1YWwgdGltZT0xMTc3MTcuNzEuLjExNzcxNy44 NiByb3dzPTE3NSBsb29wcz0xKQ0KICAgICAgICAgU29ydCBLZXk6IG5hdGlv bi5uX25hbWUsIGRhdGVfcGFydCgneWVhcic6OnRleHQsDQpvcmRlcnMub19v cmRlcmRhdGUpDQogICAgICAgICAtPiAgQWdncmVnYXRlICAoY29zdD0yNzU1 MTUuNzkuLjI3NTUxNS44MyByb3dzPTEgd2lkdGg9MTIxKSAoYWN0dWFsIHRp bWU9MTEyMTQ4LjUwLi4xMTc2OTUuOTYgcm93cz0xNzUgbG9vcHM9MSkNCiAg ICAgICAgICAgICAgIC0+ICBHcm91cCAgKGNvc3Q9Mjc1NTE1Ljc5Li4yNzU1 MTUuODIgcm93cz00IHdpZHRoPTEyMSkgKGFjdHVhbCB0aW1lPTExMjExMi45 NC4uMTE1MzA0LjQ5IHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAtPiAgU29ydCAgKGNvc3Q9Mjc1NTE1Ljc5Li4yNzU1MTUu ODAgcm93cz00DQp3aWR0aD0xMjEpIChhY3R1YWwgdGltZT0xMTIxMTIuOTIu LjExMjY5Mi4yOCByb3dzPTM0ODc2MCBsb29wcz0xKQ0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgU29ydCBLZXk6IG5hdGlvbi5uX25hbWUsIGRhdGVf cGFydCgneWVhcic6OnRleHQsIG9yZGVycy5vX29yZGVyZGF0ZSkNCiAgICAg ICAgICAgICAgICAgICAgICAgICAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTI3 NTUxNC4zNC4uMjc1NTE1Ljc2IHJvd3M9NCB3aWR0aD0xMjEpIChhY3R1YWwg dGltZT05MDk1MS40NS4uOTM3ODkuODMgcm93cz0zNDg3NjAgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDog KCJvdXRlciIubl9uYXRpb25rZXkgPQ0KImlubmVyIi5zX25hdGlvbmtleSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2Nh biBvbiBuYXRpb24gIChjb3N0PTAuMDAuLjEuMjUgcm93cz0yNSB3aWR0aD0z MykgKGFjdHVhbCB0aW1lPTQuNjguLjUuMDYgcm93cz0yNSBsb29wcz0xKQ0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gIEhhc2ggIChj b3N0PTI3NTUxNC4zMy4uMjc1NTE0LjMzIHJvd3M9NCB3aWR0aD04OCkgKGFj dHVhbCB0aW1lPTkwOTQ2LjU2Li45MDk0Ni41NiByb3dzPTAgbG9vcHM9MSkN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBO ZXN0ZWQgTG9vcCAoY29zdD05MzE2LjU2Li4yNzU1MTQuMzMgcm93cz00IHdp ZHRoPTg4KSAoYWN0dWFsIHRpbWU9NjI5MS42MS4uODk0MjYuMzEgcm93cz0z NDg3NjAgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIC0+ICBIYXNoIEpvaW4gKGNvc3Q9OTMxNi41Ni4u Mjc1NTAzLjMzIHJvd3M9NCB3aWR0aD03NikgKGFjdHVhbCB0aW1lPTYyNTQu MzIuLjcwNjgxLjIwIHJvd3M9MzQ4NzYwIGxvb3BzPTEpDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBIYXNo IENvbmQ6ICgib3V0ZXIiLmxfcGFydGtleSA9DQoiaW5uZXIiLnBzX3BhcnRr ZXkpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICBKb2luIEZpbHRlcjogKCJpbm5lciIuc19zdXBwa2V5ID0g Im91dGVyIi5sX3N1cHBrZXkpDQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgU2VxIFNjYW4gb24gbGlu ZWl0ZW0gIChjb3N0PTAuMDAuLjIzNTYyMC4xNSByb3dzPTYwMDEyMTUgd2lk dGg9NDUpIChhY3R1YWwgdGltZT05LjgwLi40MzExMS4yOCByb3dzPTYwMDEy MTUgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIC0+ICBIYXNoIChjb3N0PTkzMTMuMzYuLjkz MTMuMzYgcm93cz0xMjgwIHdpZHRoPTMxKSAoYWN0dWFsIHRpbWU9NjI0NC4x Ni4uNjI0NC4xNiByb3dzPTAgbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0+ICBI YXNoIEpvaW4gKGNvc3Q9ODg3MS4zNi4uOTMxMy4zNiByb3dzPTEyODAgd2lk dGg9MzEpIChhY3R1YWwgdGltZT01OTY3LjgyLi42MTYzLjk4IHJvd3M9NDY1 NDggbG9vcHM9MSkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJv dXRlciIuc19zdXBwa2V5ID0gImlubmVyIi5wc19zdXBwa2V5KQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgLT4gIFNlcSBTY2FuIG9uIHN1cHBsaWVyICAoY29zdD0w LjAwLi4zNTEuMDAgcm93cz0xMDAwMCB3aWR0aD04KSAoYWN0dWFsIHRpbWU9 MC40NS4uNTUuNzggcm93cz0xMDAwMCBsb29wcz0xKQ0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgLT4gIEhhc2ggKGNvc3Q9ODg2OC4xNi4uODg2OC4xNiByb3dzPTEy ODAgd2lkdGg9MjMpIChhY3R1YWwgdGltZT01OTY3LjAyLi41OTY3LjAyIHJv d3M9MCBsb29wcz0xKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLT4gTmVz dGVkIExvb3AgIChjb3N0PTAuMDAuLjg4NjguMTYgcm93cz0xMjgwIHdpZHRo PTIzKSAoYWN0dWFsIHRpbWU9OC4xNC4uNTg1Ni4xNyByb3dzPTQ2NTQ4IGxv b3BzPTEpDQoNCi0+ICBTZXENClNjYW4gb24gcGFydCAgKGNvc3Q9MC4wMC4u Nzg2Ny4wMCByb3dzPTMyMCB3aWR0aD00KSAoYWN0dWFsIHRpbWU9OC4wNy4u MTU1NC40MSByb3dzPTExNjM3IGxvb3BzPTEpDQoNCkZpbHRlcjogKHBfbmFt ZSB+fiAnJWdyZWVuJSc6OnRleHQpDQoNCi0+ICBJbmRleCBTY2FuIHVzaW5n IGlfcHNfcGFydGtleSBvbiBwYXJ0c3VwcCAgKGNvc3Q9MC4wMC4uMy4wNyBy b3dzPTUNCndpZHRoPTE5KSAoYWN0dWFsIHRpbWU9MC4zMS4uMC4zNSByb3dz PTQgbG9vcHM9MTE2MzcpDQoNCkluZGV4IENvbmQ6ICgib3V0ZXIiLnBfcGFy dGtleSA9IHBhcnRzdXBwLnBzX3BhcnRrZXkpDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1 c2luZyBwa19vcmRlcnMgb24gb3JkZXJzICAoY29zdD0wLjAwLi4zLjAxIHJv d3M9MSB3aWR0aD0xMikgKGFjdHVhbCB0aW1lPTAuMDQuLjAuMDQgcm93cz0x IGxvb3BzPTM0ODc2MCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6IChvcmRlcnMub19v cmRlcmtleSA9ICJvdXRlciIubF9vcmRlcmtleSkgIFRvdGFsIHJ1bnRpbWU6 IDExNzc1OC45NiBtc2VjICgyOSByb3dzKQ0KDQo= --_NextPart_1_qmZrHLajoetbkwlTZTViemHPfyb-- From pgsql-performance-owner@postgresql.org Thu Oct 2 16:54:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 566A6D1B531 for ; Thu, 2 Oct 2003 19:54:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66857-02 for ; Thu, 2 Oct 2003 16:53:21 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 38C22D1B4F6 for ; Thu, 2 Oct 2003 16:53:19 -0300 (ADT) 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 h92JprGQ006419; Thu, 2 Oct 2003 13:51:53 -0600 (MDT) Date: Thu, 2 Oct 2003 13:44:12 -0600 (MDT) From: "scott.marlowe" To: Oleg Lebedev Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7627@postoffice.waterford.org> 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: 200310/64 X-Sequence-Number: 3812 On Thu, 2 Oct 2003, Oleg Lebedev wrote: > I was trying to get the pg_stats information to Josh and decided to > recreate the indexes on all my tables. After that I ran vacuum full > analyze, re-enabled nestloop and ran explain analyze on the query. It > ran in about 2 minutes. > I attached the new query plan. I am not sure what did the trick, but 2 > minutes is much better than 2 hours. But then again, I can't take long > lunches anymore :) > Is there any way to make this query run even faster without increasing > the memory dedicated to postgres? > Thanks. As long as the estimated row counts and real ones match up, and postgresql seems to be picking the right plan, there's probably not a lot to be done. You might want to look at increasing sort_mem a bit, but don't go crazy, as being too high can result in swap storms under load, which are a very bad thing. I'd check for index growth. You may have been reloading your data over and over and had an index growth problem. Next time instead of recreating the indexed completely, you might wanna try reindex indexname. Also, 7.4 mostly fixes the index growth issue, especially as it applies to truncating/reloading a table over and over, so moving to 7.4 beta3/4 and testing might be a good idea (if you aren't there already). What you want to avoid is having postgresql switch back to that nestloop join on you in the middle of the day, and to prevent that you might need to have higher statistics targets so the planner gets the right number all the time. From pgsql-performance-owner@postgresql.org Thu Oct 2 16:52:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4D036D1B4F6 for ; Thu, 2 Oct 2003 19:52:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67477-02 for ; Thu, 2 Oct 2003 16:51:28 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 1182CD1B4E1 for ; Thu, 2 Oct 2003 16:51:26 -0300 (ADT) Received: (qmail 19079 invoked by uid 500); 2 Oct 2003 19:58:43 -0000 Date: Thu, 2 Oct 2003 14:58:43 -0500 From: Bruno Wolff III To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables Message-ID: <20031002195843.GA19021@wolff.to> Mail-Followup-To: Dror Matalon , pgsql-performance@postgresql.org References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <20031002194645.GA87525@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031002194645.GA87525@rlx11.zapatec.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/63 X-Sequence-Number: 3811 On Thu, Oct 02, 2003 at 12:46:45 -0700, Dror Matalon wrote: Please keep replies copied to the list. > When would it happen that a tuple be invisible to the current > transaction? Are we talking about permissions? They could be tuples that were changed by a transaction that hasn't committed or in the case of serializable isolation, a transaction that committed after the current transaction started. > > On Thu, Oct 02, 2003 at 02:39:05PM -0500, Bruno Wolff III wrote: > > On Thu, Oct 02, 2003 at 12:15:47 -0700, > > Dror Matalon wrote: > > > Hi, > > > > > > I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a > > > count(*) takes around 40 seconds. > > > > > > Looks like the count(*) fetches the table from disk and goes through it. > > > Made me wonder, why the optimizer doesn't just choose the smallest index > > > which in my case is around 60 Megs and goes through it, which it could > > > do in a fraction of the time. > > > > Because it can't tell from the index if a tuple is visible to the current > > transaction and would still have to hit the table to check this. So that > > performance would be a lot worse instead of better. > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 5: Have you checked our extensive FAQ? > > > > http://www.postgresql.org/docs/faqs/FAQ.html > > -- > Dror Matalon, President > Zapatec Inc > 1700 MLK Way > Berkeley, CA 94709 > http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Oct 2 17:12:12 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 25421D1B4FE for ; Thu, 2 Oct 2003 20:12:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 75590-02 for ; Thu, 2 Oct 2003 17:11:26 -0300 (ADT) Received: from cbnsitar.cbnco.com (unknown [207.164.182.16]) by svr1.postgresql.org (Postfix) with ESMTP id C56E1D1B522 for ; Thu, 2 Oct 2003 17:11:20 -0300 (ADT) Received: (from root@localhost) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) id h92K9v018280 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 16:09:57 -0400 Received: from mail.cbnco.com (hermes.cbnco.com [207.164.182.47]) by cbnsitar.cbnco.com (8.11.6/8.11.3/SuSE Linux 8.11.1-0.5) with SMTP id h92K9ui18273 for ; Thu, 2 Oct 2003 16:09:56 -0400 Received: from 207.164.182.8 (SquirrelMail authenticated user rwu.cbnco.com) by mail.cbnco.com with HTTP; Thu, 2 Oct 2003 16:11:21 -0400 (EDT) Message-ID: <33506.207.164.182.8.1065125481.squirrel@mail.cbnco.com> In-Reply-To: <3F7C75C3.4060904@potentialtech.com> References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> <1065120643.89807.40.camel@jester> <3F7C75C3.4060904@potentialtech.com> Date: Thu, 2 Oct 2003 16:11:21 -0400 (EDT) Subject: Thanks - Re: low cardinality column From: "Rong Wu" To: "Postgresql Performance" Reply-To: rwu@cbnco.com 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-Scanned-By: MIMEDefang 2.24 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by AMaViS 0.3.12pre6 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=IN_REP_TO, PRIORITY_NO_NAME, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT X-Spam-Level: X-Archive-Number: 200310/65 X-Sequence-Number: 3813 Thanks, Rod, Josh and Bill, That' fantastic. have a nice day, rong :-) > Rod Taylor wrote: >> On Thu, 2003-10-02 at 14:30, Rong Wu wrote: >> >>>Hi, >>> >>>I have a select like this: >>> >>>SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0; >> >> >> For various reasons (primarily MVCC and the ability to make custom >> aggregates making it difficult) MAX() is not optimized in this fashion. >> >> Try: >> >> SELECT transactionid >> FROM ... >> WHERE ... >> ORDER BY transactionid DESC >> LIMIT 1; > > Despite this good suggestion, if you're using this technique to generate > the next transaction ID, you're going to have errors as concurrency rises. > > Use a SERIAL, which guarantees that you won't have two processes generate > the same number. > > -- > Bill Moran > Potential Technologies > http://www.potentialtech.com > > From pgsql-performance-owner@postgresql.org Fri Oct 3 11:56:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6D041D1B4F2 for ; Thu, 2 Oct 2003 20:17:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67630-08 for ; Thu, 2 Oct 2003 17:16:59 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id B4805D1B52A for ; Thu, 2 Oct 2003 17:16:57 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 3F5FA3E3E for ; Thu, 2 Oct 2003 16:16:59 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24112-03 for ; Thu, 2 Oct 2003 16:16:58 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 9BF383E34 for ; Thu, 2 Oct 2003 16:16:58 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h92KGwZd060442 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 16:16:58 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: inferior SCSI performance Date: Thu, 02 Oct 2003 16:16:58 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 18 Message-ID: References: <20031001103338.GA29293@libertyrms.info> <20031001132536.GA30269@libertyrms.info> <60brt1szby.fsf@dev6.int.libertyrms.info> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065125818 55478 216.194.193.105 (2 Oct 2003 20:16:58 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Thu, 2 Oct 2003 20:16:58 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:JiOJHoawfVXWAqkfk7T75sTxQBo= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/87 X-Sequence-Number: 3835 >>>>> "CB" == Christopher Browne writes: CB> Unfortunately, while there are companies hawking SSDs, they are in the CB> "you'll have to talk to our salescritter for pricing" category, which CB> means that they must be ferociously expensive. :-(. You ain't kidding. Unfortunately, one of the major vendors just went belly up (Imperial Technology) so pricing probably won't get any better anytime soon. Perhaps one of these days I'll try that experiment on my SSD... ;-) -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Thu Oct 2 18:21:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8037ED1B551 for ; Thu, 2 Oct 2003 21:21:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 79221-09 for ; Thu, 2 Oct 2003 18:20:38 -0300 (ADT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by svr1.postgresql.org (Postfix) with ESMTP id 489BAD1B542 for ; Thu, 2 Oct 2003 18:20:23 -0300 (ADT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id RAA09382; Thu, 2 Oct 2003 17:20:20 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma009378; Thu, 2 Oct 03 17:20:09 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id RAA17094; Thu, 2 Oct 2003 17:06:17 -0400 Message-ID: <3F7C98B8.C892D0E5@nsd.ca> Date: Thu, 02 Oct 2003 17:29:28 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.8 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Bruno Wolff III Cc: Dror Matalon , "pgsql-performance@postgresql.org" Subject: Re: count(*) slow on large tables References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/66 X-Sequence-Number: 3814 That's one of the draw back of MVCC. I once suggested that the transaction number and other house keeping info be included in the index, but was told to forget it... It would solve once and for all the issue of seq_scan vs index_scan. It would simplify the aggregate problem. Bruno Wolff III wrote: > > On Thu, Oct 02, 2003 at 12:15:47 -0700, > Dror Matalon wrote: > > Hi, > > > > I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a > > count(*) takes around 40 seconds. > > > > Looks like the count(*) fetches the table from disk and goes through it. > > Made me wonder, why the optimizer doesn't just choose the smallest index > > which in my case is around 60 Megs and goes through it, which it could > > do in a fraction of the time. > > Because it can't tell from the index if a tuple is visible to the current > transaction and would still have to hit the table to check this. So that > performance would be a lot worse instead of better. > > ---------------------------(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 Thu Oct 2 19:20:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8459ED1B52A for ; Thu, 2 Oct 2003 22:20:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 88576-09 for ; Thu, 2 Oct 2003 19:19:29 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id D1123D1B508 for ; Thu, 2 Oct 2003 19:19:26 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h92MJQQj024759 for ; Thu, 2 Oct 2003 22:19:26 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h92LvXBF020467 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 21:57:33 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: count(*) slow on large tables Date: Thu, 02 Oct 2003 17:57:30 -0400 Organization: Hub.Org Networking Services Lines: 30 Message-ID: <60brszcng5.fsf@dev6.int.libertyrms.info> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> 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:IMEM6aaxjpIbqYtfIS4GbclqBjI= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/67 X-Sequence-Number: 3815 jllachan@nsd.ca (Jean-Luc Lachance) writes: > That's one of the draw back of MVCC. > I once suggested that the transaction number and other house keeping > info be included in the index, but was told to forget it... > It would solve once and for all the issue of seq_scan vs index_scan. > It would simplify the aggregate problem. It would only simplify _one_ case, namely the case where someone cares about the cardinality of a relation, and it would do that at _considerable_ cost. A while back I outlined how this would have to be done, and for it to be done efficiently, it would be anything BUT simple. It would be very hairy to implement it correctly, and all this would cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" If you had a single WHERE clause attached, you would have to revert to walking through the tuples looking for the ones that are live and committed, which is true for any DBMS. And it still begs the same question, of why the result of this query would be particularly meaningful to anyone. I don't see the usefulness; I don't see the value of going to the considerable effort of "fixing" this purported problem. -- let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Thu Oct 2 19:29:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7D3D9D1B551 for ; Thu, 2 Oct 2003 22:29:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97077-04 for ; Thu, 2 Oct 2003 19:28:44 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id C50E8D1B533 for ; Thu, 2 Oct 2003 19:28:40 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Thu, 2 Oct 2003 16:27:30 -0600 From: Oleg Lebedev To: "scott.marlowe" Cc: Josh Berkus , "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 16:27:29 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731E783E@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/68 X-Sequence-Number: 3816 Thanks everyone for the help. I have another question. How do I optimize my indexes for the query that contains a lot of ORed blocks, each of which contains a bunch of ANDed expressions? The structure of each ORed block is the same except the right-hand-side values vary.=20 The first expression of each AND-block is a join condition. However, postgres tries to use a sequential scan on both of the tables applying the OR-ed blocks of ANDed expressions. So, the cost of the plan is around 700,000,000,000.=20 Here is an example: select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey =3D l_partkey and p_brand =3D 'Brand#24' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >=3D 4 and l_quantity <=3D 4 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ) or ( p_partkey =3D l_partkey and p_brand =3D 'Brand#22' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >=3D 18 and l_quantity <=3D 18 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ) or ( p_partkey =3D l_partkey and p_brand =3D 'Brand#33' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >=3D 24 and l_quantity <=3D 24 + 10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ); -----Original Message----- From: scott.marlowe [mailto:scott.marlowe@ihs.com]=20 Sent: Thursday, October 02, 2003 1:44 PM To: Oleg Lebedev Cc: Josh Berkus; pgsql-performance@postgresql.org Subject: RE: [PERFORM] TPC-R benchmarks On Thu, 2 Oct 2003, Oleg Lebedev wrote: > I was trying to get the pg_stats information to Josh and decided to=20 > recreate the indexes on all my tables. After that I ran vacuum full=20 > analyze, re-enabled nestloop and ran explain analyze on the query. It=20 > ran in about 2 minutes. I attached the new query plan. I am not sure=20 > what did the trick, but 2 minutes is much better than 2 hours. But=20 > then again, I can't take long lunches anymore :) > Is there any way to make this query run even faster without increasing > the memory dedicated to postgres? > Thanks. As long as the estimated row counts and real ones match up, and postgresql=20 seems to be picking the right plan, there's probably not a lot to be done.=20=20 You might want to look at increasing sort_mem a bit, but don't go crazy, as being too high can result in swap storms under load, which are a very bad thing. I'd check for index growth. You may have been reloading your data over=20 and over and had an index growth problem. Next time instead of recreating=20 the indexed completely, you might wanna try reindex indexname. Also, 7.4 mostly fixes the index growth issue, especially as it applies to=20 truncating/reloading a table over and over, so moving to 7.4 beta3/4 and testing might be a good idea (if you aren't there already). What you want to avoid is having postgresql switch back to that nestloop join on you in the middle of the day, and to prevent that you might need to have higher statistics targets so the planner gets the right number=20 all the time. ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Thu Oct 2 19:34:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 48ECDD1B552 for ; Thu, 2 Oct 2003 22:34:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97628-08 for ; Thu, 2 Oct 2003 19:33:24 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 6DF41D1B56F for ; Thu, 2 Oct 2003 19:33:11 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 3FF2DACAC for ; Thu, 2 Oct 2003 22:33:14 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h92MXD1Z094761 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 15:33:13 -0700 (PDT) (envelope-from dror) Date: Thu, 2 Oct 2003 15:33:13 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables Message-ID: <20031002223313.GE87525@rlx11.zapatec.com> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60brszcng5.fsf@dev6.int.libertyrms.info> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/69 X-Sequence-Number: 3817 I don't have an opinion on how hard it would be to implement the tracking in the indexes, but "select count(*) from some table" is, in my experience, a query that people tend to run quite often. One of the databases that I've used, I believe it was Informix, had that info cached so that it always new how many rows there were in any table. It was quite useful. On Thu, Oct 02, 2003 at 05:57:30PM -0400, Christopher Browne wrote: > jllachan@nsd.ca (Jean-Luc Lachance) writes: > > That's one of the draw back of MVCC. > > I once suggested that the transaction number and other house keeping > > info be included in the index, but was told to forget it... > > It would solve once and for all the issue of seq_scan vs index_scan. > > It would simplify the aggregate problem. > > It would only simplify _one_ case, namely the case where someone cares > about the cardinality of a relation, and it would do that at > _considerable_ cost. > > A while back I outlined how this would have to be done, and for it to > be done efficiently, it would be anything BUT simple. > > It would be very hairy to implement it correctly, and all this would > cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" > > If you had a single WHERE clause attached, you would have to revert to > walking through the tuples looking for the ones that are live and > committed, which is true for any DBMS. > > And it still begs the same question, of why the result of this query > would be particularly meaningful to anyone. I don't see the > usefulness; I don't see the value of going to the considerable effort > of "fixing" this purported problem. > -- > let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; > > Christopher Browne > (416) 646 3304 x124 (land) > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Dror Matalon, President Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Oct 2 20:44:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9318FD1B52A for ; Thu, 2 Oct 2003 23:44:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 10010-04 for ; Thu, 2 Oct 2003 20:43:58 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 62957D1B4F0 for ; Thu, 2 Oct 2003 20:43:55 -0300 (ADT) 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 h92NhLGQ022709 for ; Thu, 2 Oct 2003 17:43:21 -0600 (MDT) Date: Thu, 2 Oct 2003 17:35:39 -0600 (MDT) From: "scott.marlowe" To: Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: 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: 200310/70 X-Sequence-Number: 3818 On Thu, 2 Oct 2003, scott.marlowe wrote: > I was testing to get some idea of how to speed up the speed of pgbench > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > /dev/hdx). > > The only parameter that seems to make a noticeable difference was setting > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > it jumped to the range of 45 to 52 tps. with write cache on I was getting > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > about 5 times slower, much better. > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > and see if the data gets corrupted with write caching turned on, i.e. do > my hard drives have the ability to write at least some of their cache > during spin down. OK, back from testing. Information: Dual PIV system with a pair of 80 gig IDE drives, model number: ST380023A (seagate). File system is ext3 and is on a seperate drive from the OS. These drives DO NOT write cache when they lose power. Testing was done by issuing a 'hdparm -W0/1 /dev/hdx' command where x is the real drive letter, and 0 or 1 was chosen in place of 0/1. Then I'd issue a 'pgbench -c 50 -t 100000000' command, wait for a few minutes, then pull the power cord. I'm running RH linux 9.0 stock install, kernel: 2.4.20-8smp. Three times pulling the plug with 'hdparm -W0 /dev/hdx' resulted in a machine that would boot up, recover with journal, and a database that came up within about 30 seconds, with all the accounts still intact. Switching the caching back on with 'hdparm -W1 /dev/hdx' and doing the same 'pgbench -c 50 -t 100000000' resulted in a corrupted database each time. Also, I tried each of the following fsync methods: fsync, fdatasync, and open_sync with write caching turned off. Each survived a power off test with no corruption of the database. fsync and fdatasync result in 11 to 17 tps with 'pgbench -c 5 -t 500' while open_sync resulted in 45 to 55 tps, as mentioned in the previous post. I'd be interested in hearing from other folks which sync method works for them and whether or not there are any IDE drives out there that can write their cache to the platters on power off when caching is enabled. From pgsql-performance-owner@postgresql.org Thu Oct 2 20:53:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7B2BFD1B520 for ; Thu, 2 Oct 2003 23:53:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02465-07 for ; Thu, 2 Oct 2003 20:53:05 -0300 (ADT) Received: from smtp.noos.fr (nan-smtp-15.noos.net [212.198.2.123]) by svr1.postgresql.org (Postfix) with ESMTP id 30B62D1B50D for ; Thu, 2 Oct 2003 20:53:02 -0300 (ADT) Received: (qmail 24773 invoked by uid 0); 2 Oct 2003 23:53:05 -0000 Received: from unknown (HELO bigfoot.com) ([::ffff:212.198.37.110]) (envelope-sender ) by ::ffff:212.198.2.123 (qmail-ldap-1.03) with SMTP for ; 2 Oct 2003 23:53:05 -0000 Message-ID: <3F7CBA4E.6020302@bigfoot.com> Date: Fri, 03 Oct 2003 01:52:46 +0200 From: Gaetano Mendola 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@postgresql.org" Cc: Andriy Tkachuk Subject: Re: runtime of the same query in function differs on 2 degree! References: <20031002163005.N53420-100000@pool.imt.com.ua> In-Reply-To: <20031002163005.N53420-100000@pool.imt.com.ua> 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: 200310/71 X-Sequence-Number: 3819 Andriy Tkachuk wrote: > Hi folks. > > What's wrong with planner that executes my query in function?: > (i mean no explanation but runtime) > > > tele=# EXPLAIN analyze select calc_total(6916799, 1062363600, 1064955599); > QUERY PLAN > ------------------------------------------------------------------------------------------ > Result (cost=0.00..0.01 rows=1 width=0) (actual time=36919.37..36919.37 rows=1 loops=1) > Total runtime: 36919.40 msec > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > tele=# \df+ calc_total > ... > declare > usr alias for $1; > d1 alias for $2; > d2 alias for $3; > res integer; > begin > select sum(cost) into res > from bills where > (parent(user_id) = usr or user_id = usr) > and dat >= d1 and dat < d2; > if res is not null then > return res; > else > return 0; > end if; > end; You didn't wrote the type of d1 and d2, I had your same problem: declare a_user alias for $1; res INTEGER; begin select cost into res from my_table where login = a_user; ...... end; the problem was that login was a VARCHAR and a_user was a TEXT so the index was not used, was enough cast a_user::varchar; I believe that your dat, d1, d2 are not "index" comparable. Gaetano From pgsql-performance-owner@postgresql.org Thu Oct 2 23:20:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4AEDAD1B4EF for ; Fri, 3 Oct 2003 02:20:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29474-08 for ; Thu, 2 Oct 2003 23:19:31 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 54ED6D1B508 for ; Thu, 2 Oct 2003 23:19:27 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h932JQQj061698 for ; Fri, 3 Oct 2003 02:19:27 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h932CGcj060938 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 02:12:16 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: count(*) slow on large tables Date: Thu, 02 Oct 2003 22:08:18 -0400 Organization: cbbrowne Computing Inc Lines: 43 Message-ID: References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <20031002223313.GE87525@rlx11.zapatec.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:nqN2S1g4IaIUHFMhdc9gGlxONnA= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/73 X-Sequence-Number: 3821 The world rejoiced as dror@zapatec.com (Dror Matalon) wrote: > I don't have an opinion on how hard it would be to implement the > tracking in the indexes, but "select count(*) from some table" is, in my > experience, a query that people tend to run quite often. > One of the databases that I've used, I believe it was Informix, had that > info cached so that it always new how many rows there were in any > table. It was quite useful. I can't imagine why the raw number of tuples in a relation would be expected to necessarily be terribly useful. I'm involved with managing Internet domains, and it's only when people are being pretty clueless that anyone imagines that "select count(*) from domains;" would be of any use to anyone. There are enough "test domains" and "inactive domains" and other such things that the raw number of "things in the table" aren't really of much use. - I _do_ care how many pages a table occupies, to some extent, as that determines whether it will fit in my disk space or not, but that's not COUNT(*). - I might care about auditing the exact numbers of records in order to be assured that a data conversion process was done correctly. But in that case, I want to do something a whole *lot* more detailed than mere COUNT(*). I'm playing "devil's advocate" here, to some extent. But realistically, there is good reason to be skeptical of the merits of using SELECT COUNT(*) FROM TABLE for much of anything. Furthermore, the relation that you query mightn't be a physical "table." It might be a more virtual VIEW, and if that's the case, bets are even MORE off. If you go with the common dictum of "good design" that users don't directly access tables, but go through VIEWs, users may have no way to get at SELECT COUNT(*) FROM TABLE. -- output = reverse("ac.notelrac.teneerf" "@" "454aa") http://www.ntlug.org/~cbbrowne/finances.html Rules of the Evil Overlord #74. "When I create a multimedia presentation of my plan designed so that my five-year-old advisor can easily understand the details, I will not label the disk "Project Overlord" and leave it lying on top of my desk." From pgsql-performance-owner@postgresql.org Thu Oct 2 23:14:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 18B13D1B54C for ; Fri, 3 Oct 2003 02:14:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37771-02 for ; Thu, 2 Oct 2003 23:14:10 -0300 (ADT) Received: from mail.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by svr1.postgresql.org (Postfix) with ESMTP id 14869D1B51C for ; Thu, 2 Oct 2003 23:14:06 -0300 (ADT) Received: from smtp.us2.messagingengine.com (localhost [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id 457F425D256 for ; Thu, 2 Oct 2003 22:14:08 -0400 (EDT) Received: from 10.202.2.133 ([10.202.2.133] helo=smtp.us2.messagingengine.com) by messagingengine.com with SMTP; Thu, 02 Oct 2003 22:14:08 -0400 Received: by smtp.us2.messagingengine.com (Postfix, from userid 99) id 6DC2F63D07; Thu, 2 Oct 2003 22:14:07 -0400 (EDT) Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="Big5" MIME-Version: 1.0 X-Mailer: MIME::Lite 1.2 (F2.71; T1.001; A1.51; B2.12; Q2.03) From: "CN" To: pgsql-performance@postgresql.org Date: Thu, 02 Oct 2003 18:14:07 -0800 X-Epoch: 1065147248 X-Sasl-enc: mUsvIBepnS422qFaX5purw Subject: Is This My Speed Limit? Message-Id: <20031003021407.6DC2F63D07@smtp.us2.messagingengine.com> 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: 200310/72 X-Sequence-Number: 3820 Hi! It's just my curiosity. I wonder if there is any way to break my speed limit on AMD 450Mhz: Best Regards, CN ------------------- --This table contains 1036 rows. CREATE TABLE table1 ( c1 VARCHAR(20) PRIMARY KEY, c2 "char" )WITHOUT OIDS; --------------------- --This table contains 9429 rows. CREATE TABLE table2 ( c1 VARCHAR(20) PRIMARY KEY, c2 DATE, c3 INTEGER, c4 INTEGER )WITHOUT OIDS; CREATE INDEX i2c3c4 ON table2 (c3,c4); --------------------- --This table contains 28482 rows. CREATE TABLE table3 ( CONSTRAINT fk3c1 FOREIGN KEY (c1) REFERENCES table2 (c1) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT fk3c3 FOREIGN KEY (c3) REFERENCES table1 (c1), PRIMARY KEY (c1,c2), c1 VARCHAR(20), c2 INTEGER, c3 VARCHAR(20), c4 "char", c5 INTEGER )WITHOUT OIDS; --------------------- EXPLAIN ANALYZE SELECT table2.c3 AS year ,table2.c4 AS month ,(SELECT CASE WHEN (table1.c2 = 'A' OR table1.c2 = 'E') AND table3.c4 = 'D' OR table1.c2 IN ('L','O','I') AND table3.c4 = 'C' THEN table3.c5 ELSE 0-table3.c5 END FROM table1 WHERE table1.c1=table3.c3 ) AS amount FROM table2,table3 WHERE table3.c1=table2.c1 AND table2.c3 > 2001; Hash Join (cost=189.79..1508.67 rows=11203 width=48) (actual time=129.20..1780.53 rows=9912 loops=1) Hash Cond: ("outer".c1 = "inner".c1) -> Seq Scan on table3 (cost=0.00..822.82 rows=28482 width=27) (actual time=14.01..403.78 rows=28482 loops=1) -> Hash (cost=180.69..180.69 rows=3640 width=21) (actual time=85.61..85.61 rows=0 loops=1) -> Seq Scan on table2 (cost=0.00..180.69 rows=3640 width=21) (actual time=0.28..64.62 rows=3599 loops=1) Filter: (c3 > 2001) SubPlan -> Index Scan using table1_pkey on table1 (cost=0.00..3.01 rows=1 width=1) (actual time=0.06..0.06 rows=1 loops=9912) Index Cond: (c1 = $2) Total runtime: 1802.71 msec ------------------- EXPLAIN ANALYZE SELECT table2.c3 AS year ,table2.c4 AS month ,CASE WHEN (table1.c2 = 'A' OR table1.c2 = 'E') AND table3.c4 = 'D' OR table1.c2 IN ('L','O','I') AND table3.c4 = 'C' THEN table3.c5 ELSE 0-table3.c5 END AS amount FROM table2,table3,table1 WHERE table3.c1=table2.c1 AND table1.c1=table3.c3 AND table2.c3 > 2001; Hash Join (cost=208.74..1751.68 rows=11203 width=58) (actual time=135.87..1113.69 rows=9912 loops=1) Hash Cond: ("outer".c3 = "inner".c1) -> Hash Join (cost=189.79..1508.67 rows=11203 width=48) (actual time=123.81..899.29 rows=9912 loops=1) Hash Cond: ("outer".c1 = "inner".c1) -> Seq Scan on table3 (cost=0.00..822.82 rows=28482 width=27) (actual time=9.30..371.10 rows=28482 loops=1) -> Hash (cost=180.69..180.69 rows=3640 width=21) (actual time=85.62..85.62 rows=0 loops=1) -> Seq Scan on table2 (cost=0.00..180.69 rows=3640 width=21) (actual time=0.31..64.33 rows=3599 loops=1) Filter: (c3 > 2001) -> Hash (cost=16.36..16.36 rows=1036 width=10) (actual time=11.91..11.91 rows=0 loops=1) -> Seq Scan on table1 (cost=0.00..16.36 rows=1036 width=10) (actual time=0.05..7.16 rows=1036 loops=1) Total runtime: 1133.95 msec -- http://www.fastmail.fm - Does exactly what it says on the tin From pgsql-performance-owner@postgresql.org Fri Oct 3 01:28:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 236B0D1B53F for ; Fri, 3 Oct 2003 04:28:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52869-04 for ; Fri, 3 Oct 2003 01:27:56 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id C3E67D1B550 for ; Fri, 3 Oct 2003 01:27:55 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 676F7ACAC for ; Fri, 3 Oct 2003 04:27:55 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h934RsDC095314 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 21:27:54 -0700 (PDT) (envelope-from dror) Date: Thu, 2 Oct 2003 21:27:54 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables Message-ID: <20031003042754.GH87525@rlx11.zapatec.com> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <20031002223313.GE87525@rlx11.zapatec.com> 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: 200310/74 X-Sequence-Number: 3822 I smell a religious war in the aii:-). Can you go several days in a row without doing select count(*) on any of your tables? I suspect that this is somewhat a domain specific issue. In some areas you don't need to know the total number of rows in your tables, in others you do. I also suspect that you're right, that end user applications don't use this information as often as DBAs would. On the other hand, it seems whenever you want to optimize your app (something relevant to this list), one of the things you do need to know is the number of rows in your table. Dror On Thu, Oct 02, 2003 at 10:08:18PM -0400, Christopher Browne wrote: > The world rejoiced as dror@zapatec.com (Dror Matalon) wrote: > > I don't have an opinion on how hard it would be to implement the > > tracking in the indexes, but "select count(*) from some table" is, in my > > experience, a query that people tend to run quite often. > > One of the databases that I've used, I believe it was Informix, had that > > info cached so that it always new how many rows there were in any > > table. It was quite useful. > > I can't imagine why the raw number of tuples in a relation would be > expected to necessarily be terribly useful. > > I'm involved with managing Internet domains, and it's only when people > are being pretty clueless that anyone imagines that "select count(*) > from domains;" would be of any use to anyone. There are enough "test > domains" and "inactive domains" and other such things that the raw > number of "things in the table" aren't really of much use. > > - I _do_ care how many pages a table occupies, to some extent, as that > determines whether it will fit in my disk space or not, but that's not > COUNT(*). > > - I might care about auditing the exact numbers of records in order to > be assured that a data conversion process was done correctly. But in > that case, I want to do something a whole *lot* more detailed than > mere COUNT(*). > > I'm playing "devil's advocate" here, to some extent. But > realistically, there is good reason to be skeptical of the merits of > using SELECT COUNT(*) FROM TABLE for much of anything. > > Furthermore, the relation that you query mightn't be a physical > "table." It might be a more virtual VIEW, and if that's the case, > bets are even MORE off. If you go with the common dictum of "good > design" that users don't directly access tables, but go through VIEWs, > users may have no way to get at SELECT COUNT(*) FROM TABLE. > -- > output = reverse("ac.notelrac.teneerf" "@" "454aa") > http://www.ntlug.org/~cbbrowne/finances.html > Rules of the Evil Overlord #74. "When I create a multimedia > presentation of my plan designed so that my five-year-old advisor can > easily understand the details, I will not label the disk "Project > Overlord" and leave it lying on top of my desk." > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Dror Matalon, President Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 02:13:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 02F0CD1B503 for ; Fri, 3 Oct 2003 05:13:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 61176-03 for ; Fri, 3 Oct 2003 02:13:10 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 6CCD8D1B550 for ; Fri, 3 Oct 2003 02:13:08 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 60CD436B2D; Fri, 3 Oct 2003 01:13:08 -0400 (EDT) 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 1A5IFY-0000Ys-00; Fri, 03 Oct 2003 01:13:08 -0400 To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> In-Reply-To: <60brszcng5.fsf@dev6.int.libertyrms.info> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 03 Oct 2003 01:13:08 -0400 Message-ID: <87brsyrjiz.fsf@stark.dyndns.tv> Lines: 43 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: 200310/75 X-Sequence-Number: 3823 Christopher Browne writes: > It would be very hairy to implement it correctly, and all this would > cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" > > If you had a single WHERE clause attached, you would have to revert to > walking through the tuples looking for the ones that are live and > committed, which is true for any DBMS. Well it would be handy for a few other cases as well. 1 It would be useful for the case where you have a partial index with a matching where clause. The optimizer already considers using such indexes but it has to pay the cost of the tuple lookup, which is substantial. 2 It would be useful for the very common queries of the form WHERE x IN (select id from foo where some_indexed_expression) (Or the various equivalent forms including outer joins that test to see if the matching record was found and don't retrieve any other columns in the select list.) 3 It would be useful for many-many relationships where the intermediate table has only the two primary key columns being joined. If you create a multi-column index on the two columns it shouldn't need to look up the tuple. This would be effectively be nearly equivalent to an "index organized table". 4 It would be useful for just about all the referential integrity queries... I don't mean to say this is definitely a good thing. The tradeoff in complexity and time to maintain the index pages would be large. But don't dismiss it as purely a count(*) optimization hack. I know Oracle is capable of it and it can speed up your query a lot when you remove that last unnecessary column from a join table allowing oracle to skip the step of reading the table. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 3 02:29:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CBBA4D1B550 for ; Fri, 3 Oct 2003 05:29:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51766-10 for ; Fri, 3 Oct 2003 02:28:26 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 5DFB9D1B503 for ; Fri, 3 Oct 2003 02:28:25 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3715721; Thu, 02 Oct 2003 22:28:52 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "scott.marlowe" Subject: Re: TPC-R benchmarks Date: Thu, 2 Oct 2003 22:27:08 -0700 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" References: <993DBE5B4D02194382EC8DF8554A52731E783E@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731E783E@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310022227.08554.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/76 X-Sequence-Number: 3824 Oleg, > I have another question. How do I optimize my indexes for the query that > contains a lot of ORed blocks, each of which contains a bunch of ANDed > expressions? The structure of each ORed block is the same except the > right-hand-side values vary. Given the example, I'd do a multicolumn index on p_brand, p_container, p_size and a second multicolumn index on l_partkey, l_quantity, l_shipmode. Hmmm ... or maybe seperate indexes, one on l_partkey and one on l_quantity, l_shipmode & l_instruct. Test both configurations. Mind you, if this is also an OLTP table, then you'd want to test those multi-column indexes to determine the least columns you need for the indexes still to be used, since more columns = more index maintainence. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 03:01:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 56801D1B4E3 for ; Fri, 3 Oct 2003 06:01:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 63077-09 for ; Fri, 3 Oct 2003 03:01:11 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id 1ED00D1B51A for ; Fri, 3 Oct 2003 03:01:10 -0300 (ADT) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 21C922B3CC; Fri, 3 Oct 2003 08:00:32 +0200 (CEST) Message-ID: <3F7D103D.3070801@klaster.net> Date: Fri, 03 Oct 2003 07:59:25 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5) Gecko/20030916 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: CN Cc: pgsql-performance@postgresql.org Subject: Re: Is This My Speed Limit? References: <20031003021407.6DC2F63D07@smtp.us2.messagingengine.com> In-Reply-To: <20031003021407.6DC2F63D07@smtp.us2.messagingengine.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT_MOZILLA_UA X-Spam-Level: X-Archive-Number: 200310/77 X-Sequence-Number: 3825 > Hi! > > It's just my curiosity. I wonder if there is any way to break my speed > limit on AMD 450Mhz: > Hash Join (cost=189.79..1508.67 rows=11203 width=48) (actual > time=129.20..1780.53 rows=9912 loops=1) > Hash Join (cost=208.74..1751.68 rows=11203 width=58) (actual > time=135.87..1113.69 rows=9912 loops=1) Well, it looks like a speed limit. I wouldn't expect better speed for queries returning 10000 rows. Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Fri Oct 3 03:23:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 60508D1B51A for ; Fri, 3 Oct 2003 06:23:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72086-06 for ; Fri, 3 Oct 2003 03:22:49 -0300 (ADT) Received: from loki.globexplorer.com (unknown [208.35.14.10]) by svr1.postgresql.org (Postfix) with ESMTP id 6EC24D1B53C for ; Fri, 3 Oct 2003 03:22:44 -0300 (ADT) Subject: Re: count(*) slow on large tables Date: Thu, 2 Oct 2003 23:22:46 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Message-ID: <71E37EF6B7DCC1499CEA0316A256832801057269@loki.wc.globexplorer.net> X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 X-MS-TNEF-Correlator: content-class: urn:content-classes:message Thread-Topic: [PERFORM] count(*) slow on large tables Thread-Index: AcOJaD0UHMAeGAptSiOaFPTu15lKIwADRudK From: "Gregory S. Williamson" To: "Dror Matalon" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/78 X-Sequence-Number: 3826 I can tell you that this is one of the first thing applications' programmer= s and IT managers notice. It can slightly tarnish postgres' image when it t= akes it many long seconds to do what other databases can do in a snap. The = "whys and wherefores" can be hard to get across once they see the comparati= ve numbers. When I use Informix "dbaccess" it has a "status" which will tell me the row= count of a table virtually instantly -- it can be locked out by a user wit= h an exclusive lock so its not entirely independant of the table (like a st= ored value in one of the system catalog tables). This is not to say Informix is "right" and Postgres is "wrong" ... but it = is something that virtually any newcomer will run into head long, with resu= lting bruises and contusions, not to mention confusion. At the very least this needs to be VERY clearly explained right up front, a= long with some of the possible work-arounds, depending on what one is reall= y after with this info. Greg Williamson DBA GlobeXplorer LLC -----Original Message----- From: Dror Matalon [mailto:dror@zapatec.com] Sent: Thu 10/2/2003 9:27 PM To: pgsql-performance@postgresql.org Cc:=09 Subject: Re: [PERFORM] count(*) slow on large tables I smell a religious war in the aii:-).=20 Can you go several days in a row without doing select count(*) on any of your tables?=20 I suspect that this is somewhat a domain specific issue. In some areas you don't need to know the total number of rows in your tables, in others you do.=20 I also suspect that you're right, that end user applications don't use this information as often as DBAs would. On the other hand, it seems whenever you want to optimize your app (something relevant to this list), one of the things you do need to know is the number of rows in your table. Dror On Thu, Oct 02, 2003 at 10:08:18PM -0400, Christopher Browne wrote: > The world rejoiced as dror@zapatec.com (Dror Matalon) wrote: > > I don't have an opinion on how hard it would be to implement the > > tracking in the indexes, but "select count(*) from some table" is, in my > > experience, a query that people tend to run quite often.=20 > > One of the databases that I've used, I believe it was Informix, had that > > info cached so that it always new how many rows there were in any > > table. It was quite useful. >=20 > I can't imagine why the raw number of tuples in a relation would be > expected to necessarily be terribly useful. >=20 > I'm involved with managing Internet domains, and it's only when people > are being pretty clueless that anyone imagines that "select count(*) > from domains;" would be of any use to anyone. There are enough "test > domains" and "inactive domains" and other such things that the raw > number of "things in the table" aren't really of much use. >=20 > - I _do_ care how many pages a table occupies, to some extent, as that > determines whether it will fit in my disk space or not, but that's not > COUNT(*). >=20 > - I might care about auditing the exact numbers of records in order to > be assured that a data conversion process was done correctly. But in > that case, I want to do something a whole *lot* more detailed than > mere COUNT(*). >=20 > I'm playing "devil's advocate" here, to some extent. But > realistically, there is good reason to be skeptical of the merits of > using SELECT COUNT(*) FROM TABLE for much of anything. >=20 > Furthermore, the relation that you query mightn't be a physical > "table." It might be a more virtual VIEW, and if that's the case, > bets are even MORE off. If you go with the common dictum of "good > design" that users don't directly access tables, but go through VIEWs, > users may have no way to get at SELECT COUNT(*) FROM TABLE. > --=20 > output =3D reverse("ac.notelrac.teneerf" "@" "454aa") > http://www.ntlug.org/~cbbrowne/finances.html > Rules of the Evil Overlord #74. "When I create a multimedia > presentation of my plan designed so that my five-year-old advisor can > easily understand the details, I will not label the disk "Project > Overlord" and leave it lying on top of my desk." > >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster --=20 Dror Matalon, President Zapatec Inc=20 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Fri Oct 3 03:27:49 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2DEA3D1B4E3 for ; Fri, 3 Oct 2003 06:27:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 79990-04 for ; Fri, 3 Oct 2003 03:27:03 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 30503D1B53C for ; Fri, 3 Oct 2003 03:27:01 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h936UJrB011062 for ; Fri, 3 Oct 2003 12:00:19 +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 h936UIYM011036; Fri, 3 Oct 2003 12:00:18 +0530 Message-ID: <3F7D172E.3060107@persistent.co.in> Date: Fri, 03 Oct 2003 11:59:02 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <20031002223313.GE87525@rlx11.zapatec.com> <20031003042754.GH87525@rlx11.zapatec.com> In-Reply-To: <20031003042754.GH87525@rlx11.zapatec.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: 200310/79 X-Sequence-Number: 3827 Dror Matalon wrote: > I smell a religious war in the aii:-). > Can you go several days in a row without doing select count(*) on any > of your tables? > > I suspect that this is somewhat a domain specific issue. In some areas > you don't need to know the total number of rows in your tables, in > others you do. If I were you, I would have an autovacuum daemon running and rather than doing select count(*), I would look at stats generated by vacuums. They give approximate number of tuples and it should be good enough it is accurate within a percent. Just another approach of achieving same thing.. Don't be religious about running a qeury from SQL prompt. That's it.. Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 3 04:04:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EB311D1B54A for ; Fri, 3 Oct 2003 07:03:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82304-01 for ; Fri, 3 Oct 2003 04:03:13 -0300 (ADT) Received: from davlin.co.in (ns.vasnet.net.in [202.4.160.11]) by svr1.postgresql.org (Postfix) with ESMTP id 95A7FD1B4F0 for ; Fri, 3 Oct 2003 04:02:55 -0300 (ADT) Received: from staging (unknown [202.4.160.15]) by davlin.co.in (Postfix) with ESMTP id 24B2C14B70 for ; Fri, 3 Oct 2003 12:04:38 +0530 (IST) Message-ID: <6681508.1065164977817.JavaMail.tomcat@mail.davlin.co.in> From: shyamperi@davlin.co.in To: pgsql-performance@postgresql.org Subject: A Basic Question Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_77_5164729.1065164977622" Date: Fri, 3 Oct 2003 12:04:38 +0530 (IST) X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=2.0 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: ** X-Archive-Number: 200310/81 X-Sequence-Number: 3829 ------=_Part_77_5164729.1065164977622 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 12:28p Dear All, This question is regarding the performance of queries in general. The performance of the queries wud varying depending on the no. Of tuples i= t is returning, and the sort of alogorithm that will be implemented or the = retrieval.=20 Now if the relation returns zero tuples.. (the seq, and the index scan is t= he best option) and if there are 1 or more then rest PG-supported scans wil= l be the best.=20 Now here is where I am having a bit of considerations. My relation works fa= st, when it returns more than on tuple. But get's slow when it returns zero= tuple. Now how shud I got abt it. ----- Warm Regards Sh=FFam Peri II Floor, Punja Building, M.G.Road, Ballalbagh, Mangalore-575003=20 Ph : 91-824-2451001/5 Fax : 91-824-2451050=20 DISCLAIMER: This message contains privileged and confidential information a= nd is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. ------=_Part_77_5164729.1065164977622 Content-type: text/html Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=Untitled1

12:28p
Dear All,

This question is regarding the performance of queries in general.

The performance of the queries wud varying depending on the no. Of tuple= s it is returning, and the sort of alogorithm that will be implemented or t= he retrieval.
Now if the relation returns zero tuples.. (the seq, and t= he index scan is the best option) and if there are 1 or more then rest PG-s= upported scans will be the best.

Now here is where I am having a bit of considerations. My relation works= fast, when it returns more than on tuple. But get's slow when it returns z= ero tuple.

Now how shud I got abt it.

-----
Warm Regards
Sh=FFam Peri

II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003=20
Ph : 91-824-2451001/5
Fax : 91-824-2451050=20




DISCLAIMER: This message contains privileged and confidential information a= nd is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. ------=_Part_77_5164729.1065164977622-- From pgsql-performance-owner@postgresql.org Fri Oct 3 04:03:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 27076D1B54A for ; Fri, 3 Oct 2003 07:03:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 80710-04 for ; Fri, 3 Oct 2003 04:02:28 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id 328DAD1B4EE for ; Fri, 3 Oct 2003 04:02:22 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h93728lB064022 for ; Fri, 3 Oct 2003 10:02:09 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h93723J4064019 for ; Fri, 3 Oct 2003 10:02:08 +0300 (EEST) (envelope-from ant@imt.com.ua) X-Authentication-Warning: pool.imt.com.ua: ant owned process doing -bs Date: Fri, 3 Oct 2003 10:02:03 +0300 (EEST) From: Andriy Tkachuk To: pgsql-performance@postgresql.org Subject: Re: runtime of the same query in function differs on 2 In-Reply-To: <3F7CBA4E.6020302@bigfoot.com> Message-ID: <20031003092552.B62657-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/80 X-Sequence-Number: 3828 No: the function is calc_total(int,int,int) and the table have the same types. As Tom said that my problem is because of planning in pl/pgsql. As is written in http://www.postgresql.org/docs/7.3/static/plpgsql.html#PLPGSQL-OVERVIEW plans for queries in pl/pgsql are made just once - when they are first used in function by backend. So AFAICS this planning do not take into consideration table statistics because it don't see values of variables in queries (or if see than it must not take them into account, because they may be changed in future function callings). I rollback to my previous realization of calc_total() on pl/tcl. I use there spi_exec - so the query always regards as dynamic - it always parsed, rewritten, planned but executes fastest much more :) On Fri, 3 Oct 2003, Gaetano Mendola wrote: > Andriy Tkachuk wrote: > > > Hi folks. > > > > What's wrong with planner that executes my query in function?: > > (i mean no explanation but runtime) > > > > > > tele=# EXPLAIN analyze select calc_total(6916799, 1062363600, 1064955599); > > QUERY PLAN > > ------------------------------------------------------------------------------------------ > > Result (cost=0.00..0.01 rows=1 width=0) (actual time=36919.37..36919.37 rows=1 loops=1) > > Total runtime: 36919.40 msec > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > tele=# \df+ calc_total > > ... > > declare > > usr alias for $1; > > d1 alias for $2; > > d2 alias for $3; > > res integer; > > begin > > select sum(cost) into res > > from bills where > > (parent(user_id) = usr or user_id = usr) > > and dat >= d1 and dat < d2; > > if res is not null then > > return res; > > else > > return 0; > > end if; > > end; > > You didn't wrote the type of d1 and d2, I had your same problem: > > declare > a_user alias for $1; > res INTEGER; > begin > select cost into res > from my_table > where login = a_user; > > ...... > end; > > the problem was that login was a VARCHAR and a_user was a TEXT so > the index was not used, was enough cast a_user::varchar; > > > I believe that your dat, d1, d2 are not "index" comparable. > > > Gaetano > > > > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Fri Oct 3 07:11:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BBD1CD1B54C for ; Fri, 3 Oct 2003 10:11:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08824-10 for ; Fri, 3 Oct 2003 07:10:28 -0300 (ADT) Received: from anchor-post-37.mail.demon.net (anchor-post-37.mail.demon.net [194.217.242.87]) by svr1.postgresql.org (Postfix) with ESMTP id 7B79ED1B51A for ; Fri, 3 Oct 2003 07:10:25 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1A5MtH-0004w2-0b; Fri, 03 Oct 2003 11:10:27 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 4A31C17183; Fri, 3 Oct 2003 11:10:26 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 9F1FE1717B; Fri, 3 Oct 2003 11:10:25 +0100 (BST) From: Richard Huxton To: shyamperi@davlin.co.in, pgsql-performance@postgresql.org Subject: Re: A Basic Question Date: Fri, 3 Oct 2003 11:10:25 +0100 User-Agent: KMail/1.5 References: <6681508.1065164977817.JavaMail.tomcat@mail.davlin.co.in> In-Reply-To: <6681508.1065164977817.JavaMail.tomcat@mail.davlin.co.in> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310031110.25776.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/82 X-Sequence-Number: 3830 On Friday 03 October 2003 07:34, shyamperi@davlin.co.in wrote: > 12:28p > Dear All, > This question is regarding the performance of queries in general. > The performance of the queries wud varying depending on the no. Of tuples > it is returning, and the sort of alogorithm that will be implemented or the > retrieval. Now if the relation returns zero tuples.. (the seq, and the > index scan is the best option) and if there are 1 or more then rest > PG-supported scans will be the best. Now here is where I am having a bit of > considerations. My relation works fast, when it returns more than on tuple. > But get's slow when it returns zero tuple. Now how shud I got abt it. If PG has to examine a lot of tuples to rule them out, then returning no rows can take longer. If you post EXPLAIN ANALYSE output for both queries, someone will be able to explain why in your case. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Oct 3 08:50:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 117B0D1B51A for ; Fri, 3 Oct 2003 11:50:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22031-07 for ; Fri, 3 Oct 2003 08:49:36 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 442D7D1B50D for ; Fri, 3 Oct 2003 08:49:33 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h93BnXQj083484 for ; Fri, 3 Oct 2003 11:49:33 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h93BiYkl082815 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 11:44:34 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: count(*) slow on large tables Date: Fri, 03 Oct 2003 07:37:07 -0400 Organization: cbbrowne Computing Inc Lines: 38 Message-ID: References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <20031002223313.GE87525@rlx11.zapatec.com> <20031003042754.GH87525@rlx11.zapatec.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:FyuTA7XIMR7BGzzd/bnO8Qr0n2A= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/83 X-Sequence-Number: 3831 Oops! dror@zapatec.com (Dror Matalon) was seen spray-painting on a wall: > I smell a religious war in the aii:-). > Can you go several days in a row without doing select count(*) on any > of your tables? I would be more likely, personally, to run "VACUUM VERBOSE ANALYZE", which has useful side-effects :-). > I suspect that this is somewhat a domain specific issue. In some > areas you don't need to know the total number of rows in your > tables, in others you do. "Relationship tables," which don't contain data in their own right, but which, instead, link together records in other tables, are likely to have particularly useless COUNT(*)'s. > I also suspect that you're right, that end user applications don't > use this information as often as DBAs would. On the other hand, it > seems whenever you want to optimize your app (something relevant to > this list), one of the things you do need to know is the number of > rows in your table. Ah, but in the case of optimization, there's little need for "transactionally safe, MVCC-managed, known-to-be-exact" values. Approximations are plenty good enough to get the right plan. Furthermore, it's not the number of rows that is most important when optimizing queries; the number of pages are more relevant to the matter, as that's what the database is slinging around. -- (reverse (concatenate 'string "ac.notelrac.teneerf" "@" "454aa")) http://www3.sympatico.ca/cbbrowne/multiplexor.html Rules of the Evil Overlord #134. "If I am escaping in a large truck and the hero is pursuing me in a small Italian sports car, I will not wait for the hero to pull up along side of me and try to force him off the road as he attempts to climb aboard. Instead I will slam on the brakes when he's directly behind me. (A rudimentary knowledge of physics can prove quite useful.)" From pgsql-performance-owner@postgresql.org Fri Oct 3 09:37:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E9FFAD1B4FC for ; Fri, 3 Oct 2003 12:37:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40355-02 for ; Fri, 3 Oct 2003 09:36:56 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 4B1B4D1B503 for ; Fri, 3 Oct 2003 09:36:37 -0300 (ADT) Received: (qmail 34480 invoked from network); 3 Oct 2003 12:36:42 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 3 Oct 2003 12:36:42 -0000 Date: Fri, 3 Oct 2003 08:36:42 -0400 (EDT) From: Jeff To: Christopher Browne Cc: "pgsql-performance@postgresql.org" Subject: Re: count(*) slow on large tables In-Reply-To: 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: 200310/84 X-Sequence-Number: 3832 On Thu, 2 Oct 2003, Christopher Browne wrote: > I can't imagine why the raw number of tuples in a relation would be > expected to necessarily be terribly useful. > We use stuff like that for reporting queries. example: On our message boards each post is a row. The powers that be like to know how many posts there are total (In addition to 'today')- select count(*) from posts is how it has been done on our informix db. With our port to PG I instead select reltuples pg_class. I know when I login to a new db (or unknown to me db) the first thing I do is look at tables and see what sort of data there is.. but in code I'd rarely do that. I know some monitoring things around here also do a select count(*) on sometable to ensure it is growing, but like you said, this is easily done with the number of pages as well. yes. Informix caches this data. I believe Oracle does too. Mysql with InnoDB does the same thing PG does. (MyISAM caches it) -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 3 11:31:47 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B2034D1B4EF for ; Fri, 3 Oct 2003 14:31:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59709-08 for ; Fri, 3 Oct 2003 11:31:01 -0300 (ADT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id 173FCD1B502 for ; Fri, 3 Oct 2003 11:30:53 -0300 (ADT) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id 7E91E2BDEC for ; Fri, 3 Oct 2003 16:30:44 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id D797BDA8AB for ; Fri, 3 Oct 2003 16:30:44 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id 63487973EA for ; Fri, 3 Oct 2003 16:30:44 +0200 (SAST) Date: Fri, 3 Oct 2003 16:30:40 +0200 From: Stef To: pgsql-performance@postgresql.org Subject: Postgres low end processing. Message-Id: <20031003163040.3641f39a.svb@ucs.co.za> X-Mailer: Sylpheed version 0.9.5claws28 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: LV^-*d3kQlL,6{Y:X)M~tuL#y!p.kO_Qbc!xxqhZC4s}Y]L0g)z^aiLsQGY34d|}Xp:HNm)MRsc?^?ZQ}smznF&jx|w@,a**K&QL.Dc~2~M5V`zb>hExCJDB[[o=M)e"; k-n[7tz2TY7+; *_xX's(5cUEtdw*yG-OmKm}6($zpUz8S`Nz@w X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Fri__3_Oct_2003_16_30_41_+0200_m8AE1l+9oErPqzEx" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/85 X-Sequence-Number: 3833 --Signature=_Fri__3_Oct_2003_16_30_41_+0200_m8AE1l+9oErPqzEx Content-Type: multipart/mixed; boundary="Multipart=_Fri__3_Oct_2003_16_30_40_+0200_yL2q87cXztrCXW/D" --Multipart=_Fri__3_Oct_2003_16_30_40_+0200_yL2q87cXztrCXW/D Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Hi everyone, I've been trying to find out if some guidelines exist, somewhere, describing how postgres can possibly run on less than 8MB of RAM. (Disk space not an issue). The closest thread I could find in the list archives is : http://archives.postgresql.org/pgsql-general/2002-06/msg01343.php Is it possible to have a stripped-down version of postgres that will use an absolute minimal amount of memory? Maybe by switching off some features/options at compile time, and/or configuration tweaks? (Or anything else) This will be on very low end i386 architecture. Performance penalties are expected and will be accepted. I will need the functionality of >= 7.3.4 , at least. Any help will be much appreciated. Regards Stef --Multipart=_Fri__3_Oct_2003_16_30_40_+0200_yL2q87cXztrCXW/D Content-Type: application/pgp-signature; name="00000009.mimetmp" Content-Disposition: attachment; filename="00000009.mimetmp" Content-Transfer-Encoding: base64 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcg djEuMi4zIChHTlUvTGludXgpCgppRDhEQlFFL2ZZR1pnRFlzM1VrUmpaa1JB cnB5QUo5M2FaM3RNd1RTWlpnNUVlY0lkL29XUk9ZZnhRQ2ZhblNVCi80V0Y4 VVpTVnhxSS9BUW9rZ0hFUXFRPQo9WlFSaAotLS0tLUVORCBQR1AgU0lHTkFU VVJFLS0tLS0KCg== --Multipart=_Fri__3_Oct_2003_16_30_40_+0200_yL2q87cXztrCXW/D-- --Signature=_Fri__3_Oct_2003_16_30_41_+0200_m8AE1l+9oErPqzEx Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/fYgUgDYs3UkRjZkRAhdQAJ0a7V0JSug//08ktSGUwuBtBVpnZwCdHD/V pZ8v+JaRuNWhDlUBzpf6Gb0= =g+xq -----END PGP SIGNATURE----- --Signature=_Fri__3_Oct_2003_16_30_41_+0200_m8AE1l+9oErPqzEx-- From pgsql-performance-owner@postgresql.org Fri Oct 3 12:32:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 62A43D1B533 for ; Fri, 3 Oct 2003 14:57:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 63115-10 for ; Fri, 3 Oct 2003 11:56:32 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 32243D1B540 for ; Fri, 3 Oct 2003 11:56:24 -0300 (ADT) 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 h93EtUGQ029323; Fri, 3 Oct 2003 08:55:31 -0600 (MDT) Date: Fri, 3 Oct 2003 08:47:43 -0600 (MDT) From: "scott.marlowe" To: CN Cc: Subject: Re: Is This My Speed Limit? In-Reply-To: <20031003021407.6DC2F63D07@smtp.us2.messagingengine.com> 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: 200310/88 X-Sequence-Number: 3836 On Thu, 2 Oct 2003, CN wrote: > Hi! > > It's just my curiosity. I wonder if there is any way to break my speed > limit on AMD 450Mhz: You're most likely I/O bound, not CPU bound here. So, if you want better speed, you'll likely need a better storage subsystem. From pgsql-performance-owner@postgresql.org Fri Oct 3 12:46:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B1C4AD1B56C for ; Fri, 3 Oct 2003 15:44:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77268-06 for ; Fri, 3 Oct 2003 12:43:26 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C326FD1B582 for ; Fri, 3 Oct 2003 12:42:56 -0300 (ADT) 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 h93Fgthn024647; Fri, 3 Oct 2003 11:42:55 -0400 (EDT) To: Stef Cc: pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. In-reply-to: <20031003163040.3641f39a.svb@ucs.co.za> References: <20031003163040.3641f39a.svb@ucs.co.za> Comments: In-reply-to Stef message dated "Fri, 03 Oct 2003 16:30:40 +0200" Date: Fri, 03 Oct 2003 11:42:54 -0400 Message-ID: <24646.1065195774@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/90 X-Sequence-Number: 3838 Stef writes: > I've been trying to find out if some guidelines > exist, somewhere, describing how postgres > can possibly run on less than 8MB of RAM. Are you sure you want Postgres, and not something smaller? BDB, or SQL Lite, for example? "Postgres is bloatware by design: it was built to house PhD theses." -- J. Hellerstein (who ought to know) But having said that ... given virtual memory and cramped configuration settings, Postgres would certainly run in an 8M machine. Maybe "crawl" would be a more applicable verb than "run", but you could execute it. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Oct 3 12:43:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3D501D1B4F2 for ; Fri, 3 Oct 2003 15:40:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77399-03 for ; Fri, 3 Oct 2003 12:39:21 -0300 (ADT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by svr1.postgresql.org (Postfix) with ESMTP id F0239D1B53F for ; Fri, 3 Oct 2003 12:39:20 -0300 (ADT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA19275; Fri, 3 Oct 2003 11:39:19 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma019271; Fri, 3 Oct 03 11:38:58 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA18836; Fri, 3 Oct 2003 11:25:04 -0400 Message-ID: <3F7D9A57.B37A0DFC@nsd.ca> Date: Fri, 03 Oct 2003 11:48:39 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.8 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/89 X-Sequence-Number: 3837 Well I can think of many more case where it would be usefull: SELECT COUNT(DISTINCT x) FROM ... SELECT COUNT(*) FROM ... WHERE x = ? Also having transaction number (visibility) would tip the balance more toward index_scan than seq_scan because you do not have to look up visibility in the data file. We all know this has been an issue many times. Having a different index file structure when the index is not UNIQUE would help too. The last page of a non unique index could hold more stats. Christopher Browne wrote: > > jllachan@nsd.ca (Jean-Luc Lachance) writes: > > That's one of the draw back of MVCC. > > I once suggested that the transaction number and other house keeping > > info be included in the index, but was told to forget it... > > It would solve once and for all the issue of seq_scan vs index_scan. > > It would simplify the aggregate problem. > > It would only simplify _one_ case, namely the case where someone cares > about the cardinality of a relation, and it would do that at > _considerable_ cost. > > A while back I outlined how this would have to be done, and for it to > be done efficiently, it would be anything BUT simple. > > It would be very hairy to implement it correctly, and all this would > cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" > > If you had a single WHERE clause attached, you would have to revert to > walking through the tuples looking for the ones that are live and > committed, which is true for any DBMS. > > And it still begs the same question, of why the result of this query > would be particularly meaningful to anyone. I don't see the > usefulness; I don't see the value of going to the considerable effort > of "fixing" this purported problem. > -- > let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; > > Christopher Browne > (416) 646 3304 x124 (land) > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Fri Oct 3 13:11:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7303BD1B552 for ; Fri, 3 Oct 2003 16:11:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86269-03 for ; Fri, 3 Oct 2003 13:10:22 -0300 (ADT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id BACC4D1B53E for ; Fri, 3 Oct 2003 13:10:17 -0300 (ADT) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id 4EA932BDC0; Fri, 3 Oct 2003 18:10:10 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id 28867DA934; Fri, 3 Oct 2003 18:10:10 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id EB570973EA; Fri, 3 Oct 2003 18:10:09 +0200 (SAST) Date: Fri, 3 Oct 2003 18:10:02 +0200 From: Stef To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. Message-Id: <20031003181002.20cc6912.svb@ucs.co.za> In-Reply-To: <24646.1065195774@sss.pgh.pa.us> References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> X-Mailer: Sylpheed version 0.9.5claws28 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: LV^-*d3kQlL,6{Y:X)M~tuL#y!p.kO_Qbc!xxqhZC4s}Y]L0g)z^aiLsQGY34d|}Xp:HNm)MRsc?^?ZQ}smznF&jx|w@,a**K&QL.Dc~2~M5V`zb>hExCJDB[[o=M)e"; k-n[7tz2TY7+; *_xX's(5cUEtdw*yG-OmKm}6($zpUz8S`Nz@w X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Fri__3_Oct_2003_18_10_02_+0200_RUHA.E2bYB1TIrpy" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/91 X-Sequence-Number: 3839 --Signature=_Fri__3_Oct_2003_18_10_02_+0200_RUHA.E2bYB1TIrpy Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit On Fri, 03 Oct 2003 11:42:54 -0400 Tom Lane wrote: => Are you sure you want Postgres, and not something smaller? BDB, => or SQL Lite, for example? I have considered various options, including BDB and SQL Lite, but alas, it will have to be postgres if it's going to be a database. Otherwise it will be back to the original idea of flat .idx files :( => "Postgres is bloatware by design: it was built to house PhD theses." => -- J. Hellerstein (who ought to know) :o) Believe me, I've been amazed since I encountered postgres v6.3.2 in '98 => But having said that ... given virtual memory and cramped configuration => settings, Postgres would certainly run in an 8M machine. Maybe "crawl" => would be a more applicable verb than "run", but you could execute it. Crawling is ok. Won't differ much from normal operation on a machine like that. Any tips on how to achieve the most diminutive vmem an conf settings? I tried to figure this out from the docs, and played around with backend/storage , but I'm not really winning. Regards Stef --Signature=_Fri__3_Oct_2003_18_10_02_+0200_RUHA.E2bYB1TIrpy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/fZ9hgDYs3UkRjZkRAugiAJ905TWfgHxYHmS4nB6kUkjLD6x6fACdF/su FBDEM07zuuSR28recUKeBSc= =GXG7 -----END PGP SIGNATURE----- --Signature=_Fri__3_Oct_2003_18_10_02_+0200_RUHA.E2bYB1TIrpy-- From pgsql-performance-owner@postgresql.org Fri Oct 3 13:32:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 150EDD1B4E3 for ; Fri, 3 Oct 2003 16:32:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 88931-02 for ; Fri, 3 Oct 2003 13:32:01 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E8EC4D1B4F2 for ; Fri, 3 Oct 2003 13:32:00 -0300 (ADT) 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 h93GW0hn026555; Fri, 3 Oct 2003 12:32:01 -0400 (EDT) To: Stef Cc: pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. In-reply-to: <20031003181002.20cc6912.svb@ucs.co.za> References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> <20031003181002.20cc6912.svb@ucs.co.za> Comments: In-reply-to Stef message dated "Fri, 03 Oct 2003 18:10:02 +0200" Date: Fri, 03 Oct 2003 12:32:00 -0400 Message-ID: <26554.1065198720@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/92 X-Sequence-Number: 3840 Stef writes: > Crawling is ok. Won't differ much from normal operation on a machine > like that. Any tips on how to achieve the most diminutive vmem an > conf settings? The out-of-the-box settings are already pretty diminutive on current releases :-(. In 7.4 you'd likely want to knock back shared_buffers and max_connections, and maybe the fsm settings if the database is going to be tiny. > I tried to figure this out from the docs, and played > around with backend/storage , but I'm not really winning. What exactly is failing? And what's the platform, anyway? regards, tom lane From pgsql-performance-owner@postgresql.org Fri Oct 3 13:50:28 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4FCC0D1B4F2 for ; Fri, 3 Oct 2003 16:50:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90586-06 for ; Fri, 3 Oct 2003 13:49:32 -0300 (ADT) Received: from lorraine.ipl.co.uk (lorraine.ipl.co.uk [195.112.52.123]) by svr1.postgresql.org (Postfix) with ESMTP id 472E8D1B55D for ; Fri, 3 Oct 2003 13:49:30 -0300 (ADT) Received: from HFPORT.dmr.co.uk (pennsoft.gotadsl.co.uk [81.6.232.68]) by lorraine.ipl.co.uk (8.12.9/8.12.9) with ESMTP id h93Gn5GB023279; Fri, 3 Oct 2003 17:49:08 +0100 Message-Id: <5.1.0.14.0.20031003174352.02172a08@mailserver.ipl.co.uk> X-Sender: hf1@mailserver.ipl.co.uk X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 03 Oct 2003 17:50:17 +0100 To: "Gregory S. Williamson" From: Hilary Forbes Subject: Re: count(*) slow on large tables Cc: pgsql-performance@postgresql.org In-Reply-To: <71E37EF6B7DCC1499CEA0316A256832801057269@loki.wc.globexplo rer.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/93 X-Sequence-Number: 3841 We frequently need to know the number of tuples in a table although sometimes we do have WHERE status='X' for example but this often doesn't guarantee an indexed scan. And yes, my reasons are the same - reporting figures eg number of bookings made since the system was introduced. Have you tried doing SELECT count(pkey) rather than count(*) where pkey is the primary key (assuming you have a single field that is a primary key or a unique indexed key). This is MUCH faster in my experience. If you don't have such an animal, I'd seriously suggesting putting in a serial number and recreate the table with that as the primary key. The vacuuming bit is not accurate enough for us in many instances. Also a count can be easily fed into other programs/web pages etc without having to parse the vacuum output. Hilary At 23:22 02/10/2003 -0700, you wrote: >I can tell you that this is one of the first thing applications' programmers and IT managers notice. It can slightly tarnish postgres' image when it takes it many long seconds to do what other databases can do in a snap. The "whys and wherefores" can be hard to get across once they see the comparative numbers. > >When I use Informix "dbaccess" it has a "status" which will tell me the row count of a table virtually instantly -- it can be locked out by a user with an exclusive lock so its not entirely independant of the table (like a stored value in one of the system catalog tables). > >This is not to say Informix is "right" and Postgres is "wrong" ... but it is something that virtually any newcomer will run into head long, with resulting bruises and contusions, not to mention confusion. > >At the very least this needs to be VERY clearly explained right up front, along with some of the possible work-arounds, depending on what one is really after with this info. > >Greg Williamson >DBA >GlobeXplorer LLC > >-----Original Message----- >From: Dror Matalon [mailto:dror@zapatec.com] >Sent: Thu 10/2/2003 9:27 PM >To: pgsql-performance@postgresql.org >Cc: >Subject: Re: [PERFORM] count(*) slow on large tables > > >I smell a religious war in the aii:-). >Can you go several days in a row without doing select count(*) on any >of your tables? > >I suspect that this is somewhat a domain specific issue. In some areas >you don't need to know the total number of rows in your tables, in >others you do. > >I also suspect that you're right, that end user applications don't use >this information as often as DBAs would. On the other hand, it seems >whenever you want to optimize your app (something relevant to this list), >one of the things you do need to know is the number of rows in your >table. > >Dror > >On Thu, Oct 02, 2003 at 10:08:18PM -0400, Christopher Browne wrote: >> The world rejoiced as dror@zapatec.com (Dror Matalon) wrote: >> > I don't have an opinion on how hard it would be to implement the >> > tracking in the indexes, but "select count(*) from some table" is, in my >> > experience, a query that people tend to run quite often. >> > One of the databases that I've used, I believe it was Informix, had that >> > info cached so that it always new how many rows there were in any >> > table. It was quite useful. >> >> I can't imagine why the raw number of tuples in a relation would be >> expected to necessarily be terribly useful. >> >> I'm involved with managing Internet domains, and it's only when people >> are being pretty clueless that anyone imagines that "select count(*) >> from domains;" would be of any use to anyone. There are enough "test >> domains" and "inactive domains" and other such things that the raw >> number of "things in the table" aren't really of much use. >> >> - I _do_ care how many pages a table occupies, to some extent, as that >> determines whether it will fit in my disk space or not, but that's not >> COUNT(*). >> >> - I might care about auditing the exact numbers of records in order to >> be assured that a data conversion process was done correctly. But in >> that case, I want to do something a whole *lot* more detailed than >> mere COUNT(*). >> >> I'm playing "devil's advocate" here, to some extent. But >> realistically, there is good reason to be skeptical of the merits of >> using SELECT COUNT(*) FROM TABLE for much of anything. >> >> Furthermore, the relation that you query mightn't be a physical >> "table." It might be a more virtual VIEW, and if that's the case, >> bets are even MORE off. If you go with the common dictum of "good >> design" that users don't directly access tables, but go through VIEWs, >> users may have no way to get at SELECT COUNT(*) FROM TABLE. >> -- >> output = reverse("ac.notelrac.teneerf" "@" "454aa") >> http://www.ntlug.org/~cbbrowne/finances.html >> Rules of the Evil Overlord #74. "When I create a multimedia >> presentation of my plan designed so that my five-year-old advisor can >> easily understand the details, I will not label the disk "Project >> Overlord" and leave it lying on top of my desk." >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 4: Don't 'kill -9' the postmaster > >-- >Dror Matalon, President >Zapatec Inc >1700 MLK Way >Berkeley, CA 94709 >http://www.zapatec.com > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > > > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster Hilary Forbes ------------- DMR Computer Limited: http://www.dmr.co.uk/ Direct line: 01689 889950 Switchboard: (44) 1689 860000 Fax: (44) 1689 860330 E-mail: hforbes@dmr.co.uk ********************************************************** From pgsql-performance-owner@postgresql.org Fri Oct 3 13:56:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0CFADD1B51A for ; Fri, 3 Oct 2003 16:56:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 91668-02 for ; Fri, 3 Oct 2003 13:55:56 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id 67AD7D1B4F2 for ; Fri, 3 Oct 2003 13:55:55 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Fri, 3 Oct 2003 10:54:43 -0600 From: Oleg Lebedev To: Josh Berkus , "scott.marlowe" Cc: "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Fri, 3 Oct 2003 10:54:42 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731E7841@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/94 X-Sequence-Number: 3842 Josh, I declared all the indexes that you suggested and ran vacuum full analyze. The query plan has not changed and it's still trying to use seqscan. I tried to disable seqscan, but the plan didn't change. Any other suggestions? I started explain analyze on the query, but I doubt it will finish any time soon. Thanks. Oleg -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Thursday, October 02, 2003 11:27 PM To: Oleg Lebedev; scott.marlowe Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Oleg, > I have another question. How do I optimize my indexes for the query=20 > that contains a lot of ORed blocks, each of which contains a bunch of=20 > ANDed expressions? The structure of each ORed block is the same except > the right-hand-side values vary. Given the example, I'd do a multicolumn index on p_brand, p_container, p_size=20 and a second multicolumn index on l_partkey, l_quantity, l_shipmode. Hmmm=20 ... or maybe seperate indexes, one on l_partkey and one on l_quantity,=20 l_shipmode & l_instruct. Test both configurations. Mind you, if this is also an OLTP table, then you'd want to test those=20 multi-column indexes to determine the least columns you need for the indexes=20 still to be used, since more columns =3D more index maintainence. --=20 Josh Berkus Aglio Database Solutions San Francisco ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Fri Oct 3 14:23:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0F5EED1B55C for ; Fri, 3 Oct 2003 17:23:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 99412-02 for ; Fri, 3 Oct 2003 14:23:05 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id E845CD1B4E3 for ; Fri, 3 Oct 2003 14:23:03 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3718447; Fri, 03 Oct 2003 10:23:38 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Oleg Lebedev , "scott.marlowe" Subject: Re: TPC-R benchmarks Date: Fri, 3 Oct 2003 10:21:50 -0700 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" References: <993DBE5B4D02194382EC8DF8554A52731E7841@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731E7841@postoffice.waterford.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310031021.50918.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/95 X-Sequence-Number: 3843 Oleg, > I declared all the indexes that you suggested and ran vacuum full > analyze. The query plan has not changed and it's still trying to use > seqscan. I tried to disable seqscan, but the plan didn't change. Any > other suggestions? > I started explain analyze on the query, but I doubt it will finish any > time soon. Can I get a copy of the database so that I can tinker? I'm curious now, plus I want our benchmarks to look good. I have a private FTP if that helps. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 14:53:47 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0CE4DD1B531 for ; Fri, 3 Oct 2003 17:53:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03332-03 for ; Fri, 3 Oct 2003 14:52:54 -0300 (ADT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5D9EAD1B50F for ; Fri, 3 Oct 2003 14:52:53 -0300 (ADT) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id C19212BD81; Fri, 3 Oct 2003 19:52:42 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id 8B8A8D9E05; Fri, 3 Oct 2003 19:52:42 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id 5A717973EA; Fri, 3 Oct 2003 19:52:42 +0200 (SAST) Date: Fri, 3 Oct 2003 19:52:38 +0200 From: Stef To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. Message-Id: <20031003195238.16fc1229.svb@ucs.co.za> In-Reply-To: <26554.1065198720@sss.pgh.pa.us> References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> <20031003181002.20cc6912.svb@ucs.co.za> <26554.1065198720@sss.pgh.pa.us> X-Mailer: Sylpheed version 0.9.5claws28 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: LV^-*d3kQlL,6{Y:X)M~tuL#y!p.kO_Qbc!xxqhZC4s}Y]L0g)z^aiLsQGY34d|}Xp:HNm)MRsc?^?ZQ}smznF&jx|w@,a**K&QL.Dc~2~M5V`zb>hExCJDB[[o=M)e"; k-n[7tz2TY7+; *_xX's(5cUEtdw*yG-OmKm}6($zpUz8S`Nz@w X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Fri__3_Oct_2003_19_52_38_+0200_9wyB/8t3ArhbbHVz" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/96 X-Sequence-Number: 3844 --Signature=_Fri__3_Oct_2003_19_52_38_+0200_9wyB/8t3ArhbbHVz Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit On Fri, 03 Oct 2003 12:32:00 -0400 Tom Lane wrote: => What exactly is failing? And what's the platform, anyway? Nothing is really failing atm, except the funds for better hardware. JBOSS and some other servers need to be run on these machines, along with linux, which will be a minimal RH >= 7.2 with kernel 2.4.21 (Any better suggestions here?) In this case, whatever is the least amount of memory postgres can run on, is what is needed. So this is still a kind of feasibility study. Of course, it will still be thoroughly tested, if it turns out to be possible. (Which I know it is, but not how) Regards Stef --Signature=_Fri__3_Oct_2003_19_52_38_+0200_9wyB/8t3ArhbbHVz Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/fbdqgDYs3UkRjZkRAm5kAJ0cfqccA3w5y1SWDK3RUvvEDmZqNQCgg90k pXNgZely+ho25p8AwbvpBXE= =1vZ/ -----END PGP SIGNATURE----- --Signature=_Fri__3_Oct_2003_19_52_38_+0200_9wyB/8t3ArhbbHVz-- From pgsql-performance-owner@postgresql.org Fri Oct 3 15:06:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 34B94D1B4F2 for ; Fri, 3 Oct 2003 18:06:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00923-10 for ; Fri, 3 Oct 2003 15:05:39 -0300 (ADT) Received: from mail.waterford.org (67.107.203.158.ptr.us.xo.net [67.107.203.158]) by svr1.postgresql.org (Postfix) with ESMTP id AA477D1B502 for ; Fri, 3 Oct 2003 15:05:37 -0300 (ADT) Received: by mail.waterford.org with XWall v3.27 ; Fri, 3 Oct 2003 12:04:23 -0600 From: Oleg Lebedev To: Josh Berkus Cc: "pgsql-performance@postgresql.org" Subject: Re: TPC-R benchmarks Date: Fri, 3 Oct 2003 12:04:23 -0600 X-Assembled-By: XWall v3.27 Message-ID: <993DBE5B4D02194382EC8DF8554A52731D7630@postoffice.waterford.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/97 X-Sequence-Number: 3845 Josh, My data directory is 3.8 GB. I can send you flat data files and scripts to create indices, but still it would be about 1.3 GB of data. Do you still want me to transfer data to you? If yes, then just give me your FTP address. Thanks. Oleg -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Friday, October 03, 2003 11:22 AM To: Oleg Lebedev; scott.marlowe Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] TPC-R benchmarks Oleg, > I declared all the indexes that you suggested and ran vacuum full=20 > analyze. The query plan has not changed and it's still trying to use=20 > seqscan. I tried to disable seqscan, but the plan didn't change. Any=20 > other suggestions? I started explain analyze on the query, but I doubt > it will finish any time soon. Can I get a copy of the database so that I can tinker? I'm curious now, plus=20 I want our benchmarks to look good. I have a private FTP if that helps. --=20 Josh Berkus Aglio Database Solutions San Francisco ************************************* This e-mail may contain privileged or confidential material intended for th= e named recipient only. If you are not the named recipient, delete this message and all attachments. Unauthorized reviewing, copying, printing, disclosing, or otherwise using i= nformation in this e-mail is prohibited. We reserve the right to monitor e-mail sent through our network.=20 ************************************* From pgsql-performance-owner@postgresql.org Fri Oct 3 15:11:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B8A8CD1B4FC for ; Fri, 3 Oct 2003 18:11:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03129-08 for ; Fri, 3 Oct 2003 15:10:29 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 5B6B2D1B4E3 for ; Fri, 3 Oct 2003 15:10:27 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3718705; Fri, 03 Oct 2003 11:10:37 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Stef , pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. Date: Fri, 3 Oct 2003 11:08:48 -0700 User-Agent: KMail/1.4.3 References: <20031003163040.3641f39a.svb@ucs.co.za> In-Reply-To: <20031003163040.3641f39a.svb@ucs.co.za> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310031108.49002.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/98 X-Sequence-Number: 3846 Stef, > I've been trying to find out if some guidelines > exist, somewhere, describing how postgres > can possibly run on less than 8MB of RAM. > (Disk space not an issue). I can tell you from experience that you will get some odd behaviour, and even connection failures, when Postgres is forced into swap by lack of memory. Also, you will run into trouble with the default Linux kernel 2.4 VM manager, which allows applications to overcommit memory; either hack your own memory manager, or designate swap space >= 200% of RAM. Also, program your application to expect, and recover from, PostgreSQL failures and connection failures. > Is it possible to have a stripped-down version of > postgres that will use an absolute minimal amount > of memory? I don;t know that there is anything you can remove safely from the postgres core that would save you memory. > Maybe by switching off some features/options > at compile time, and/or configuration tweaks? > (Or anything else) You're in luck; the default postgresql.conf file for 7.3 is actually cofigured for a low-memory, slow machine setup (which most other people bitch about). Here's a few other things you can do: 1. Make sure that the WAL files (pg_xlog) are on a seperate disk from the database files, either through mounting or symlinking. 2. Tweak the .conf file for low vacuum_mem (1024?), but vacuum very frequently, like every 1-5 minutes. Spend some time tuning your fsm_max_pages to the ideal level so that you're not allocating any extra memory to the FSM. 3. If your concern is *average* CPU/RAM consumption, and not peak load activity, increase wal_files and checkpoint_segments to do more efficient batch processing of pending updates as the cost of some disk space. If peak load activity is a problem, don't do this. 4. Tune all of your queries carefully to avoid anything requiring a RAM-intensive merge join or CPU-eating calculated expression hash join, or similar computation-or-RAM-intensive operations. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 15:34:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 703F7D1B557 for ; Fri, 3 Oct 2003 18:34:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 10568-08 for ; Fri, 3 Oct 2003 15:34:06 -0300 (ADT) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by svr1.postgresql.org (Postfix) with ESMTP id 1E95CD1B4EF for ; Fri, 3 Oct 2003 15:34:05 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031003183401.KDPD17750.lakemtao02.cox.net@lhosts> for ; Fri, 3 Oct 2003 14:34:01 -0400 Subject: Re: Postgres low end processing. From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <20031003195238.16fc1229.svb@ucs.co.za> References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> <20031003181002.20cc6912.svb@ucs.co.za> <26554.1065198720@sss.pgh.pa.us> <20031003195238.16fc1229.svb@ucs.co.za> Content-Type: text/plain Message-Id: <1065206040.1513.98.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Fri, 03 Oct 2003 13:34:00 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/99 X-Sequence-Number: 3847 On Fri, 2003-10-03 at 12:52, Stef wrote: > On Fri, 03 Oct 2003 12:32:00 -0400 > Tom Lane wrote: > > => What exactly is failing? And what's the platform, anyway? > > Nothing is really failing atm, except the funds for better > hardware. JBOSS and some other servers need to be > run on these machines, along with linux, which will be > a minimal RH >= 7.2 with kernel 2.4.21 > (Any better suggestions here?) > > In this case, whatever is the least amount of memory > postgres can run on, is what is needed. So this is still > a kind of feasibility study. Of course, it will still be thoroughly > tested, if it turns out to be possible. (Which I know it is, but not how) JBOSS, PostgreSQL & 2.4.21 all on a computer w/ 8MB RAM? A 486 or *very* low end Pentium? It'll thrash (in the literal sense) the page files. *No* work will get done. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "...always eager to extend a friendly claw" From pgsql-performance-owner@postgresql.org Fri Oct 3 16:06:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4EFEFD1B553 for ; Fri, 3 Oct 2003 19:06:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21932-01 for ; Fri, 3 Oct 2003 16:05:11 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id D1606D1B4E3 for ; Fri, 3 Oct 2003 16:05:09 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id E9DC41E13; Fri, 3 Oct 2003 15:04:54 -0400 (EDT) Subject: Re: Postgres low end processing. From: Neil Conway To: Josh Berkus Cc: Stef , PostgreSQL Performance In-Reply-To: <200310031108.49002.josh@agliodbs.com> References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> Content-Type: text/plain Message-Id: <1065207892.391.36.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 15:04:52 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/100 X-Sequence-Number: 3848 On Fri, 2003-10-03 at 14:08, Josh Berkus wrote: > I can tell you from experience that you will get some odd behaviour, and even > connection failures, when Postgres is forced into swap by lack of memory. Why would you get a connection failure? And other than poor performance, why would you get "odd behavior" due to a lack of physical memory? -Neil From pgsql-performance-owner@postgresql.org Fri Oct 3 16:23:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0A099D1B53C for ; Fri, 3 Oct 2003 19:23:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24186-01 for ; Fri, 3 Oct 2003 16:22:48 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id A6FBDD1B50E for ; Fri, 3 Oct 2003 16:22:46 -0300 (ADT) 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 h93JLdGQ022094; Fri, 3 Oct 2003 13:21:40 -0600 (MDT) Date: Fri, 3 Oct 2003 13:13:51 -0600 (MDT) From: "scott.marlowe" To: Ron Johnson Cc: PgSQL Performance ML Subject: Re: Postgres low end processing. In-Reply-To: <1065206040.1513.98.camel@haggis> 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: 200310/101 X-Sequence-Number: 3849 On Fri, 3 Oct 2003, Ron Johnson wrote: > On Fri, 2003-10-03 at 12:52, Stef wrote: > > On Fri, 03 Oct 2003 12:32:00 -0400 > > Tom Lane wrote: > > > > => What exactly is failing? And what's the platform, anyway? > > > > Nothing is really failing atm, except the funds for better > > hardware. JBOSS and some other servers need to be > > run on these machines, along with linux, which will be > > a minimal RH >= 7.2 with kernel 2.4.21 > > (Any better suggestions here?) > > > > In this case, whatever is the least amount of memory > > postgres can run on, is what is needed. So this is still > > a kind of feasibility study. Of course, it will still be thoroughly > > tested, if it turns out to be possible. (Which I know it is, but not how) > > JBOSS, PostgreSQL & 2.4.21 all on a computer w/ 8MB RAM? A 486 or > *very* low end Pentium? > > It'll thrash (in the literal sense) the page files. *No* work > will get done. I built a test server four years ago on a P100 with 64 Megs of RAM and it was already a pretty slow / old box at that time. Considering that those kind of beasts sell by the pound nowadays, I can't imagine torturing yourself by using a 486 with 8 megs of ram. Even my ancient 486DX50 Toshiba 4700 has 16 Megs of ram in it. IF ons has to develop in such a low end environment you're much better off either writing perl CGI or using PHP, which both use much less memory than JBoss. I don't think I'd try to run JBoss / Postgresql on anything less than 64 or 128 Meg of RAM. Even then you're probably looking at having a fair bit of swapping going on. From pgsql-performance-owner@postgresql.org Fri Oct 3 17:21:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9FAECD1B923 for ; Fri, 3 Oct 2003 20:21:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37206-01 for ; Fri, 3 Oct 2003 17:21:00 -0300 (ADT) Received: from krusty-motorsports.com (krusty-motorsports.com [192.94.170.8]) by svr1.postgresql.org (Postfix) with ESMTP id AC296D1CAE3 for ; Fri, 3 Oct 2003 16:52:52 -0300 (ADT) Received: from [24.194.112.77] (helo=skipper.averillpark.net) by krusty-motorsports.com with asmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.22) id 1A5Vyv-0008R8-Nb for pgsql-performance@postgresql.org; Fri, 03 Oct 2003 19:52:53 +0000 Received: from rwelty by skipper.averillpark.net with local (Exim 4.22) id 1A5VxY-000621-VR for pgsql-performance@postgresql.org; Fri, 03 Oct 2003 15:51:28 -0400 Date: Fri, 3 Oct 2003 15:51:28 -0400 (EDT) From: Richard Welty Subject: Re: Postgres low end processing. To: pgsql-performance@postgresql.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII Content-Disposition: INLINE References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> In-Reply-To: <24646.1065195774@sss.pgh.pa.us> Reply-To: Stef Organization: Averill Park Networking X-Mailer: Mahogany 0.65.0 'Claire', compiled for Linux 2.4.20-19.9 i686 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/102 X-Sequence-Number: 3850 On Fri, 03 Oct 2003 11:42:54 -0400 Tom Lane wrote: > "Postgres is bloatware by design: it was built to house PhD theses." > -- J. Hellerstein (who ought to know) if postgres is bloatware, what is oracle 9i? (after i downloaded a copy of oracle 8i a couple of months back, i swore i'd never complain about the size of postgresql ever ever again.) richard -- Richard Welty rwelty@averillpark.net Averill Park Networking 518-573-7592 Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security From pgsql-performance-owner@postgresql.org Fri Oct 3 17:40:42 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 07B93D1CA5E for ; Fri, 3 Oct 2003 20:40:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 39688-03 for ; Fri, 3 Oct 2003 17:39:51 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id A5266D1B582 for ; Fri, 3 Oct 2003 17:21:35 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 83072ACAC for ; Fri, 3 Oct 2003 20:21:21 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h93KLK2N097195 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 13:21:20 -0700 (PDT) (envelope-from dror) Date: Fri, 3 Oct 2003 13:21:20 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Speeding up Aggregates Message-ID: <20031003202120.GO87525@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/103 X-Sequence-Number: 3851 Hi, I have a query that ran quite well initially, but slowed down quite a bit once I introduced an aggregate into the equation. The average execution time went up from around 15 msec to around 300 msec. The original query fetches a bunch of articles: select articlenumber, channel, description, title, link, dtstamp from items, my_channels where items.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and dtstamp > last_viewed and articlenumber not in (select item from viewed_items where channel ='22222' and owner = 'drormata'); I then added a call to a function: and (dtstamp = item_max_date(22222, link)) item_max_date() looks like this: select max(dtstamp) from items where channel = $1 and link = $2; This should eliminate duplicate articles and only show the most recent one. resulting in the following query select articlenumber, channel, description, title, link, dtstamp from items, my_channels where items.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and dtstamp > last_viewed and articlenumber not in (select item from viewed_items where channel ='22222' and owner = 'drormata') and (dtstamp = item_max_date(22222, link)); Any suggestions on optimizing the query/function? It makes sense that it slowed down, but I wonder if I can do better. I'm including index list as well as "explain analyze" of both versions. Indexes: "item_channel_link" btree (channel, link) "item_created" btree (dtstamp) "item_signature" btree (signature) "items_channel_article" btree (channel, articlenumber) explain analyze select articlenumber, channel, description, title, link, dtstamp from items, my_channels where items.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and dtstamp > last_viewed and articlenumber not in (select item from viewed_items where channel ='22222' and owner = 'drormata'); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------- Nested Loop (cost=8.19..6982.58 rows=302 width=259) (actual time=16.95..17.16 rows=8 loops=1) Join Filter: ("inner".dtstamp > "outer".last_viewed) -> Seq Scan on my_channels (cost=0.00..3.23 rows=1 width=8) (actual time=0.36..0.38 rows=1 loops=1) Filter: ((id = 22222) AND (("owner")::text = 'drormata'::text)) -> Index Scan using items_channel_article on items (cost=8.19..6968.05 rows=904 width=259) (actual time=0.68..13.94 rows=899 loops=1) Index Cond: (channel = 22222) Filter: (NOT (hashed subplan)) SubPlan -> Seq Scan on viewed_items (cost=0.00..8.19 rows=2 width=4) (actual time=0.48..0.48 rows=0 loops=1) Filter: ((channel = 22222) AND (("owner")::text = 'drormata'::text)) Total runtime: 17.42 msec (11 rows) explain analyze select articlenumber, channel, description, title, link, dtstamp from items, my_channels where items.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and dtstamp > last_viewed and articlenumber not in (select item from viewed_items where channel ='22222' and owner = 'drormata') and (dtstamp = item_max_date(22222, link)); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop (cost=8.19..6980.33 rows=1 width=259) (actual time=262.94..265.14 rows=7 loops=1) Join Filter: ("outer".dtstamp > "inner".last_viewed) -> Index Scan using items_channel_article on items (cost=8.19..6977.08 rows=1 width=259) (actual time=1.94..150.55 rows=683 loops=1) Index Cond: (channel = 22222) Filter: ((dtstamp = item_max_date(22222, link)) AND (NOT (hashed subplan))) SubPlan -> Seq Scan on viewed_items (cost=0.00..8.19 rows=2 width=4) (actual time=0.43..0.43 rows=0 loops=1) Filter: ((channel = 22222) AND (("owner")::text = 'drormata'::text)) -> Seq Scan on my_channels (cost=0.00..3.23 rows=1 width=8) (actual time=0.14..0.15 rows=1 loops=683) Filter: ((id = 22222) AND (("owner")::text = 'drormata'::text)) Total runtime: 265.39 msec -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 17:40:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 07E3AD1CA66 for ; Fri, 3 Oct 2003 20:40:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40018-01 for ; Fri, 3 Oct 2003 17:39:55 -0300 (ADT) Received: from travelers.mail.cornell.edu (travelers.mail.cornell.edu [132.236.56.13]) by svr1.postgresql.org (Postfix) with ESMTP id 382F0D1B9B6 for ; Fri, 3 Oct 2003 17:21:51 -0300 (ADT) Received: from travelers.mail.cornell.edu (travelers.mail.cornell.edu [132.236.56.13]) by travelers.mail.cornell.edu (8.9.3p2/8.9.3) with SMTP id QAA28701; Fri, 3 Oct 2003 16:21:48 -0400 (EDT) Date: Fri, 3 Oct 2003 16:21:48 -0400 (EDT) From: apb18@cornell.edu X-Sender: apb18@travelers.mail.cornell.edu To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Joins on inherited tables In-Reply-To: <864.1065028461@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: 200310/104 X-Sequence-Number: 3852 OK, so I've had a bit of time to look things over, and appear to be making headway. Here's how things stand right now: I added a function called best_inner_scan used the same way as best_inner_indexscan, but it's a bit more generalized in the sense that it can make append plans comprising of the best scans for each constituent table (it makes calls to best_inner_indexscan for each child), or just return the best simple index scan (or null) for plain relations. In order to make that work, I gave the child tables modified join clauses from the parent... modified in the sense that I had to make the operands match the inherited child table (they would match the parent otherwise if I were to simply copy the Joininfo nodes, and thus fail in finding an appropriate index in the child table). I'm not entirely comfortable with that solution yet, as I'm not absolutely certain those additonal modified join clauses wont' affect something else in the code that I'm not aware of, but it appears to be having the desired effect. Basically, with optimizer debug enabled, I'm getting plans that look like this (with the same queries as before) RELOPTINFO (1 2): rows=501 width=19 cheapest total path: NestLoop(1 2) rows=501 cost=0.00..1253.67 clauses: numbers.id = ids.id SeqScan(1) rows=1 cost=0.00..0.02 Append(2) rows=100051 cost=0.00..3.01 As opposed to this: RELOPTINFO (1 2): rows=501 width=19 cheapest total path: HashJoin(1 2) rows=501 cost=0.00..2195.79 clauses: numbers.id = ids.id SeqScan(1) rows=1 cost=0.00..0.02 Append(2) rows=100051 cost=0.00..1690.50 The total cost seems a high for the nestloop.. its constituents are certainly cheap. I need to look to see if I missed keeping track of costs somewhere. When I EXPLAIN, though, I get an error from the executor: "ERROR: both left and right operands are rel-vars". I haven't looked into that yet, but the results so far are encouraging enough to press on and get this completed. There was one hairy part, though, which will have to be addressed at some later point: Right now there is a boolean 'inh' in the RangeTblEntry struct which indicates "inheritance requested". When the inheritance root is first expanded by expand_inherited_rtentry(), the rte->inh is nulled in order to prevent expansion of an UPDATE/DELETE target. This presented problems for me when I wanted to detect which relation was an inheritor one in order to expand it into the append path. For my testing purposes, I just commented out the line, but for a real solution, that's not an acceptable solution and some struct might have to be changed slightly in order to convey the inheritance knowledge.. So, I guess the next step is to see what the executor is complaining about and see if it's something that would need attention in the executor of if it's something I did wrong.. If everything appears to work after that point, then I'll check for efficiency and use of cache in generating the inner scan plans. Thanks for the advice and historical perspective so far, Tom. It has been quite helpful. -Aaron From pgsql-performance-owner@postgresql.org Fri Oct 3 17:43:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4C610D1BADD for ; Fri, 3 Oct 2003 20:43:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 39688-06 for ; Fri, 3 Oct 2003 17:42:52 -0300 (ADT) Received: from jump.bivio.com (jump.bivio.com [216.87.82.232]) by svr1.postgresql.org (Postfix) with ESMTP id E62ACD1BA87 for ; Fri, 3 Oct 2003 17:24:46 -0300 (ADT) Received: (from nagler@localhost) by jump.bivio.com (8.11.6/8.11.6) id h93KOgL20962; Fri, 3 Oct 2003 14:24:42 -0600 X-Authentication-Warning: jump.bivio.com: nagler set sender to nagler@bivio.biz using -f From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16253.56074.737161.470428@jump.bivio.com> Date: Fri, 3 Oct 2003 14:24:42 -0600 To: pgsql-performance@postgresql.org Subject: reindex/vacuum locking/performance? X-Mailer: VM 6.96 under Emacs 20.7.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/105 X-Sequence-Number: 3853 I've read some posts that says vacuum doesn't lock, but my experience today indicates the opposite. It seemed that "vacuum full analyze" was locked waiting and so were other postmaster processes. It appeared to be deadlock, because all were in "WAITING" state according to ps. I let this go for about a 1/2 hour, and then killed the vacuum at which point all other processes completed normally. The same thing seemed to be happening with reindex on a table. It seems that the reindex locks the table and some other resource which then causes deadlock with other active processes. Another issue seems to be performance. A reindex on some indexes is taking 12 minutes or so. Vacuum seems to be slow, too. Way longer than the time it takes to reimport the entire database (30 mins). In summary, I suspect that it is better from a UI perspective to bring down the app on Sat at 3 a.m and reimport with a fixed time period than to live through reindexing/vacuuming which may deadlock. Am I missing something? Thanks, Rob From pgsql-general-owner@postgresql.org Fri Oct 3 17:51:41 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DC4AFD1B55E for ; Fri, 3 Oct 2003 20:51:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40018-10 for ; Fri, 3 Oct 2003 17:50:53 -0300 (ADT) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by svr1.postgresql.org (Postfix) with ESMTP id 89394D1B533 for ; Fri, 3 Oct 2003 17:42:31 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031003204234.MCKL17519.lakemtao03.cox.net@lhosts> for ; Fri, 3 Oct 2003 16:42:34 -0400 Subject: Re: [PERFORM] Postgres low end processing. From: Ron Johnson To: PgSQL General ML In-Reply-To: <1065207892.391.36.camel@tokyo> References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> <1065207892.391.36.camel@tokyo> Content-Type: text/plain Message-Id: <1065213752.1487.144.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Fri, 03 Oct 2003 15:42:32 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/169 X-Sequence-Number: 50242 On Fri, 2003-10-03 at 14:04, Neil Conway wrote: > On Fri, 2003-10-03 at 14:08, Josh Berkus wrote: > > I can tell you from experience that you will get some odd behaviour, and even > > connection failures, when Postgres is forced into swap by lack of memory. > > Why would you get a connection failure? And other than poor performance, > why would you get "odd behavior" due to a lack of physical memory? It would take so long for the "server" to respond that the client might time out. Of course, back in the day, we supported 70 people on a mainframe w/ 1.6 MIPS and 8MB RAM. FEPs and 3270 terminals helped, of course. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "All machines, no matter how complex, are considered to be based on 6 simple elements: the lever, the pulley, the wheel and axle, the screw, the wedge and the inclined plane." Marilyn Vos Savant From pgsql-performance-owner@postgresql.org Fri Oct 3 18:01:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CC417D1B562 for ; Fri, 3 Oct 2003 21:01:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 42934-03 for ; Fri, 3 Oct 2003 18:00:39 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 3CDE4D1B571 for ; Fri, 3 Oct 2003 17:57:58 -0300 (ADT) 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 h93Kvuhn000955; Fri, 3 Oct 2003 16:57:57 -0400 (EDT) To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? In-reply-to: <16253.56074.737161.470428@jump.bivio.com> References: <16253.56074.737161.470428@jump.bivio.com> Comments: In-reply-to Rob Nagler message dated "Fri, 03 Oct 2003 14:24:42 -0600" Date: Fri, 03 Oct 2003 16:57:56 -0400 Message-ID: <954.1065214676@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/106 X-Sequence-Number: 3854 Rob Nagler writes: > I've read some posts that says vacuum doesn't lock, but my experience > today indicates the opposite. It seemed that "vacuum full analyze" > was locked waiting and so were other postmaster processes. vacuum full does require exclusive lock, plain vacuum does not. > It > appeared to be deadlock, because all were in "WAITING" state according > to ps. I let this go for about a 1/2 hour, and then killed the vacuum > at which point all other processes completed normally. It's considerably more likely that the vacuum was waiting for an open client transaction (that had a read or write lock on some table) to finish than that there was an undetected deadlock. I suggest looking at your client code. Also, in 7.3 or later you could look at the pg_locks view to work out exactly who has the lock that's blocking vacuum. > Another issue seems to be performance. A reindex on some indexes is > taking 12 minutes or so. Vacuum seems to be slow, too. Way longer > than the time it takes to reimport the entire database (30 mins). vacuum full is indeed slow. That's why we do not recommend it as a routine maintenance procedure. The better approach is to do plain vacuums often enough that you don't need vacuum full. In pre-7.4 releases you might need periodic reindexes too, depending on whether your usage patterns tickle the index-bloat problem. But it is easily demonstrable that reindexing is cheaper than rebuilding the database. > In summary, I suspect that it is better from a UI perspective to bring > down the app on Sat at 3 a.m and reimport with a fixed time period > than to live through reindexing/vacuuming which may deadlock. Am I > missing something? Almost certainly, though you've not provided enough detail to determine what. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Oct 3 18:09:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 16DDFD1B53C for ; Fri, 3 Oct 2003 21:09:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 42799-10 for ; Fri, 3 Oct 2003 18:09:04 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 6E38AD1B55A for ; Fri, 3 Oct 2003 18:09:02 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3719664; Fri, 03 Oct 2003 14:09:38 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Dror Matalon , pgsql-performance@postgresql.org Subject: Re: Speeding up Aggregates Date: Fri, 3 Oct 2003 14:07:10 -0700 User-Agent: KMail/1.4.3 References: <20031003202120.GO87525@rlx11.zapatec.com> In-Reply-To: <20031003202120.GO87525@rlx11.zapatec.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310031407.10343.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/107 X-Sequence-Number: 3855 Dror, > select articlenumber, channel, description, title, link, dtstamp from > items, my_channels where items.channel =3D '22222' and my_channels.id = =3D > '22222' and owner =3D 'drormata' and dtstamp > last_viewed and > articlenumber not in (select item from viewed_items where channel > =3D'22222' and owner =3D 'drormata'); the NOT IN is a bad idea unless the subselect never returns more than a=20 handful of rows. If viewed_items can grow to dozens of rows, wyou should= =20 use WHERE NOT EXISTS instead. Unless you're using 7.4. > item_max_date() looks like this: > select max(dtstamp) from items where channel =3D $1 and link =3D $2; Change it to=20 SELECT dtstamp from iterm where channel =3D $1 and link =3D $2 ORDER BY dtstamp DESC LIMIT 1 and possibly build an index on channel, link, dtstamp --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 18:29:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7CEAAD1B506 for ; Fri, 3 Oct 2003 21:29:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 47510-10 for ; Fri, 3 Oct 2003 18:28:49 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id DA584D1B500 for ; Fri, 3 Oct 2003 18:28:46 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 20A74ACAC for ; Fri, 3 Oct 2003 21:28:48 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h93LSmE7097315 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 14:28:48 -0700 (PDT) (envelope-from dror) Date: Fri, 3 Oct 2003 14:28:48 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Speeding up Aggregates Message-ID: <20031003212848.GP87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <200310031407.10343.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310031407.10343.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/108 X-Sequence-Number: 3856 Hi Josh, On Fri, Oct 03, 2003 at 02:07:10PM -0700, Josh Berkus wrote: > Dror, > > > select articlenumber, channel, description, title, link, dtstamp from > > items, my_channels where items.channel = '22222' and my_channels.id = > > '22222' and owner = 'drormata' and dtstamp > last_viewed and > > articlenumber not in (select item from viewed_items where channel > > ='22222' and owner = 'drormata'); > > the NOT IN is a bad idea unless the subselect never returns more than a > handful of rows. If viewed_items can grow to dozens of rows, wyou should > use WHERE NOT EXISTS instead. Unless you're using 7.4. > I am using 7.4, and had tried NOT EXISTS and didn't see any improvements. > > item_max_date() looks like this: > > select max(dtstamp) from items where channel = $1 and link = $2; > > Change it to > > SELECT dtstamp from iterm where channel = $1 and link = $2 > ORDER BY dtstamp DESC LIMIT 1 > Didn't make a difference. And plugging real values into this query as well as into the original select max(dtstamp) from items where channel = $1 and link = $2; and doing an explain analyze shows that the cost is the same. The strange things is that when I run the above queries by hand they take about .5 msec. Yet on a resultset that fetches 5 rows, I go up from 15 msec to 300 msec. It would seem like it should be something like 15 + (0.5 * 5) + small overhead, = 30 msec or so rather than the 300 I'm seeing. > and possibly build an index on channel, link, dtstamp Didn't make a difference either. Explain analyze shows that it didn't use it. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 19:20:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DD3C8D1B50E for ; Fri, 3 Oct 2003 22:20:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51284-10 for ; Fri, 3 Oct 2003 19:19:42 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 26720D1B506 for ; Fri, 3 Oct 2003 19:19:40 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h93MJdQl054653 for ; Fri, 3 Oct 2003 22:19:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h93M9xUb053627 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 22:09:59 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: reindex/vacuum locking/performance? Date: Fri, 03 Oct 2003 17:34:14 -0400 Organization: Hub.Org Networking Services Lines: 47 Message-ID: <60d6de9fah.fsf@dev6.int.libertyrms.info> References: <16253.56074.737161.470428@jump.bivio.com> 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:PxzAec+YnnTgAP4sW75pZIs4aOc= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/119 X-Sequence-Number: 3867 nagler@bivio.biz (Rob Nagler) writes: > I've read some posts that says vacuum doesn't lock, but my experience > today indicates the opposite. It seemed that "vacuum full analyze" > was locked waiting and so were other postmaster processes. It > appeared to be deadlock, because all were in "WAITING" state according > to ps. I let this go for about a 1/2 hour, and then killed the vacuum > at which point all other processes completed normally. VACUUM FULL certainly does lock. See the man page: INPUTS FULL Selects ``full'' vacuum, which may reclaim more space, but takes much longer and exclusively locks the table. The usual answer is that you probably _didn't_ want to VACUUM FULL. VACUUM ('no full') does NOT block updates. > The same thing seemed to be happening with reindex on a table. It > seems that the reindex locks the table and some other resource which > then causes deadlock with other active processes. Not surprising either. While the reindex takes place, updates to that table have to be deferred. > Another issue seems to be performance. A reindex on some indexes is > taking 12 minutes or so. Vacuum seems to be slow, too. Way longer > than the time it takes to reimport the entire database (30 mins). That seems a little surprising. > In summary, I suspect that it is better from a UI perspective to > bring down the app on Sat at 3 a.m and reimport with a fixed time > period than to live through reindexing/vacuuming which may deadlock. > Am I missing something? Consider running pg_autovacuum, and thereby do a little bit of vacuuming here and there all the time. It DOESN'T block, so unless your system is really busy, it shouldn't slow things down to a major degree. -- "cbbrowne","@","libertyrms.info" Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Fri Oct 3 18:38:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AE9C5D1B500 for ; Fri, 3 Oct 2003 21:38:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50123-09 for ; Fri, 3 Oct 2003 18:37:40 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 48A8ED1B502 for ; Fri, 3 Oct 2003 18:37:38 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3719802; Fri, 03 Oct 2003 14:38:14 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Dror Matalon , pgsql-performance@postgresql.org Subject: Re: Speeding up Aggregates Date: Fri, 3 Oct 2003 14:35:46 -0700 User-Agent: KMail/1.4.3 References: <20031003202120.GO87525@rlx11.zapatec.com> <200310031407.10343.josh@agliodbs.com> <20031003212848.GP87525@rlx11.zapatec.com> In-Reply-To: <20031003212848.GP87525@rlx11.zapatec.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310031435.46838.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/109 X-Sequence-Number: 3857 Dror, > I am using 7.4, and had tried NOT EXISTS and didn't see any > improvements. It wouldn't if you're using 7.4, which has improved IN performance immensel= y. What happens if you stop using a function and instead use a subselect? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 18:45:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 16E7ED1B4FE for ; Fri, 3 Oct 2003 21:45:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53047-01 for ; Fri, 3 Oct 2003 18:44:42 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 864F7D1B503 for ; Fri, 3 Oct 2003 18:44:24 -0300 (ADT) Received: (qmail 29344 invoked from network); 3 Oct 2003 21:43:37 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.136.235) by 205.178.180.9 with SMTP; 3 Oct 2003 21:43:37 -0000 Subject: Re: Speeding up Aggregates From: Rod Taylor To: Dror Matalon Cc: Postgresql Performance In-Reply-To: <20031003202120.GO87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-FSO74Jbo4HfsFxOvk4Gn" Message-Id: <1065217488.91586.3.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 17:44:49 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/110 X-Sequence-Number: 3858 --=-FSO74Jbo4HfsFxOvk4Gn Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > item_max_date() looks like this: > select max(dtstamp) from items where channel =3D $1 and link =3D $2; It is too bad the (channel, link) index doesn't have dtstamp at the end of it, otherwise the below query would be a gain (might be a small one anyway). select dtstamp from items where channel =3D $1 and link =3D $2 ORDER BY dtstamp DESC LIMIT 1; Could you show us the exact specification of the function? In particular, did you mark it VOLATILE, IMMUTABLE, or STABLE? I hope it isn't the first or second one ;) --=-FSO74Jbo4HfsFxOvk4Gn Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/fe3Q6DETLow6vwwRAqeBAJ9r8F2NU9iBv4PMHWFH2HiYPV3q7wCfWes8 B/GSfsD/XGNFe+8lZhIRH4M= =XQSG -----END PGP SIGNATURE----- --=-FSO74Jbo4HfsFxOvk4Gn-- From pgsql-performance-owner@postgresql.org Fri Oct 3 18:47:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8E6C8D1B55C for ; Fri, 3 Oct 2003 21:47:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50417-08 for ; Fri, 3 Oct 2003 18:47:05 -0300 (ADT) Received: from jump.bivio.com (jump.bivio.com [216.87.82.232]) by svr1.postgresql.org (Postfix) with ESMTP id 68720D1B50D for ; Fri, 3 Oct 2003 18:46:59 -0300 (ADT) Received: (from nagler@localhost) by jump.bivio.com (8.11.6/8.11.6) id h93Ll1J21489; Fri, 3 Oct 2003 15:47:01 -0600 X-Authentication-Warning: jump.bivio.com: nagler set sender to nagler@bivio.biz using -f From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16253.61013.56254.526139@jump.bivio.com> Date: Fri, 3 Oct 2003 15:47:01 -0600 To: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? In-Reply-To: <954.1065214676@sss.pgh.pa.us> References: <16253.56074.737161.470428@jump.bivio.com> <954.1065214676@sss.pgh.pa.us> X-Mailer: VM 6.96 under Emacs 20.7.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/111 X-Sequence-Number: 3859 > vacuum full does require exclusive lock, plain vacuum does not. I think I need full, because there are updates on the table. As I understand it, an update in pg is an insert/delete, so it needs to be garbage collected. > It's considerably more likely that the vacuum was waiting for an open > client transaction (that had a read or write lock on some table) to > finish than that there was an undetected deadlock. I suggest looking at > your client code. Also, in 7.3 or later you could look at the pg_locks > view to work out exactly who has the lock that's blocking vacuum. My client code does a lot. I look at more often than I'd like to. :-) I don't understand why the client transaction would block if vacuum was waiting. Does vacuum lock the table and then try to get some other "open transaction" resource? Free space? I guess I don't understand what other resources would be required of vacuum. The client transactions are short (< 1s). They don't deadlock normally, only with reindex and vacuum did I see this behavior. > vacuum full is indeed slow. That's why we do not recommend it as a > routine maintenance procedure. The better approach is to do plain > vacuums often enough that you don't need vacuum full. The description of vacuum full implies that is required if the db is updated frequently. This db gets about 1 txn a second, possibly more at peak load. > In pre-7.4 > releases you might need periodic reindexes too, depending on whether > your usage patterns tickle the index-bloat problem. 7.3, and yes, we have date indexes as well as sequences for primary keys. > But it is easily > demonstrable that reindexing is cheaper than rebuilding the database. IOW, vacuum+reindex is faster than dump+restore? I didn't see this, then again, I had this locking problem, so the stats are distorted. One other question: The reindex seems to lock the table for the entire process as opposed to freeing the lock between index rebuilds. It was hard to see, but it seemed like the clients were locked for the entire "reindex table bla" command. Sorry for lack of detail, but I didn't expect these issues so I wasn't keeping track of the system state as closely as I should have. Next time. :-) Thanks, Rob From pgsql-performance-owner@postgresql.org Fri Oct 3 18:54:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3E856D1B508 for ; Fri, 3 Oct 2003 21:54:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50888-10 for ; Fri, 3 Oct 2003 18:53:48 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 967CED1B4FE for ; Fri, 3 Oct 2003 18:53:45 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 413EFACAC for ; Fri, 3 Oct 2003 21:53:48 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h93Lrl0i097438 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 14:53:47 -0700 (PDT) (envelope-from dror) Date: Fri, 3 Oct 2003 14:53:47 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031003215347.GQ87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1065217488.91586.3.camel@jester> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/113 X-Sequence-Number: 3861 On Fri, Oct 03, 2003 at 05:44:49PM -0400, Rod Taylor wrote: > > item_max_date() looks like this: > > select max(dtstamp) from items where channel = $1 and link = $2; > > It is too bad the (channel, link) index doesn't have dtstamp at the end > of it, otherwise the below query would be a gain (might be a small one > anyway). > > select dtstamp > from items > where channel = $1 > and link = $2 > ORDER BY dtstamp DESC > LIMIT 1; Similar idea to what Josh suggested. I did create an additional index with dtstamp at the end and it doesn't look like the planner used it. Using the above query instead of max() didn't improve things either. > > > Could you show us the exact specification of the function? In > particular, did you mark it VOLATILE, IMMUTABLE, or STABLE? > > I hope it isn't the first or second one ;) CREATE or REPLACE FUNCTION item_max_date (int4, varchar) RETURNS timestamptz AS ' select max(dtstamp) from items where channel = $1 and link = $2; ' LANGUAGE 'sql'; -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 19:20:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F2099D1B4F0 for ; Fri, 3 Oct 2003 22:20:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54057-05 for ; Fri, 3 Oct 2003 19:19:42 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 33F72D1B51A for ; Fri, 3 Oct 2003 19:19:40 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h93MJdQp054653 for ; Fri, 3 Oct 2003 22:19:40 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h93M4NEG052965 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 22:04:23 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: count(*) slow on large tables Date: Fri, 03 Oct 2003 17:55:25 -0400 Organization: cbbrowne Computing Inc Lines: 31 Message-ID: References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <3F7D9A57.B37A0DFC@nsd.ca> 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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:2KvR0uAbh1RBj2RGL/9Y0ZwIfBE= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/118 X-Sequence-Number: 3866 In the last exciting episode, jllachan@nsd.ca (Jean-Luc Lachance) wrote: > Well I can think of many more case where it would be usefull: > > SELECT COUNT(DISTINCT x) FROM ... > SELECT COUNT(*) FROM ... WHERE x = ? Those are precisely the cases that the "other databases" ALSO fall down on. Maintaining those sorts of statistics would lead [in _ANY_ database; PostgreSQL has no disadvantage in this] to needing for each and every update to update a whole host of statistic values. It would be fairly reasonable to have a trigger, in PostgreSQL, to manage this sort of information. It would not be outrageously difficult to substantially improve performance of queries, at the considerable cost that each and every update would have to update a statistics table. If you're doing a whole lot of these sorts of queries, then it is a reasonable idea to create appropriate triggers for the (probably very few) tables where you are doing these counts. But the notion that this should automatically be applied to all tables always is a dangerous one. It would make update performance Suck Badly, because the extra statistical updates would be quite expensive. -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','cbbrowne.com'). http://www3.sympatico.ca/cbbrowne/multiplexor.html I'm sorry Dave, I can't let you do that. Why don't you lie down and take a stress pill? From pgsql-performance-owner@postgresql.org Fri Oct 3 18:53:10 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AF8B4D1B4FE for ; Fri, 3 Oct 2003 21:53:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50995-09 for ; Fri, 3 Oct 2003 18:52:21 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id C90BDD1B4F0 for ; Fri, 3 Oct 2003 18:52:18 -0300 (ADT) Received: (qmail 24502 invoked by uid 500); 3 Oct 2003 21:59:39 -0000 Date: Fri, 3 Oct 2003 16:59:39 -0500 From: Bruno Wolff III To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031003215939.GA24446@wolff.to> Mail-Followup-To: Rob Nagler , pgsql-performance@postgresql.org References: <16253.56074.737161.470428@jump.bivio.com> <954.1065214676@sss.pgh.pa.us> <16253.61013.56254.526139@jump.bivio.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16253.61013.56254.526139@jump.bivio.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/112 X-Sequence-Number: 3860 On Fri, Oct 03, 2003 at 15:47:01 -0600, Rob Nagler wrote: > > vacuum full does require exclusive lock, plain vacuum does not. > > I think I need full, because there are updates on the table. As I > understand it, an update in pg is an insert/delete, so it needs > to be garbage collected. Plain vacuum will mark the space used by deleted tuples as reusable. Most of the time this is good enough and you don't need to run vacuum full. From pgsql-performance-owner@postgresql.org Fri Oct 3 19:04:47 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CCFCFD1B500 for ; Fri, 3 Oct 2003 22:04:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52926-04 for ; Fri, 3 Oct 2003 19:03:59 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id CD294D1B502 for ; Fri, 3 Oct 2003 19:03:56 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 0EB0D5FE7 for ; Fri, 3 Oct 2003 22:03:59 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h93M3wl7097475 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 15:03:58 -0700 (PDT) (envelope-from dror) Date: Fri, 3 Oct 2003 15:03:58 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Speeding up Aggregates Message-ID: <20031003220358.GR87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <200310031407.10343.josh@agliodbs.com> <20031003212848.GP87525@rlx11.zapatec.com> <200310031435.46838.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310031435.46838.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/114 X-Sequence-Number: 3862 On Fri, Oct 03, 2003 at 02:35:46PM -0700, Josh Berkus wrote: > Dror, > > > I am using 7.4, and had tried NOT EXISTS and didn't see any > > improvements. > > It wouldn't if you're using 7.4, which has improved IN performance immensely. > > What happens if you stop using a function and instead use a subselect? An improvement. Now I'm getting in the 200 msec response time. And by the way, I tried "not exists" again and it actually runs slower than "not in." > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(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 -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 19:10:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 22C87D1B506 for ; Fri, 3 Oct 2003 22:10:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55998-04 for ; Fri, 3 Oct 2003 19:09:47 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 2E115D1B514 for ; Fri, 3 Oct 2003 19:09:44 -0300 (ADT) Received: (qmail 24494 invoked from network); 3 Oct 2003 22:09:11 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.136.235) by 205.178.180.9 with SMTP; 3 Oct 2003 22:09:11 -0000 Subject: Re: Speeding up Aggregates From: Rod Taylor To: Dror Matalon Cc: Postgresql Performance In-Reply-To: <20031003215347.GQ87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-jkZdsfcTRaSOAH4mQj0+" Message-Id: <1065219028.91586.8.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 18:10:29 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/115 X-Sequence-Number: 3863 --=-jkZdsfcTRaSOAH4mQj0+ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-10-03 at 17:53, Dror Matalon wrote: > On Fri, Oct 03, 2003 at 05:44:49PM -0400, Rod Taylor wrote: > > > item_max_date() looks like this: > > > select max(dtstamp) from items where channel =3D $1 and link =3D $= 2; > >=20 > > It is too bad the (channel, link) index doesn't have dtstamp at the end > > of it, otherwise the below query would be a gain (might be a small one > > anyway). > >=20 > > select dtstamp > > from items > > where channel =3D $1 > > and link =3D $2 > > ORDER BY dtstamp DESC > > LIMIT 1; It didn't make a difference even with the 3 term index? I guess you don't have very many common values for channel / link combination. How about the below? Note the word STABLE on the end. CREATE or REPLACE FUNCTION item_max_date (int4, varchar) RETURNS timestamptz AS ' select max(dtstamp) from items where channel =3D $1 and link =3D $2; ' LANGUAGE 'sql' STABLE; --=-jkZdsfcTRaSOAH4mQj0+ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/ffPU6DETLow6vwwRAqqoAJ98/xpgZnGCWs9w5LVIvOWCWeqbOQCfSvp5 vGPd63zUg9xdu4dKuawyPb8= =LuwE -----END PGP SIGNATURE----- --=-jkZdsfcTRaSOAH4mQj0+-- From pgsql-performance-owner@postgresql.org Fri Oct 3 19:12:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A318DD1B50D for ; Fri, 3 Oct 2003 22:12:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53914-01 for ; Fri, 3 Oct 2003 19:11:49 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 688D6D1B506 for ; Fri, 3 Oct 2003 19:11:46 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id C532C1DF6; Fri, 3 Oct 2003 18:11:47 -0400 (EDT) Subject: Re: reindex/vacuum locking/performance? From: Neil Conway To: Rob Nagler Cc: PostgreSQL Performance In-Reply-To: <16253.61013.56254.526139@jump.bivio.com> References: <16253.56074.737161.470428@jump.bivio.com> <954.1065214676@sss.pgh.pa.us> <16253.61013.56254.526139@jump.bivio.com> Content-Type: text/plain Message-Id: <1065219105.3068.43.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 18:11:45 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/116 X-Sequence-Number: 3864 On Fri, 2003-10-03 at 17:47, Rob Nagler wrote: > They don't deadlock normally, > only with reindex and vacuum did I see this behavior. If you can provide a reproducible example of a deadlock induced by REINDEX + VACUUM, that would be interesting. (FWIW, I remember noticing a potential deadlock in the REINDEX code and posting to -hackers about it, but I've never seen it occur in a real-world situation...) > One other question: The reindex seems to lock the table for the entire > process as opposed to freeing the lock between index rebuilds. Yeah, I wouldn't be surprised if there is some room for optimizing the locks that are acquired by REINDEX. -Neil From pgsql-performance-owner@postgresql.org Fri Oct 3 19:17:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CA336D1B508 for ; Fri, 3 Oct 2003 22:17:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52458-08 for ; Fri, 3 Oct 2003 19:16:59 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 7BBB1D1B500 for ; Fri, 3 Oct 2003 19:16:56 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 3CD79ACAC for ; Fri, 3 Oct 2003 22:16:59 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h93MGwh2097525 for pgsql-performance@postgresql.org; Fri, 3 Oct 2003 15:16:58 -0700 (PDT) (envelope-from dror) Date: Fri, 3 Oct 2003 15:16:58 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031003221658.GS87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1065219028.91586.8.camel@jester> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/117 X-Sequence-Number: 3865 On Fri, Oct 03, 2003 at 06:10:29PM -0400, Rod Taylor wrote: > On Fri, 2003-10-03 at 17:53, Dror Matalon wrote: > > On Fri, Oct 03, 2003 at 05:44:49PM -0400, Rod Taylor wrote: > > > > item_max_date() looks like this: > > > > select max(dtstamp) from items where channel = $1 and link = $2; > > > > > > It is too bad the (channel, link) index doesn't have dtstamp at the end > > > of it, otherwise the below query would be a gain (might be a small one > > > anyway). > > > > > > select dtstamp > > > from items > > > where channel = $1 > > > and link = $2 > > > ORDER BY dtstamp DESC > > > LIMIT 1; > > It didn't make a difference even with the 3 term index? I guess you > don't have very many common values for channel / link combination. There's no noticeable difference between two term and three term indexes. > > > > How about the below? Note the word STABLE on the end. > > CREATE or REPLACE FUNCTION item_max_date (int4, varchar) RETURNS > timestamptz AS ' > select max(dtstamp) from items where channel = $1 and link = $2; > ' LANGUAGE 'sql' STABLE; Made no difference. -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 3 20:22:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CE1EAD1B554 for ; Fri, 3 Oct 2003 23:22:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71521-01 for ; Fri, 3 Oct 2003 20:21:36 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 849F4D1B4FB for ; Fri, 3 Oct 2003 20:21:32 -0300 (ADT) Received: (qmail 25824 invoked from network); 3 Oct 2003 23:21:35 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 3 Oct 2003 23:21:35 -0000 From: "Matt Clark" To: "Rob Nagler" , Subject: Re: reindex/vacuum locking/performance? Date: Sat, 4 Oct 2003 00:21:32 +0100 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <16253.61013.56254.526139@jump.bivio.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/120 X-Sequence-Number: 3868 > > vacuum full does require exclusive lock, plain vacuum does not. > > I think I need full, because there are updates on the table. As I > understand it, an update in pg is an insert/delete, so it needs > to be garbage collected. Yes and no. You only need a plain VACUUM that is run often enough to recover space as fast as you need to grab it. For heavily updated tables run it often - I run it every 5 minutes on some tables. A VACUUM FULL is only needed if you haven't been running VACUUM often enough in the first place. > The description of vacuum full implies that is required if the db > is updated frequently. This db gets about 1 txn a second, possibly > more at peak load. Assuming you mean 1 update/insert per second that is an absolutely _trivial_ load on any reasonable hardware. You can do thousands of updates/second on hardware costing less than $2000. If you vacuum every hour then you will be fine. > IOW, vacuum+reindex is faster than dump+restore? I didn't see this, > then again, I had this locking problem, so the stats are distorted. REINDEX also locks tables like VACUUM FULL. Either is terribly slow, but unless you turn off fsync during the restore it's unlikely to be slower than dump & restore. Matt From pgsql-performance-owner@postgresql.org Fri Oct 3 20:27:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DD2D0D1B584 for ; Fri, 3 Oct 2003 23:27:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64190-07 for ; Fri, 3 Oct 2003 20:26:46 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 301C9D1B56A for ; Fri, 3 Oct 2003 20:25:55 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3722108; Fri, 03 Oct 2003 16:26:32 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Matt Clark" , "Rob Nagler" , Subject: Re: reindex/vacuum locking/performance? Date: Fri, 3 Oct 2003 16:24:03 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310031624.03933.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/121 X-Sequence-Number: 3869 Rob, > > I think I need full, because there are updates on the table. As I > > understand it, an update in pg is an insert/delete, so it needs > > to be garbage collected. >=20 > Yes and no. You only need a plain VACUUM that is run often enough to > recover space as fast as you need to grab it. For heavily updated tables > run it often - I run it every 5 minutes on some tables. A VACUUM FULL is > only needed if you haven't been running VACUUM often enough in the first > place. Also, if you find that you need to run VACUUM FULL often, then you need to= =20 raise your max_fsm_pages. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 3 20:30:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 49954D1B55C for ; Fri, 3 Oct 2003 23:30:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72386-03 for ; Fri, 3 Oct 2003 20:29:59 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 7BE2DD1B533 for ; Fri, 3 Oct 2003 20:29:55 -0300 (ADT) Received: (qmail 27350 invoked from network); 3 Oct 2003 23:29:58 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 3 Oct 2003 23:29:58 -0000 From: "Matt Clark" To: "Christopher Browne" , Subject: Re: reindex/vacuum locking/performance? Date: Sat, 4 Oct 2003 00:29:55 +0100 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <60d6de9fah.fsf@dev6.int.libertyrms.info> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/122 X-Sequence-Number: 3870 > > In summary, I suspect that it is better from a UI perspective to > > bring down the app on Sat at 3 a.m and reimport with a fixed time > > period than to live through reindexing/vacuuming which may deadlock. > > Am I missing something? > > Consider running pg_autovacuum, and thereby do a little bit of > vacuuming here and there all the time. It DOESN'T block, so unless > your system is really busy, it shouldn't slow things down to a major > degree. My real world experience on a *very* heavily updated OLTP type DB, following advice from this list (thanks guys!), is that there is essentially zero cost to going ahead and vacuuming as often as you feel like it. Go crazy, and speed up your DB! OK, that's on a quad CPU box with goodish IO, so maybe there are issues on very slow boxen, but in a heavy-update environment the advantages seem to easily wipe out the costs. Matt p.s. Sorry to sound like a "Shake'n'Vac" advert. From pgsql-performance-owner@postgresql.org Fri Oct 3 20:32:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C674BD1B552 for ; Fri, 3 Oct 2003 23:32:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67628-10 for ; Fri, 3 Oct 2003 20:31:35 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 8D07ED1B52E for ; Fri, 3 Oct 2003 20:31:32 -0300 (ADT) Received: (qmail 6397 invoked from network); 3 Oct 2003 23:31:01 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.136.235) by 205.178.180.9 with SMTP; 3 Oct 2003 23:31:01 -0000 Subject: Re: Speeding up Aggregates From: Rod Taylor To: Dror Matalon Cc: Postgresql Performance In-Reply-To: <20031003215347.GQ87525@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-C8vA/RODvCZa9+vFsnJK" Message-Id: <1065219071.91586.11.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 19:32:16 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/123 X-Sequence-Number: 3871 --=-C8vA/RODvCZa9+vFsnJK Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > > I hope it isn't the first or second one ;) >=20 > CREATE or REPLACE FUNCTION item_max_date (int4, varchar) RETURNS > timestamptz AS ' > select max(dtstamp) from items where channel =3D $1 and link =3D $2; > ' LANGUAGE 'sql'; How about the below? CREATE or REPLACE FUNCTION item_max_date (int4, varchar) RETURNS timestamptz AS ' select max(dtstamp) from items where channel =3D $1 and link =3D $2; ' LANGUAGE 'sql' STABLE; --=-C8vA/RODvCZa9+vFsnJK Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/ffP/6DETLow6vwwRAkVWAJ0U2oP+O0Bvt/HwGSyuvqq7xOFRcgCfQbhu GpVTkMQb/IMIrXOG/2SqL/c= =1Pq1 -----END PGP SIGNATURE----- --=-C8vA/RODvCZa9+vFsnJK-- From pgsql-performance-owner@postgresql.org Fri Oct 3 20:45:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CA619D1B51A for ; Fri, 3 Oct 2003 23:45:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73233-05 for ; Fri, 3 Oct 2003 20:44:37 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id EDECED1B559 for ; Fri, 3 Oct 2003 20:44:32 -0300 (ADT) Received: (qmail 30635 invoked from network); 3 Oct 2003 23:44:36 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 3 Oct 2003 23:44:36 -0000 From: "Matt Clark" To: , "Rob Nagler" , Subject: Re: reindex/vacuum locking/performance? Date: Sat, 4 Oct 2003 00:44:33 +0100 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: <200310031624.03933.josh@agliodbs.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/124 X-Sequence-Number: 3872 > Also, if you find that you need to run VACUUM FULL often, then > you need to > raise your max_fsm_pages. Yes and no. If it's run often enough then the number of tracked pages shouldn't need to be raised, but then again... ...max_fsm_pages should be raised anyway. I'm about to reclaim a Pentium 166 w/ 64MB of RAM from a friend I lent it to _many_ years ago, and I suspect PG would run happily on it as configured by default. Set it to at least 50,000 I say. What do you have to lose, I mean if they're not free then they're not tracked in the FSM right? Of course if anyone knows a reason _not_ to raise it then I'm all ears! Matt > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(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 Fri Oct 3 20:48:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 63F11D1B51A for ; Fri, 3 Oct 2003 23:48:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73778-04 for ; Fri, 3 Oct 2003 20:48:10 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 86CEFD1B533 for ; Fri, 3 Oct 2003 20:48:07 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 225431DA9; Fri, 3 Oct 2003 19:48:10 -0400 (EDT) Subject: Re: reindex/vacuum locking/performance? From: Neil Conway To: Christopher Browne Cc: PostgreSQL Performance In-Reply-To: <60d6de9fah.fsf@dev6.int.libertyrms.info> References: <16253.56074.737161.470428@jump.bivio.com> <60d6de9fah.fsf@dev6.int.libertyrms.info> Content-Type: text/plain Message-Id: <1065224887.387.45.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 19:48:07 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/125 X-Sequence-Number: 3873 On Fri, 2003-10-03 at 17:34, Christopher Browne wrote: > Not surprising either. While the reindex takes place, updates to that > table have to be deferred. Right, but that's no reason not to let SELECTs proceed, for example. (Whether that would actually be *useful* is another question...) -Neil From pgsql-performance-owner@postgresql.org Fri Oct 3 21:15:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 99130D1B553 for ; Sat, 4 Oct 2003 00:15:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74562-04 for ; Fri, 3 Oct 2003 21:14:55 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 8A9ADD1B506 for ; Fri, 3 Oct 2003 21:14:50 -0300 (ADT) Received: (qmail 4444 invoked from network); 4 Oct 2003 00:14:53 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 4 Oct 2003 00:14:53 -0000 From: "Matt Clark" To: , "Rob Nagler" , Subject: Re: reindex/vacuum locking/performance? Date: Sat, 4 Oct 2003 01:14:50 +0100 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: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/126 X-Sequence-Number: 3874 > > Also, if you find that you need to run VACUUM FULL often, then > > you need to > > raise your max_fsm_pages. > > Yes and no. If it's run often enough then the number of tracked pages > shouldn't need to be raised, but then again... Oops, sorry, didn't pay attention and missed the mention of FULL. My bad, ignore my OT useless response. From pgsql-performance-owner@postgresql.org Fri Oct 3 22:40:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3B781D1B520 for ; Sat, 4 Oct 2003 01:40:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92689-03 for ; Fri, 3 Oct 2003 22:40:09 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id B7058D1B4FB for ; Fri, 3 Oct 2003 22:40:04 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h941deb01679; Fri, 3 Oct 2003 21:39:40 -0400 (EDT) From: Bruce Momjian Message-Id: <200310040139.h941deb01679@candle.pha.pa.us> Subject: Re: Tuning/performance issue... In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7614@postoffice.waterford.org> To: Oleg Lebedev Date: Fri, 3 Oct 2003 21:39:40 -0400 (EDT) Cc: Jeff , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/127 X-Sequence-Number: 3875 I have updated the FAQ to be: In comparison to MySQL or leaner database systems, we are faster for multiple users, complex queries, and a read/write query load. MySQL is faster for SELECT queries done by a few users. Is this accurate? It seems so. --------------------------------------------------------------------------- Oleg Lebedev wrote: > Jeff, > I would really appreciate if you could send me that lengthy presentation > that you've written on pg/other dbs comparison. > Thanks. > > Oleg > > -----Original Message----- > From: Jeff [mailto:threshar@torgo.978.org] > Sent: Wednesday, October 01, 2003 6:23 AM > To: David Griffiths > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Tuning/performance issue... > Importance: Low > > > On Tue, 30 Sep 2003, David Griffiths wrote: > > > > > This is all part of a "migrate away from Oracle" project. We are > > looking at 3 databases - MySQL (InnoDB), Postgres and Matisse (object > > oriented). We have alot of queries like this > > or worse, and I'm worried that many of them would need to be > re-written. The > > developers > > know SQL, but nothing about tuning, etc. > > > > There's a movement at my company to ditch several commercial db's in > favor of a free one. I'm currently the big pg fan around here and I've > actually written a rather lengthy presentation about pg features, why, > tuning, etc. but another part was some comparisons to other db's.. > > I decided so I wouldn't be blinding flaming mysql to give it a whirl and > loaded it up with the same dataset as pg. First thing I hit was lack of > stored procedures. But I decided to code around that, giving mysql the > benefit of the doubt. What I found was interesting. > > For 1-2 concurrent > 'beaters' it screamed. ultra-fast. But.. If you increase the concurrent > beaters up to say, 20 Mysql comes to a grinding halt.. Mysql and the > machine itself become fairly unresponsive. And if you do cache > unfriendly > queries it becomes even worse. On PG - no problems at all. Scaled fine > and dandy up. And with 40 concurrent beaters the machine was still > responsive. (The numbers for 20 client was 220 seconds (pg) and 650 > seconds (mysql)) > > So that is another test to try out - Given your configuration I expect > you have lots of concurrent activity. > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if > your > joining column's datatypes do not match > > ************************************* > > This e-mail may contain privileged or confidential material intended for the named recipient only. > If you are not the named recipient, delete this message and all attachments. > Unauthorized reviewing, copying, printing, disclosing, or otherwise using information in this e-mail is prohibited. > We reserve the right to monitor e-mail sent through our network. > > ************************************* > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend > -- 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 Fri Oct 3 23:22:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3D118D1B502 for ; Sat, 4 Oct 2003 02:22:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 91838-08 for ; Fri, 3 Oct 2003 23:21:23 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id B9ACFD1B513 for ; Fri, 3 Oct 2003 23:21:18 -0300 (ADT) Received: (qmail 8608 invoked from network); 4 Oct 2003 02:20:48 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.136.235) by 205.178.180.9 with SMTP; 4 Oct 2003 02:20:48 -0000 Subject: Re: Tuning/performance issue... From: Rod Taylor To: Bruce Momjian Cc: Oleg Lebedev , Jeff , "pgsql-performance@postgresql.org" In-Reply-To: <200310040139.h941deb01679@candle.pha.pa.us> References: <200310040139.h941deb01679@candle.pha.pa.us> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-d3rx9DbM+e0D9Fq+9K2h" Message-Id: <1065234119.23288.13.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 03 Oct 2003 22:22:00 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/128 X-Sequence-Number: 3876 --=-d3rx9DbM+e0D9Fq+9K2h Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-10-03 at 21:39, Bruce Momjian wrote: > I have updated the FAQ to be: >=20 > In comparison to MySQL or leaner database systems, we are > faster for multiple users, complex queries, and a read/write query > load. MySQL is faster for SELECT queries done by a few users.=20 >=20 > Is this accurate? It seems so. May wish to say ... for simple SELECT queries ... Several left outer joins, subselects and a large number of joins are regularly performed faster in PostgreSQL due to a more mature optimizer. But MySQL can pump out SELECT * FROM table WHERE key =3D value; queries in a hurry. I've often wondered if they win on those because they have a lighter weight parser / optimizer with less "lets try simplifying this query" steps or if the MYISAM storage mechanism is simply quicker at pulling data off the disk. --=-d3rx9DbM+e0D9Fq+9K2h Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/fi7G6DETLow6vwwRAiilAJ46Ak9nOBg8oDvnEhE6Cp0rfTn4yACeJS8X H5493nJ6QBSbxPuCvXGkXkA= =HOEy -----END PGP SIGNATURE----- --=-d3rx9DbM+e0D9Fq+9K2h-- From pgsql-performance-owner@postgresql.org Fri Oct 3 23:50:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F3752D1B513 for ; Sat, 4 Oct 2003 02:50:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02633-04 for ; Fri, 3 Oct 2003 23:49:44 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 108BBD1B54B for ; Fri, 3 Oct 2003 23:49:40 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h942ndQj002055 for ; Sat, 4 Oct 2003 02:49:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h942iGuD001447 for pgsql-performance@postgresql.org; Sat, 4 Oct 2003 02:44:16 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Tuning/performance issue... Date: Fri, 03 Oct 2003 22:37:53 -0400 Organization: cbbrowne Computing Inc Lines: 39 Message-ID: References: <993DBE5B4D02194382EC8DF8554A52731D7614@postoffice.waterford.org> <200310040139.h941deb01679@candle.pha.pa.us> 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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:hJ/ot4d4IoqLrnmrtdOfHCMe5AM= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/130 X-Sequence-Number: 3878 Centuries ago, Nostradamus foresaw when pgman@candle.pha.pa.us (Bruce Momjian) would write: > I have updated the FAQ to be: > > In comparison to MySQL or leaner database systems, we are > faster for multiple users, complex queries, and a read/write query > load. MySQL is faster for SELECT queries done by a few users. > > Is this accurate? It seems so. I would think it more accurate if you use the phrase "faster for simple SELECT queries." MySQL uses a rule-based optimizer which, when the data fits the rules well, can pump queries through lickety-split without any appreciable pause for evaluation (or reflection :-). That's _quite_ a successful strategy when users are doing what loosely amounts to evaluating association tables. select * from table where key = value; Which is just like tying a Perl variable to a hash table, and doing $value = $TABLE{$key}; In web applications where they wanted something a _little_ more structured than hash tables, that may 'hit the spot.' Anything hairier than that gets, of course, hairier. If you want something that's TRULY more structured, you may lose a lot of hair :-). -- output = reverse("gro.gultn" "@" "enworbbc") http://www.ntlug.org/~cbbrowne/oses.html "If you want to talk with some experts about something, go to the bar where they hang out, buy a round of beers, and they'll surely talk your ear off, leaving you wiser than before. If you, a stranger, show up at the bar, walk up to the table, and ask them to fax you a position paper, they'll tell you to call their office in the morning and ask for a rate sheet." -- Miguel Cruz From pgsql-performance-owner@postgresql.org Fri Oct 3 23:39:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6D68DD1B4FE for ; Sat, 4 Oct 2003 02:39:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96565-03 for ; Fri, 3 Oct 2003 23:38:21 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id F3EA3D1B4EF for ; Fri, 3 Oct 2003 23:38:15 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h942cHX12107; Fri, 3 Oct 2003 22:38:17 -0400 (EDT) From: Bruce Momjian Message-Id: <200310040238.h942cHX12107@candle.pha.pa.us> Subject: Re: Tuning/performance issue... In-Reply-To: <1065234119.23288.13.camel@jester> To: Rod Taylor Date: Fri, 3 Oct 2003 22:38:17 -0400 (EDT) Cc: Oleg Lebedev , Jeff , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/129 X-Sequence-Number: 3877 Rod Taylor wrote: -- Start of PGP signed section. > On Fri, 2003-10-03 at 21:39, Bruce Momjian wrote: > > I have updated the FAQ to be: > > > > In comparison to MySQL or leaner database systems, we are > > faster for multiple users, complex queries, and a read/write query > > load. MySQL is faster for SELECT queries done by a few users. > > > > Is this accurate? It seems so. > > May wish to say ... for simple SELECT queries ... Updated. > Several left outer joins, subselects and a large number of joins are > regularly performed faster in PostgreSQL due to a more mature optimizer. > > But MySQL can pump out SELECT * FROM table WHERE key = value; queries in > a hurry. > > > I've often wondered if they win on those because they have a lighter > weight parser / optimizer with less "lets try simplifying this query" I think that is part of it. > steps or if the MYISAM storage mechanism is simply quicker at pulling > data off the disk. And their heap is indexed by myisam, right. I know with Ingres that Isam was usually faster than btree because you didn't have all those leaves to traverse to get to the data. -- 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 Sat Oct 4 00:49:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A2384D1B531 for ; Sat, 4 Oct 2003 03:49:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04563-06 for ; Sat, 4 Oct 2003 00:49:04 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 34EEDD1B4E2 for ; Sat, 4 Oct 2003 00:49:04 -0300 (ADT) 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 h943n3hn003071; Fri, 3 Oct 2003 23:49:03 -0400 (EDT) To: Neil Conway Cc: Christopher Browne , PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? In-reply-to: <1065224887.387.45.camel@tokyo> References: <16253.56074.737161.470428@jump.bivio.com> <60d6de9fah.fsf@dev6.int.libertyrms.info> <1065224887.387.45.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Fri, 03 Oct 2003 19:48:07 -0400" Date: Fri, 03 Oct 2003 23:49:03 -0400 Message-ID: <3070.1065239343@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/131 X-Sequence-Number: 3879 Neil Conway writes: > On Fri, 2003-10-03 at 17:34, Christopher Browne wrote: >> Not surprising either. While the reindex takes place, updates to that >> table have to be deferred. > Right, but that's no reason not to let SELECTs proceed, for example. What if said SELECTs are using the index in question? I suspect it is true that REINDEX locks more than it needs to, but we should tread carefully about loosening it. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 00:59:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B800ED1B53F for ; Sat, 4 Oct 2003 03:59:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 16854-01 for ; Sat, 4 Oct 2003 00:58:17 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E4741D1B4E2 for ; Sat, 4 Oct 2003 00:58:16 -0300 (ADT) 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 h943wEhn003152; Fri, 3 Oct 2003 23:58:14 -0400 (EDT) To: Rod Taylor Cc: Bruce Momjian , Oleg Lebedev , Jeff , "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... In-reply-to: <1065234119.23288.13.camel@jester> References: <200310040139.h941deb01679@candle.pha.pa.us> <1065234119.23288.13.camel@jester> Comments: In-reply-to Rod Taylor message dated "Fri, 03 Oct 2003 22:22:00 -0400" Date: Fri, 03 Oct 2003 23:58:14 -0400 Message-ID: <3151.1065239894@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/132 X-Sequence-Number: 3880 Rod Taylor writes: > I've often wondered if they win on those because they have a lighter > weight parser / optimizer with less "lets try simplifying this query" > steps or if the MYISAM storage mechanism is simply quicker at pulling > data off the disk. Comparing pre-PREPAREd queries would probably tell something about that. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 06:01:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C8FD1D1B4E2; Sat, 4 Oct 2003 09:01:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66952-03; Sat, 4 Oct 2003 06:00:23 -0300 (ADT) 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 F25CED1B4FC; Sat, 4 Oct 2003 06:00:14 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h94908Cs003969; Sat, 4 Oct 2003 12:00:08 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h949046v003967; Sat, 4 Oct 2003 12:00:04 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: [HACKERS] Index/Function organized table layout (from Re: From: Hannu Krosing To: Christopher Browne Cc: pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" In-Reply-To: <60brszcng5.fsf@dev6.int.libertyrms.info> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1065258004.2746.30.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sat, 04 Oct 2003 12:00:04 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/133 X-Sequence-Number: 3881 Christopher Browne kirjutas R, 03.10.2003 kell 00:57: > jllachan@nsd.ca (Jean-Luc Lachance) writes: > > That's one of the draw back of MVCC. > > I once suggested that the transaction number and other house keeping > > info be included in the index, but was told to forget it... > > It would solve once and for all the issue of seq_scan vs index_scan. > > It would simplify the aggregate problem. > > It would only simplify _one_ case, namely the case where someone cares > about the cardinality of a relation, and it would do that at > _considerable_ cost. > > A while back I outlined how this would have to be done, and for it to > be done efficiently, it would be anything BUT simple. Could this be made a TODO item, perhaps with your attack plan. Of course as strictly optional feature useful only for special situations (see below) I cross-post this to [HACKERS] as it seem relevant to a problem recently discussed there. > It would be very hairy to implement it correctly, and all this would > cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" Not really. Just yesterday there was a discussion on [HACKERS] about implementing btree-organized tables, which would be much less needed if the visibility info were kept in indexes. > If you had a single WHERE clause attached, you would have to revert to > walking through the tuples looking for the ones that are live and > committed, which is true for any DBMS. If the WHERE clause could use the same index (or any index with visibility info) then there would be no need for "walking through the tuples" in data relation. the typical usecase cited on [HACKERS] was time series data, where inserts are roughly in (timestamp,id)order but queries in (id,timestamp) order. Now if the index would include all relevant fields (id,timestamp,data1,data2,...,dataN) then the query could run on index only touching just a few pages and thus vastly improving performance. I agree that this is not something everybody needs, but when it is needed it is needed bad. > And it still begs the same question, of why the result of this query > would be particularly meaningful to anyone. I don't see the > usefulness; I don't see the value of going to the considerable effort > of "fixing" this purported problem. Being able to do fast count(*) is just a side benefit. ---------------- Hannu From pgsql-performance-owner@postgresql.org Sat Oct 4 06:38:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E44EFD1B4FF for ; Sat, 4 Oct 2003 09:38:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74239-01 for ; Sat, 4 Oct 2003 06:37:37 -0300 (ADT) Received: from mail.iinet.net.au (mail-15.iinet.net.au [203.59.3.47]) by svr1.postgresql.org (Postfix) with SMTP id A2188D1B50D for ; Sat, 4 Oct 2003 06:37:33 -0300 (ADT) Received: (qmail 31838 invoked from network); 4 Oct 2003 09:37:34 -0000 Received: from unknown (HELO familyhealth.com.au) (203.59.199.78) by mail.iinet.net.au with SMTP; 4 Oct 2003 09:37:34 -0000 Message-ID: <3F7E94DC.9090709@familyhealth.com.au> Date: Sat, 04 Oct 2003 17:37:32 +0800 From: Christopher Kings-Lynne 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: Jeff Cc: Christopher Browne , "pgsql-performance@postgresql.org" Subject: Re: count(*) slow on large tables 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: 200310/134 X-Sequence-Number: 3882 > On our message boards each post is a row. The powers that be like to know > how many posts there are total (In addition to 'today')- > select count(*) from posts is how it has been > done on our informix db. With our port to PG I instead select reltuples > pg_class. We have exactly the same situation, except we just added a 'num_replies' field to each thread and a 'num_posts' field to each forum, so that getting that information out is a very fast operation. Because, of course, there are hundreds of times more reads of that information than writes... Chris From pgsql-performance-owner@postgresql.org Sat Oct 4 09:58:08 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 38711D1B565 for ; Sat, 4 Oct 2003 12:58:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 91473-08 for ; Sat, 4 Oct 2003 09:57:19 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id D1C65D1B557 for ; Sat, 4 Oct 2003 09:56:34 -0300 (ADT) Received: (qmail 42057 invoked from network); 4 Oct 2003 12:56:35 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 4 Oct 2003 12:56:35 -0000 Date: Sat, 4 Oct 2003 08:56:35 -0400 (EDT) From: Jeff To: Bruce Momjian Cc: Oleg Lebedev , "pgsql-performance@postgresql.org" Subject: Re: Tuning/performance issue... In-Reply-To: <200310040139.h941deb01679@candle.pha.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: 200310/135 X-Sequence-Number: 3883 On Fri, 3 Oct 2003, Bruce Momjian wrote: > > I have updated the FAQ to be: > > In comparison to MySQL or leaner database systems, we are > faster for multiple users, complex queries, and a read/write query > load. MySQL is faster for SELECT queries done by a few users. > > Is this accurate? It seems so. > > Another thing I noticed - If you use a dataset that can live in mysql's query cache / os cache it screams, until it has to hit the disk. then GRINDING HALT. It would be nice if someone (I don't have the time now) did a comparison of say: selct value where name = XXX; [where xxx varies] with 1,10,20,50 connections then make progressively more complex queries. And occasionally point out mysql silly omissions: select * from myview where id = 1234 [Oh wait! mysql doesn't have views. Ooopsy!] Wrapping up - PG is not that slow for simple queries either. It can be rather zippy - and PREPARE can give HUGE gains - even for simple statements. I've often wondered if YACC, etc is a bottleneck (You can only go as fast as your parser can go). Hurray for PG! And I'm giving my PG presentation monday. I hope to post it tuesday after I update with comments I receive and remove confidential information. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Sat Oct 4 12:19:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 189F7D1B589 for ; Sat, 4 Oct 2003 15:19:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17916-04 for ; Sat, 4 Oct 2003 12:18:55 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id CFBEBD1B520 for ; Sat, 4 Oct 2003 12:18:54 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A5oBK-0000q4-00 for ; Sat, 04 Oct 2003 11:18:54 -0400 Received: by dba2 (Postfix, from userid 1019) id 7E250C9FE; Sat, 4 Oct 2003 11:18:54 -0400 (EDT) Date: Sat, 4 Oct 2003 11:18:54 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031004151854.GK580@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <16253.56074.737161.470428@jump.bivio.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16253.56074.737161.470428@jump.bivio.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/136 X-Sequence-Number: 3884 On Fri, Oct 03, 2003 at 02:24:42PM -0600, Rob Nagler wrote: > I've read some posts that says vacuum doesn't lock, but my experience > today indicates the opposite. It seemed that "vacuum full analyze" VACUUM doesn't. VACUUM FULL does. -- ---- Andrew Sullivan 204-4141 Yonge Street Afilias Canada Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Sat Oct 4 12:23:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8B13DD1B553 for ; Sat, 4 Oct 2003 15:23:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 18401-05 for ; Sat, 4 Oct 2003 12:22:52 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 44757D1B520 for ; Sat, 4 Oct 2003 12:22:42 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A5oEz-0000vR-00 for ; Sat, 04 Oct 2003 11:22:41 -0400 Received: by dba2 (Postfix, from userid 1019) id CA7EDC9FE; Sat, 4 Oct 2003 11:22:41 -0400 (EDT) Date: Sat, 4 Oct 2003 11:22:41 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031004152241.GL580@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <60d6de9fah.fsf@dev6.int.libertyrms.info> 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: 200310/137 X-Sequence-Number: 3885 On Sat, Oct 04, 2003 at 12:29:55AM +0100, Matt Clark wrote: > My real world experience on a *very* heavily updated OLTP type DB, following > advice from this list (thanks guys!), is that there is essentially zero cost > to going ahead and vacuuming as often as you feel like it. Go crazy, and > speed up your DB! That's not quite true. If vacuums start running into each other, you can very easily start eating up all your I/O bandwidth. Even if you gots lots of it. Also, a vacuum pretty much destroys your shared buffers, so you have to be aware of that trade-off too. Vacuum is not free. It's _way_ cheaper than it used to be, though. 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 Sat Oct 4 12:24:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C6E4BD1B4EC for ; Sat, 4 Oct 2003 15:24:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17244-09 for ; Sat, 4 Oct 2003 12:23:39 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id ABDAED1B54B for ; Sat, 4 Oct 2003 12:23:38 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A5oFu-0000wM-00 for ; Sat, 04 Oct 2003 11:23:38 -0400 Received: by dba2 (Postfix, from userid 1019) id 78FCAC9FE; Sat, 4 Oct 2003 11:23:38 -0400 (EDT) Date: Sat, 4 Oct 2003 11:23:38 -0400 From: Andrew Sullivan To: PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031004152338.GM580@libertyrms.info> Mail-Followup-To: Andrew Sullivan , PostgreSQL Performance References: <16253.56074.737161.470428@jump.bivio.com> <60d6de9fah.fsf@dev6.int.libertyrms.info> <1065224887.387.45.camel@tokyo> <3070.1065239343@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3070.1065239343@sss.pgh.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/138 X-Sequence-Number: 3886 On Fri, Oct 03, 2003 at 11:49:03PM -0400, Tom Lane wrote: > > What if said SELECTs are using the index in question? That's a good reason to build a new index and, when it's done, drop the old one. It still prevents writes, of course. 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 Sat Oct 4 12:57:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 54FB0D1B520 for ; Sat, 4 Oct 2003 15:57:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17917-09 for ; Sat, 4 Oct 2003 12:56:43 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 97BE5D1B4EC for ; Sat, 4 Oct 2003 12:56:42 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h94Fuek24423; Sat, 4 Oct 2003 11:56:40 -0400 (EDT) From: Bruce Momjian Message-Id: <200310041556.h94Fuek24423@candle.pha.pa.us> Subject: Re: count(*) slow on large tables In-Reply-To: <60brszcng5.fsf@dev6.int.libertyrms.info> To: Christopher Browne Date: Sat, 4 Oct 2003 11:56:40 -0400 (EDT) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/139 X-Sequence-Number: 3887 Christopher Browne wrote: > jllachan@nsd.ca (Jean-Luc Lachance) writes: > > That's one of the draw back of MVCC. > > I once suggested that the transaction number and other house keeping > > info be included in the index, but was told to forget it... > > It would solve once and for all the issue of seq_scan vs index_scan. > > It would simplify the aggregate problem. > > It would only simplify _one_ case, namely the case where someone cares > about the cardinality of a relation, and it would do that at > _considerable_ cost. > > A while back I outlined how this would have to be done, and for it to > be done efficiently, it would be anything BUT simple. > > It would be very hairy to implement it correctly, and all this would > cover is the single case of "SELECT COUNT(*) FROM SOME_TABLE;" We do have a TODO item: * Consider using MVCC to cache count(*) queries with no WHERE clause The idea is to cache a recent count of the table, then have insert/delete add +/- records to the count. A COUNT(*) would get the main cached record plus any visible +/- records. This would allow the count to return the proper value depending on the visibility of the requesting transaction, and it would require _no_ heap or index scan. -- 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 Sat Oct 4 13:08:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 740E0D1B4EC for ; Sat, 4 Oct 2003 16:08:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25763-08 for ; Sat, 4 Oct 2003 13:07:55 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 5A888D1B54B for ; Sat, 4 Oct 2003 13:07:54 -0300 (ADT) 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 h94G7shn006103; Sat, 4 Oct 2003 12:07:54 -0400 (EDT) To: Hannu Krosing Cc: Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" Subject: COUNT(*) again (was Re: [HACKERS] Index/Function organized table layout) In-reply-to: <1065258004.2746.30.camel@fuji.krosing.net> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <1065258004.2746.30.camel@fuji.krosing.net> Comments: In-reply-to Hannu Krosing message dated "Sat, 04 Oct 2003 12:00:04 +0300" Date: Sat, 04 Oct 2003 12:07:53 -0400 Message-ID: <6102.1065283673@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/140 X-Sequence-Number: 3888 Hannu Krosing writes: > Christopher Browne kirjutas R, 03.10.2003 kell 00:57: >> A while back I outlined how this would have to be done, and for it to >> be done efficiently, it would be anything BUT simple. > Could this be made a TODO item, perhaps with your attack plan. If I recall that discussion correctly, no one including Christopher thought the attack plan was actually reasonable. What this keeps coming down to is that an optimization that helps only COUNT(*)-of-one-table-with-no-WHERE-clause would be too expensive in development and maintenance effort to justify its existence. At least if you insist on an exact, MVCC-correct answer. So far as I've seen, the actual use cases for unqualified COUNT(*) could be handled equally well by an approximate answer. What we should be doing rather than wasting large amounts of time trying to devise exact solutions is telling people to look at pg_class.reltuples for approximate answers. We could also be looking at beefing up support for that approach --- maybe provide some syntactic sugar for the lookup, maybe see if we can update reltuples in more places than we do now, make sure that the autovacuum daemon includes "keep reltuples accurate" as one of its design goals, etc etc. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 13:50:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C34E0D1B531 for ; Sat, 4 Oct 2003 16:50:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37654-01 for ; Sat, 4 Oct 2003 13:49:38 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id ADF5FD1B50E for ; Sat, 4 Oct 2003 13:49:37 -0300 (ADT) 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 h94GnXhn006744; Sat, 4 Oct 2003 12:49:33 -0400 (EDT) To: Bruce Momjian Cc: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables In-reply-to: <200310041556.h94Fuek24423@candle.pha.pa.us> References: <200310041556.h94Fuek24423@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 04 Oct 2003 11:56:40 -0400" Date: Sat, 04 Oct 2003 12:49:33 -0400 Message-ID: <6743.1065286173@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/141 X-Sequence-Number: 3889 Bruce Momjian writes: > We do have a TODO item: > * Consider using MVCC to cache count(*) queries with no WHERE clause > The idea is to cache a recent count of the table, then have > insert/delete add +/- records to the count. A COUNT(*) would get the > main cached record plus any visible +/- records. This would allow the > count to return the proper value depending on the visibility of the > requesting transaction, and it would require _no_ heap or index scan. ... and it would give the wrong answers. Unless the cache is somehow snapshot-aware, so that it can know which other transactions should be included in your count. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 14:49:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1AC3BD1B51E for ; Sat, 4 Oct 2003 17:49:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 46762-01 for ; Sat, 4 Oct 2003 14:48:53 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 64391D1B54C for ; Sat, 4 Oct 2003 14:48:51 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h94Hmlc04602; Sat, 4 Oct 2003 13:48:47 -0400 (EDT) From: Bruce Momjian Message-Id: <200310041748.h94Hmlc04602@candle.pha.pa.us> Subject: Re: count(*) slow on large tables In-Reply-To: <6743.1065286173@sss.pgh.pa.us> To: Tom Lane Date: Sat, 4 Oct 2003 13:48:47 -0400 (EDT) Cc: Christopher Browne , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/142 X-Sequence-Number: 3890 Tom Lane wrote: > Bruce Momjian writes: > > We do have a TODO item: > > * Consider using MVCC to cache count(*) queries with no WHERE clause > > > The idea is to cache a recent count of the table, then have > > insert/delete add +/- records to the count. A COUNT(*) would get the > > main cached record plus any visible +/- records. This would allow the > > count to return the proper value depending on the visibility of the > > requesting transaction, and it would require _no_ heap or index scan. > > ... and it would give the wrong answers. Unless the cache is somehow > snapshot-aware, so that it can know which other transactions should be > included in your count. The cache is an ordinary table, with xid's on every row. I meant it would require no index/heap scans of the large table --- it would still require a scan of the "count" table. -- 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 Sat Oct 4 14:52:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 02660D1B567 for ; Sat, 4 Oct 2003 17:52:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 45461-06 for ; Sat, 4 Oct 2003 14:51:43 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id ECE16D1B523 for ; Sat, 4 Oct 2003 14:51:41 -0300 (ADT) 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 h94Hpchn019445; Sat, 4 Oct 2003 13:51:39 -0400 (EDT) To: Bruce Momjian Cc: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables In-reply-to: <200310041748.h94Hmlc04602@candle.pha.pa.us> References: <200310041748.h94Hmlc04602@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 04 Oct 2003 13:48:47 -0400" Date: Sat, 04 Oct 2003 13:51:38 -0400 Message-ID: <19444.1065289898@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/143 X-Sequence-Number: 3891 Bruce Momjian writes: > Tom Lane wrote: >> ... and it would give the wrong answers. Unless the cache is somehow >> snapshot-aware, so that it can know which other transactions should be >> included in your count. > The cache is an ordinary table, with xid's on every row. I meant it > would require no index/heap scans of the large table --- it would still > require a scan of the "count" table. Oh, that idea. Yeah, I think we had concluded it might work. You'd better make the TODO item link to that discussion, because there's sure been plenty of discussion of ideas that wouldn't work. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 15:20:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0BA15D1B50D for ; Sat, 4 Oct 2003 18:20:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 47036-08 for ; Sat, 4 Oct 2003 15:19:51 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 09BA6D1B56A for ; Sat, 4 Oct 2003 15:19:49 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h94IJkV07596; Sat, 4 Oct 2003 14:19:46 -0400 (EDT) From: Bruce Momjian Message-Id: <200310041819.h94IJkV07596@candle.pha.pa.us> Subject: Re: count(*) slow on large tables In-Reply-To: <19444.1065289898@sss.pgh.pa.us> To: Tom Lane Date: Sat, 4 Oct 2003 14:19:46 -0400 (EDT) Cc: Christopher Browne , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/144 X-Sequence-Number: 3892 Tom Lane wrote: > Bruce Momjian writes: > > Tom Lane wrote: > >> ... and it would give the wrong answers. Unless the cache is somehow > >> snapshot-aware, so that it can know which other transactions should be > >> included in your count. > > > The cache is an ordinary table, with xid's on every row. I meant it > > would require no index/heap scans of the large table --- it would still > > require a scan of the "count" table. > > Oh, that idea. Yeah, I think we had concluded it might work. You'd > better make the TODO item link to that discussion, because there's sure > been plenty of discussion of ideas that wouldn't work. OK, I beefed up the TODO: * Use a fixed row count and a +/- count with MVCC visibility rules to allow fast COUNT(*) queries with no WHERE clause(?) I can always give the details if someone asks. It doesn't seem complex enough for a separate TODO.detail item. -- 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 Sat Oct 4 15:35:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2B5C4D1B55F for ; Sat, 4 Oct 2003 18:35:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54472-07 for ; Sat, 4 Oct 2003 15:34:36 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 284FDD1B4F1 for ; Sat, 4 Oct 2003 15:34:35 -0300 (ADT) 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 h94IYWhn020793; Sat, 4 Oct 2003 14:34:32 -0400 (EDT) To: Bruce Momjian Cc: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables In-reply-to: <200310041819.h94IJkV07596@candle.pha.pa.us> References: <200310041819.h94IJkV07596@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 04 Oct 2003 14:19:46 -0400" Date: Sat, 04 Oct 2003 14:34:32 -0400 Message-ID: <20792.1065292472@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/145 X-Sequence-Number: 3893 Bruce Momjian writes: > It doesn't seem complex enough for a separate TODO.detail item. I thought it was, if only because it is so easy to think of wrong implementations. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 18:01:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 46ADFD1B4E3; Sat, 4 Oct 2003 21:01:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85650-06; Sat, 4 Oct 2003 18:00:18 -0300 (ADT) 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 E0290D1B573; Sat, 4 Oct 2003 17:59:11 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h94Kx7Cs004926; Sat, 4 Oct 2003 23:59:13 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h94Kx03Q004924; Sat, 4 Oct 2003 23:59:00 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: COUNT(*) again (was Re: [HACKERS] Index/Function From: Hannu Krosing To: Tom Lane Cc: Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" In-Reply-To: <6102.1065283673@sss.pgh.pa.us> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <1065258004.2746.30.camel@fuji.krosing.net> <6102.1065283673@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1065301140.2746.37.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sat, 04 Oct 2003 23:59:00 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/146 X-Sequence-Number: 3894 Tom Lane kirjutas L, 04.10.2003 kell 19:07: > Hannu Krosing writes: > > Christopher Browne kirjutas R, 03.10.2003 kell 00:57: > >> A while back I outlined how this would have to be done, and for it to > >> be done efficiently, it would be anything BUT simple. > > > Could this be made a TODO item, perhaps with your attack plan. > > If I recall that discussion correctly, no one including Christopher > thought the attack plan was actually reasonable. > > What this keeps coming down to is that an optimization that helps only > COUNT(*)-of-one-table-with-no-WHERE-clause would be too expensive in > development and maintenance effort to justify its existence. Please read further in my email ;) The point I was trying to make was that faster count(*)'s is just a side effect. If we could (conditionally) keep visibility info in indexes, then this would also solve the problem fo much more tricky question of index-structured tables. Count(*) is *not* the only query that could benefit from not needing to go to actual data table for visibilty info, The much more needed case would be the "inveres time series" type of queries, which would otherways trash cache pages badly. ---------------------------- Hannu From pgsql-performance-owner@postgresql.org Sat Oct 4 18:18:08 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C3D09D1B548 for ; Sat, 4 Oct 2003 21:18:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85637-10 for ; Sat, 4 Oct 2003 18:17:16 -0300 (ADT) Received: from jamesr.best.vwh.net (jamesr.best.vwh.net [192.220.76.165]) by svr1.postgresql.org (Postfix) with SMTP id 333EAD1B4E3 for ; Sat, 4 Oct 2003 18:17:14 -0300 (ADT) Received: (qmail 473 invoked by uid 19621); 4 Oct 2003 21:17:10 -0000 Received: from unknown (HELO ?192.168.123.100?) ([67.116.53.203]) (envelope-sender ) by 192.220.76.165 (qmail-ldap-1.03) with SMTP for ; 4 Oct 2003 21:17:10 -0000 User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Sat, 04 Oct 2003 14:15:12 -0700 Subject: Uses for Index/Function organizing From: James Rogers To: Hannu Krosing Cc: , "pgsql-hackers@postgresql.org" Message-ID: In-Reply-To: <1065258004.2746.30.camel@fuji.krosing.net> 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: 200310/148 X-Sequence-Number: 3896 On 10/4/03 2:00 AM, "Hannu Krosing" wrote: > > If the WHERE clause could use the same index (or any index with > visibility info) then there would be no need for "walking through the > tuples" in data relation. > > the typical usecase cited on [HACKERS] was time series data, where > inserts are roughly in (timestamp,id)order but queries in (id,timestamp) > order. Now if the index would include all relevant fields > (id,timestamp,data1,data2,...,dataN) then the query could run on index > only touching just a few pages and thus vastly improving performance. I > agree that this is not something everybody needs, but when it is needed > it is needed bad. I would add that automatically index-organizing tuples isn't just useful for time-series data (though it is a good example), but can be used to substantially improve the query performance of any really large table in a number of different and not always direct ways. Once working sets routinely exceed the size of physical RAM, buffer access/utilization efficiency often becomes the center of performance tuning, but not one that many people know much about. One of the less direct ways of using btree-organized tables for improving scalability is to "materialize" table indexes of tables that *shouldn't* be btree-organized. Not only can you turn tables into indexes, but you can also turn indexes into tables, which can have advantages in some cases. For example, I did some scalability consulting at a well-known movie rental company with some very large Oracle databases running on big Sun boxen. One of the biggest problems was that their rental history table, which had a detailed record of every movie ever rented by every customer, had grown so large that the performance was getting painfully slow. To make matters worse, it and a few related tables had high concurrent usage, a mixture of many performance-sensitive queries grabbing windows of a customer's history plus a few broader OLAP queries which were not time sensitive. Everything was technically optimized in a relational and basic configuration sense, and the database guys at the company were at a loss on how to fix this problem. Performance of all queries was essentially bound by how fast pages could be moved between the disk and buffers. Issue #1: The history rows had quite a lot of columns and the OLAP processes used non-primary indexes, so the table was not particularly suitable for btree-organizing. Issue #2: Partitioning was not an option because it would have exceeded certain limits in Oracle (at that time, I don't know if that has changed). Issue #3: Although customer histories were being constantly queried, data needed most was really an index view of the customers history, not the details of the history itself. The solution I came up with was to use a synced btree-organized partial clone of the main history table that only contained a small number of key columns that mattered for generating customer history indexes in the applications that used them. While this substantially increased the disk space footprint for the same data (since we were cloning it), it greatly reduced the total number of cache misses for the typical query, only fetching the full history row pages when actually needed. In other words, basically concentrating more buffer traffic into a smaller number of page buffers. What we had was an exceedingly active but relatively compact materialized index of the history table that could essentially stay resident in RAM, and a much less active history table+indexes that while less likely to be buffered than before, had pages accessed at such a reduced frequency that there was a huge net performance gain because disk access plummeted. Average performance improvement for the time sensitive queries: 50-70x So btree-organized tables can do more than make tables behave like indexes. They can also make indexes behave like tables. Both are very useful in some cases when your working set exceeds the physical buffer space. For smaller databases this has much less utility and users need to understand the limitations, nonetheless when tables and databases get really big it becomes an important tool in the tool belt. Cheers, -James Rogers jamesr@best.com From pgsql-performance-owner@postgresql.org Sat Oct 4 18:16:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F21B1D1B520 for ; Sat, 4 Oct 2003 21:16:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85703-10 for ; Sat, 4 Oct 2003 18:15:40 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id A2E98D1B53F for ; Sat, 4 Oct 2003 18:15:37 -0300 (ADT) 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 h94LFOhn022014; Sat, 4 Oct 2003 17:15:24 -0400 (EDT) To: Hannu Krosing Cc: Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" Subject: Re: COUNT(*) again (was Re: [HACKERS] Index/Function organized table layout) In-reply-to: <1065301140.2746.37.camel@fuji.krosing.net> References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <1065258004.2746.30.camel@fuji.krosing.net> <6102.1065283673@sss.pgh.pa.us> <1065301140.2746.37.camel@fuji.krosing.net> Comments: In-reply-to Hannu Krosing message dated "Sat, 04 Oct 2003 23:59:00 +0300" Date: Sat, 04 Oct 2003 17:15:24 -0400 Message-ID: <22013.1065302124@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/147 X-Sequence-Number: 3895 Hannu Krosing writes: > The point I was trying to make was that faster count(*)'s is just a side > effect. If we could (conditionally) keep visibility info in indexes, I think that's not happening, conditionally or otherwise. The atomicity problems alone are sufficient reason why not, even before you look at the performance issues. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Oct 4 20:50:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 70DDDD1B4EC for ; Sat, 4 Oct 2003 23:50:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14368-03 for ; Sat, 4 Oct 2003 20:49:56 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 2FBF7D1B4F0 for ; Sat, 4 Oct 2003 20:49:53 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h94NnqQh076664 for ; Sat, 4 Oct 2003 23:49:52 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h94NaQEP075478 for pgsql-performance@postgresql.org; Sat, 4 Oct 2003 23:36:26 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: count(*) slow on large tables Date: Sat, 04 Oct 2003 19:33:46 -0400 Organization: cbbrowne Computing Inc Lines: 77 Message-ID: References: <200310041556.h94Fuek24423@candle.pha.pa.us> <6743.1065286173@sss.pgh.pa.us> 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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:lLXE17xNVoXrMYZPn8CzzK9g1mc= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/149 X-Sequence-Number: 3897 Quoth tgl@sss.pgh.pa.us (Tom Lane): > Bruce Momjian writes: >> We do have a TODO item: >> * Consider using MVCC to cache count(*) queries with no WHERE clause > >> The idea is to cache a recent count of the table, then have >> insert/delete add +/- records to the count. A COUNT(*) would get the >> main cached record plus any visible +/- records. This would allow the >> count to return the proper value depending on the visibility of the >> requesting transaction, and it would require _no_ heap or index scan. > > ... and it would give the wrong answers. Unless the cache is somehow > snapshot-aware, so that it can know which other transactions should be > included in your count. [That's an excellent summary that Bruce did of what came out of the previous discussion...] If this "cache" was a table, itself, the visibility of its records should be identical to that of the visibility of the "real" records. +/- records would become visible when the transaction COMMITed, at the very same time the source records became visible. I thought, at one point, that it would be a slick idea for "record compression" to take place automatically; when you do a COUNT(*), the process would include compressing multiple records down to one. Unfortunately, that turns out to be Tremendously Evil if the same COUNT(*) were being concurrently processed in multiple transactions. Both would repeat much the same work, and this would ultimately lead to one of the transactions aborting. [I recently saw this effect occur, um, a few times...] For this not to have Evil Effects on unsuspecting transactions, we would instead require some process analagous to VACUUM, where a single transaction would be used to compress the "counts table" down to one record per table. Being independent of "user transactions," it could safely compress the data without injuring unsuspecting transactions. But in most cases, the cost of this would be pretty prohibitive. Every transaction that adds a record to a table leads to a record being added to table "pg_exact_row_counts". If transactions typically involve adding ONE row to any given table, this effectively doubles the update traffic. Ouch. That means that in a _real_ implementation, it would make sense to pick and choose the tables that would be so managed. In my earlier arguing of "You don't really want that!", while I may have been guilty of engaging in a _little_ hyperbole, I was certainly _not_ being facetious overall. At work, we tell the developers "avoid doing COUNT(*) inside ordinary transactions!", and that is certainly NOT facetious comment. I recall a case a while back where system performance was getting brutalized by a lurking COUNT(*). (Combined with some other pathological behaviour, of course!) And note that this wasn't a query that the TODO item could address; it was of the form "SELECT COUNT(*) FROM SOME_TABLE WHERE OWNER = VALUE;" As you have commented elsewhere in the thread, much of the time, the point of asking for COUNT(*) is often to get some idea of table size, where the precise number isn't terribly important in comparison with getting general magnitude. Improving the ability to get approximate values would be of some value. I would further argue that "SELECT COUNT(*) FROM TABLE" isn't particularly useful even when precision _is_ important. If I'm working on reports that would be used to reconcile things, the queries I use are a whole lot more involved than that simple form. It is far more likely that I'm using a GROUP BY. It is legitimate to get wishful and imagine that it would be nice if we could get the value of that query "instantaneously." It is also legitimate to think that the effort required to implement that might be better used on improving other things. -- (reverse (concatenate 'string "ac.notelrac.teneerf" "@" "454aa")) http://www3.sympatico.ca/cbbrowne/ "very few people approach me in real life and insist on proving they are drooling idiots." -- Erik Naggum, comp.lang.lisp From pgsql-performance-owner@postgresql.org Sun Oct 5 01:21:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 15ACFD1B4E5; Sun, 5 Oct 2003 04:21:28 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62781-05; Sun, 5 Oct 2003 01:20:41 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3D7F9D1B4EC; Sun, 5 Oct 2003 01:20:40 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h954KWT12351; Sun, 5 Oct 2003 00:20:32 -0400 (EDT) From: Bruce Momjian Message-Id: <200310050420.h954KWT12351@candle.pha.pa.us> Subject: Re: COUNT(*) again (was Re: [HACKERS] Index/Function organized In-Reply-To: <22013.1065302124@sss.pgh.pa.us> To: Tom Lane Date: Sun, 5 Oct 2003 00:20:32 -0400 (EDT) Cc: Hannu Krosing , Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/150 X-Sequence-Number: 3898 Tom Lane wrote: > Hannu Krosing writes: > > The point I was trying to make was that faster count(*)'s is just a side > > effect. If we could (conditionally) keep visibility info in indexes, > > I think that's not happening, conditionally or otherwise. The atomicity > problems alone are sufficient reason why not, even before you look at > the performance issues. What are the atomicity problems of adding a create/expire xid to the index tuples? -- 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 Sun Oct 5 03:09:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 416E7D1B4F0 for ; Sun, 5 Oct 2003 06:09:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72563-04 for ; Sun, 5 Oct 2003 03:08:37 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 2E085D1B4E5 for ; Sun, 5 Oct 2003 03:08:36 -0300 (ADT) 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 h9568Vhn028314; Sun, 5 Oct 2003 02:08:31 -0400 (EDT) To: Bruce Momjian Cc: Hannu Krosing , Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" Subject: Re: COUNT(*) again (was Re: [HACKERS] Index/Function organized table layout) In-reply-to: <200310050420.h954KWT12351@candle.pha.pa.us> References: <200310050420.h954KWT12351@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Sun, 05 Oct 2003 00:20:32 -0400" Date: Sun, 05 Oct 2003 02:08:31 -0400 Message-ID: <28313.1065334111@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/151 X-Sequence-Number: 3899 Bruce Momjian writes: > Tom Lane wrote: >> I think that's not happening, conditionally or otherwise. The atomicity >> problems alone are sufficient reason why not, even before you look at >> the performance issues. > What are the atomicity problems of adding a create/expire xid to the > index tuples? You can't update a tuple's status in just one place ... you have to update the copies in the indexes too. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 5 08:15:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6ED73D1B4ED for ; Sun, 5 Oct 2003 11:15:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 99929-10 for ; Sun, 5 Oct 2003 08:14:41 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 72566D1B540 for ; Sun, 5 Oct 2003 08:14:37 -0300 (ADT) Received: (qmail 26069 invoked from network); 5 Oct 2003 11:14:24 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 5 Oct 2003 11:14:24 -0000 From: "Matt Clark" To: "Andrew Sullivan" , Subject: Re: reindex/vacuum locking/performance? Date: Sun, 5 Oct 2003 12:14:24 +0100 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <20031004152241.GL580@libertyrms.info> Importance: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/152 X-Sequence-Number: 3900 > On Sat, Oct 04, 2003 at 12:29:55AM +0100, Matt Clark wrote: > > My real world experience on a *very* heavily updated OLTP type > DB, following > > advice from this list (thanks guys!), is that there is > essentially zero cost > > to going ahead and vacuuming as often as you feel like it. Go > crazy, and > > speed up your DB! > > That's not quite true. If vacuums start running into each other, you > can very easily start eating up all your I/O bandwidth. Even if you > gots lots of it. Very true, which is why all my scripts write a lockfile and delete it when they're finished, to prevent that happening. I should have mentioned that. > Also, a vacuum pretty much destroys your shared buffers, so you have > to be aware of that trade-off too. Vacuum is not free. It's _way_ > cheaper than it used to be, though. That's _very_ interesting. I've never been quite clear what's in shared buffers apart from scratch space for currently running transactions. Also the docs imply that vacuum uses it's own space for working in. Do you have more info on how it clobbers shared_buffers? M From pgsql-performance-owner@postgresql.org Sun Oct 5 10:37:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3AC84D1B50F; Sun, 5 Oct 2003 13:37:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33064-07; Sun, 5 Oct 2003 10:36:48 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id C7010D1B53C; Sun, 5 Oct 2003 10:36:43 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h95Daee20397; Sun, 5 Oct 2003 09:36:40 -0400 (EDT) From: Bruce Momjian Message-Id: <200310051336.h95Daee20397@candle.pha.pa.us> Subject: Re: COUNT(*) again (was Re: [HACKERS] Index/Function organized In-Reply-To: <28313.1065334111@sss.pgh.pa.us> To: Tom Lane Date: Sun, 5 Oct 2003 09:36:40 -0400 (EDT) Cc: Hannu Krosing , Christopher Browne , pgsql-performance@postgresql.org, "pgsql-hackers@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/153 X-Sequence-Number: 3901 Tom Lane wrote: > Bruce Momjian writes: > > Tom Lane wrote: > >> I think that's not happening, conditionally or otherwise. The atomicity > >> problems alone are sufficient reason why not, even before you look at > >> the performance issues. > > > What are the atomicity problems of adding a create/expire xid to the > > index tuples? > > You can't update a tuple's status in just one place ... you have to > update the copies in the indexes too. But we don't update the tuple status for a commit, we just mark the xid as committed. We do have lazy status bits that prevent later lookups in pg_clog, but we have those in the index already also. What am I missing? -- 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 Sun Oct 5 11:35:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A6540D1B540 for ; Sun, 5 Oct 2003 14:35:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 49102-03 for ; Sun, 5 Oct 2003 11:34:34 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id BC422D1B548 for ; Sun, 5 Oct 2003 11:34:29 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A69xw-0006A3-00 for ; Sun, 05 Oct 2003 10:34:32 -0400 Received: by dba2 (Postfix, from userid 1019) id 09E7CC9FE; Sun, 5 Oct 2003 10:34:32 -0400 (EDT) Date: Sun, 5 Oct 2003 10:34:31 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031005143431.GC3441@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20031004152241.GL580@libertyrms.info> 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: 200310/154 X-Sequence-Number: 3902 On Sun, Oct 05, 2003 at 12:14:24PM +0100, Matt Clark wrote: > more info on how it clobbers shared_buffers? Vacuum is like a seqscan. It touches everything on a table. So it doesn't clobber them, but that's the latest data. It's unlikely your buffers are big enough to hold your database, unless your database is small. So you'll end up expiring potentially useful data in the buffer. 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 Sun Oct 5 13:47:12 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 979DDD1B4ED for ; Sun, 5 Oct 2003 16:47:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 69575-01 for ; Sun, 5 Oct 2003 13:46:24 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 74BA2D1B4FC for ; Sun, 5 Oct 2003 13:46:22 -0300 (ADT) Received: (qmail 30480 invoked from network); 5 Oct 2003 16:46:22 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 5 Oct 2003 16:46:22 -0000 From: "Matt Clark" To: "Andrew Sullivan" , Subject: Re: reindex/vacuum locking/performance? Date: Sun, 5 Oct 2003 17:46:21 +0100 Message-ID: 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 IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <20031005143431.GC3441@libertyrms.info> Importance: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/155 X-Sequence-Number: 3903 > On Sun, Oct 05, 2003 at 12:14:24PM +0100, Matt Clark wrote: > > more info on how it clobbers shared_buffers? > > Vacuum is like a seqscan. It touches everything on a table. So it > doesn't clobber them, but that's the latest data. It's unlikely your > buffers are big enough to hold your database, unless your database is > small. So you'll end up expiring potentially useful data in the > buffer. OK I'm definitely missing something here. I thought that the FSM was there to keep track of potentially free pages, and that all VACUUM did was double check and then write that info out for all to see? The promise being that a VACUUM FULL will walk all pages on disk and do a soft-shoe-shuffle to aggresively recover space, but a simple VACUUM won't (merely confirming pages as available for reuse). As for buffers, my understanding is that they are *not* meant to be big enough to hold the DB, as PG explicitly leaves caching up to the underlying OS. 'buffers' here meaning shared memory between PG processes, and 'cache' meaning OS cache. 'buffers' only need to be big enough to hold the intermediate calcs and the results for any current transactions? M From pgsql-performance-owner@postgresql.org Sun Oct 5 14:11:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0A13AD1B500 for ; Sun, 5 Oct 2003 17:11:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62298-09 for ; Sun, 5 Oct 2003 14:11:12 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E43D7D1B4ED for ; Sun, 5 Oct 2003 14:11:10 -0300 (ADT) 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 h95HBAhn001369; Sun, 5 Oct 2003 13:11:10 -0400 (EDT) To: "Matt Clark" Cc: "Andrew Sullivan" , pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Sun, 05 Oct 2003 17:46:21 +0100" Date: Sun, 05 Oct 2003 13:11:10 -0400 Message-ID: <1368.1065373870@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/156 X-Sequence-Number: 3904 "Matt Clark" writes: > OK I'm definitely missing something here. The point is that a big seqscan (either VACUUM or a plain table scan) hits a lot of pages, and thereby tends to fill your cache with pages that aren't actually likely to get hit again soon, perhaps pushing out pages that will be needed again soon. This happens at both the shared-buffer and kernel-disk-cache levels of caching. It would be good to find some way to prevent big seqscans from populating cache, but I don't know of any portable way to tell the OS that we don't want it to cache a page we are reading. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 5 15:00:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6C74BD1B513 for ; Sun, 5 Oct 2003 18:00:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 80949-01 for ; Sun, 5 Oct 2003 14:59:16 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 89D66D1B500 for ; Sun, 5 Oct 2003 14:59:14 -0300 (ADT) Received: (qmail 12988 invoked from network); 5 Oct 2003 17:59:15 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 5 Oct 2003 17:59:15 -0000 From: "Matt Clark" To: "Tom Lane" Cc: "Andrew Sullivan" , Subject: Re: reindex/vacuum locking/performance? Date: Sun, 5 Oct 2003 18:59:14 +0100 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: <1368.1065373870@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: 200310/157 X-Sequence-Number: 3905 > The point is that a big seqscan (either VACUUM or a plain table scan) > hits a lot of pages, and thereby tends to fill your cache with pages > that aren't actually likely to get hit again soon, perhaps pushing out > pages that will be needed again soon. This happens at both the > shared-buffer and kernel-disk-cache levels of caching. OK, I had thought (wrongly it seems, as usual, but this is how we learn!) that a plain VACUUM did not incur a read of all pages. I still don't understand *why* it does, but I'll take your word for it. Clearly if it distorts the 'normal' balance of pages in any caches, PG's or the OS's, that's a _bad thing_. I am currently in the nice position of having a DB that (just about) fits in RAM, so I pretty much don't care about read performance, but I will have to soon as it grows beyond 3GB :-( These conversations are invaluable in planning for that dread time... > It would be good to find some way to prevent big seqscans from > populating cache, but I don't know of any portable way to tell the OS > that we don't want it to cache a page we are reading. Quite. The only natural way would be to read those pages through some special device, but then you might as well do raw disk access from the get-go. Portability vs. Performance, the age old quandary. FWIW I and many others stand back in pure amazement at the sheer _quality_ of PostgreSQL. Rgds, Matt From pgsql-performance-owner@postgresql.org Sun Oct 5 15:08:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 60483D1B513 for ; Sun, 5 Oct 2003 18:08:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86806-01 for ; Sun, 5 Oct 2003 15:07:14 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 49824D1B4FE for ; Sun, 5 Oct 2003 15:07:13 -0300 (ADT) 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 h95I7Dhn006653; Sun, 5 Oct 2003 14:07:13 -0400 (EDT) To: "Matt Clark" Cc: "Andrew Sullivan" , pgsql-performance@postgresql.org Subject: Re: reindex/vacuum locking/performance? In-reply-to: References: Comments: In-reply-to "Matt Clark" message dated "Sun, 05 Oct 2003 18:59:14 +0100" Date: Sun, 05 Oct 2003 14:07:13 -0400 Message-ID: <6652.1065377233@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/158 X-Sequence-Number: 3906 "Matt Clark" writes: > OK, I had thought (wrongly it seems, as usual, but this is how we learn!) > that a plain VACUUM did not incur a read of all pages. I still don't > understand *why* it does, but I'll take your word for it. Mainly 'cause it doesn't know where the dead tuples are till it's looked. Also, VACUUM is the data collector for the free space map, and so it is also charged with finding out how much free space exists on every page. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 5 15:44:06 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 79550D1B52E for ; Sun, 5 Oct 2003 18:44:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 88853-05 for ; Sun, 5 Oct 2003 15:43:20 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 6F65FD1B54E for ; Sun, 5 Oct 2003 15:43:17 -0300 (ADT) Received: (qmail 22221 invoked from network); 5 Oct 2003 18:43:18 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 5 Oct 2003 18:43:18 -0000 From: "Matt Clark" To: "Tom Lane" Cc: "Andrew Sullivan" , Subject: Re: reindex/vacuum locking/performance? Date: Sun, 5 Oct 2003 19:43:17 +0100 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: <6652.1065377233@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: 200310/159 X-Sequence-Number: 3907 > Mainly 'cause it doesn't know where the dead tuples are till it's > looked. At this point I feel very stupid... > Also, VACUUM is the data collector for the free space map, > and so it is also charged with finding out how much free space exists > on every page. Ah, now I just feel enlightened! That makes perfect sense. I think I had been conflating free pages with free space, without understanding what the difference was. Of course I still don't really understand, but at least I now _know_ I don't. Many thanks Matt From pgsql-performance-owner@postgresql.org Sun Oct 5 15:59:42 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 86C11D1B52E for ; Sun, 5 Oct 2003 18:59:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 89668-01 for ; Sun, 5 Oct 2003 15:58:52 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 18B17D1B531 for ; Sun, 5 Oct 2003 15:58:51 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3728969; Sun, 05 Oct 2003 11:59:26 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Bruce Momjian , Tom Lane Subject: Re: count(*) slow on large tables Date: Sun, 5 Oct 2003 11:57:21 -0700 User-Agent: KMail/1.4.3 Cc: Christopher Browne , pgsql-performance@postgresql.org References: <200310041819.h94IJkV07596@candle.pha.pa.us> In-Reply-To: <200310041819.h94IJkV07596@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310051157.21555.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/160 X-Sequence-Number: 3908 Bruce, > OK, I beefed up the TODO: > > * Use a fixed row count and a +/- count with MVCC visibility rules > to allow fast COUNT(*) queries with no WHERE clause(?) > > I can always give the details if someone asks. It doesn't seem complex > enough for a separate TODO.detail item. Hmmm ... this doesn't seem effort-worthy to me. How often does anyone do COUNT with no where clause, except GUIs that give you a record count? (of course, as always, if someone wants to code it, feel free ...) And for those GUIs, wouldn't it be 97% as good to run an ANALYZE and give the approximate record counts for large tables? As for counts with a WHERE clause, this is obviously up to the user. Joe Conway and I tested using a C trigger to track some COUNT ... GROUP BY values for large tables based on additive numbers. It worked fairly well for accuracy, but the performance penalty on data writes was significant ... 8% to 25% penalty for UPDATES, depending on the frequency and batch size (> frequency > batch size --> > penalty) It's possible that this could be improved through some mechanism more tightly integrated with the source code. However,the coding effort would be significant ( 12-20 hours ) and it's possible that there would be no improvement, which is why we didn't do it. We also discussed an asynchronous aggregates collector that would work something like the statistics collector, and keep pre-programmmed aggregate data, updating during "low-activity" periods. This would significantly reduce the performance penalty, but at the cost of accuracy ... that is, a 1%-5% variance on high-activity tables would be unavoidable, and all cached aggregates would have to be recalculated on database restart, significantly slowing down startup. Again, we felt that the effort-result payoff was not worthwhile. Overall, I think the stuff we already have planned ... the hash aggregates in 7.4 and Tom's suggestion of adding an indexable flag to pg_aggs ... are far more likely to yeild useful fruit than any caching plan. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Oct 5 16:11:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6C6F9D1B523 for ; Sun, 5 Oct 2003 19:11:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90110-06 for ; Sun, 5 Oct 2003 16:11:11 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 3FE54D1B515 for ; Sun, 5 Oct 2003 16:11:09 -0300 (ADT) Received: (qmail 22647 invoked from network); 5 Oct 2003 19:11:25 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.136.235) by 205.178.180.9 with SMTP; 5 Oct 2003 19:11:25 -0000 Subject: Re: count(*) slow on large tables From: Rod Taylor To: Josh Berkus Cc: Bruce Momjian , Tom Lane , Christopher Browne , Postgresql Performance In-Reply-To: <200310051157.21555.josh@agliodbs.com> References: <200310041819.h94IJkV07596@candle.pha.pa.us> <200310051157.21555.josh@agliodbs.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-XTNXnIGcdPFIprcvprBw" Message-Id: <1065381109.23288.196.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 05 Oct 2003 15:11:50 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/161 X-Sequence-Number: 3909 --=-XTNXnIGcdPFIprcvprBw Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > And for those GUIs, wouldn't it be 97% as good to run an ANALYZE and give= the=20 > approximate record counts for large tables? Interfaces which run a COUNT(*) like that are broken by design. They fail to consider the table may really be a view which of course could not be cached with results like that and may take days to load a full result set (we had some pretty large views in an old billing system). --=-XTNXnIGcdPFIprcvprBw Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/gGz16DETLow6vwwRAtTVAJ0ZiggnYaltbSqjZvpmgT3dVUzQjwCfaSbx XJVaUzgB8PiM5ozyY7P6LuA= =ljMF -----END PGP SIGNATURE----- --=-XTNXnIGcdPFIprcvprBw-- From pgsql-performance-owner@postgresql.org Sun Oct 5 19:20:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AD641D1B4EF for ; Sun, 5 Oct 2003 22:20:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17862-06 for ; Sun, 5 Oct 2003 19:20:12 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 034D1D1B520 for ; Sun, 5 Oct 2003 19:20:10 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h95MK5Qh082405 for ; Sun, 5 Oct 2003 22:20:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h95M4YQw080756 for pgsql-performance@postgresql.org; Sun, 5 Oct 2003 22:04:34 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: reindex/vacuum locking/performance? Date: Sun, 05 Oct 2003 17:57:42 -0400 Organization: cbbrowne Computing Inc Lines: 23 Message-ID: References: <1368.1065373870@sss.pgh.pa.us> 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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:NvJnCRv57A/AFMW7U2gKB7DEgsY= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/162 X-Sequence-Number: 3910 After a long battle with technology,matt@ymogen.net ("Matt Clark"), an earthling, wrote: >> The point is that a big seqscan (either VACUUM or a plain table scan) >> hits a lot of pages, and thereby tends to fill your cache with pages >> that aren't actually likely to get hit again soon, perhaps pushing out >> pages that will be needed again soon. This happens at both the >> shared-buffer and kernel-disk-cache levels of caching. > > OK, I had thought (wrongly it seems, as usual, but this is how we learn!) > that a plain VACUUM did not incur a read of all pages. I still don't > understand *why* it does, but I'll take your word for it. How does it know what to do on any given page if it does not read it in? It has to evaluate whether tuples can be thrown away or not, and that requires looking at the tuples. It may only be looking at a small portion of the page, but that still requires reading each page. No free lunch, unfortunately... -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','cbbrowne.com'). http://www3.sympatico.ca/cbbrowne/sgml.html "End users are just test loads for verifying that the system works, kind of like resistors in an electrical circuit." -- Kaz Kylheku in c.o.l.d.s From pgsql-performance-owner@postgresql.org Sun Oct 5 20:33:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 23313D1B52D for ; Sun, 5 Oct 2003 23:33:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34204-06 for ; Sun, 5 Oct 2003 20:32:52 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 46AB2D1B515 for ; Sun, 5 Oct 2003 20:32:49 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id F2EE61EF1; Sun, 5 Oct 2003 19:32:51 -0400 (EDT) Subject: Re: reindex/vacuum locking/performance? From: Neil Conway To: Andrew Sullivan Cc: PostgreSQL Performance In-Reply-To: <20031004152241.GL580@libertyrms.info> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> Content-Type: text/plain Message-Id: <1065396767.466.12.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 05 Oct 2003 19:32:47 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/163 X-Sequence-Number: 3911 On Sat, 2003-10-04 at 11:22, Andrew Sullivan wrote: > Also, a vacuum pretty much destroys your shared buffers, so you have > to be aware of that trade-off too. True, although there is no reason that this necessary needs to be the case (at least, as far as the PostgreSQL shared buffer goes). As has been pointed out numerous times on -hackers and in the literature, using LRU for a DBMS shared buffer cache is far from optimal, and better algorithms have been proposed (e.g. LRU-K, ARC). We could even have the VACUUM command inform the bufmgr that the pages it is in the process of reading in are part of a seqscan, and so are unlikely to be needed in the immediate future. -Neil From pgsql-performance-owner@postgresql.org Sun Oct 5 20:44:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 04550D1B515 for ; Sun, 5 Oct 2003 23:44:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25775-10 for ; Sun, 5 Oct 2003 20:43:49 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F05C9D1B53A for ; Sun, 5 Oct 2003 20:43:45 -0300 (ADT) 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 h95Nhmhn015814; Sun, 5 Oct 2003 19:43:48 -0400 (EDT) To: Neil Conway Cc: Andrew Sullivan , PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? In-reply-to: <1065396767.466.12.camel@tokyo> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Sun, 05 Oct 2003 19:32:47 -0400" Date: Sun, 05 Oct 2003 19:43:48 -0400 Message-ID: <15813.1065397428@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/164 X-Sequence-Number: 3912 Neil Conway writes: > ... We could even have the > VACUUM command inform the bufmgr that the pages it is in the process of > reading in are part of a seqscan, and so are unlikely to be needed in > the immediate future. This would be relatively easy to fix as far as our own buffering is concerned, but the thing that's needed to make it really useful is to prevent caching of seqscan-read pages in the kernel disk buffers. I don't know any portable way to do that :-( regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 5 20:51:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6A89FD1B4F1 for ; Sun, 5 Oct 2003 23:51:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34204-09 for ; Sun, 5 Oct 2003 20:50:39 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 8473CD1B520 for ; Sun, 5 Oct 2003 20:50:36 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 9BFC21D6F; Sun, 5 Oct 2003 19:50:39 -0400 (EDT) Subject: Re: reindex/vacuum locking/performance? From: Neil Conway To: Tom Lane Cc: Andrew Sullivan , PostgreSQL Performance In-Reply-To: <15813.1065397428@sss.pgh.pa.us> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> <15813.1065397428@sss.pgh.pa.us> Content-Type: text/plain Message-Id: <1065397835.471.17.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 05 Oct 2003 19:50:35 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/165 X-Sequence-Number: 3913 On Sun, 2003-10-05 at 19:43, Tom Lane wrote: > This would be relatively easy to fix as far as our own buffering is > concerned, but the thing that's needed to make it really useful is > to prevent caching of seqscan-read pages in the kernel disk buffers. True. > I don't know any portable way to do that :-( For the non-portable way of doing this, are you referring to O_DIRECT? Even if it isn't available everywhere, it might be worth considering this at least for the platforms on which it is supported. -Neil From pgsql-performance-owner@postgresql.org Sun Oct 5 23:01:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 271CBD1B50D for ; Mon, 6 Oct 2003 02:01:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 45524-04 for ; Sun, 5 Oct 2003 23:01:03 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id E4141D1B4ED for ; Sun, 5 Oct 2003 23:00:59 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A6KgK-0008PS-00 for ; Sun, 05 Oct 2003 22:01:04 -0400 Received: by dba2 (Postfix, from userid 1019) id EB3ECC9FE; Sun, 5 Oct 2003 22:01:03 -0400 (EDT) Date: Sun, 5 Oct 2003 22:01:03 -0400 From: Andrew Sullivan To: PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031006020103.GD3441@libertyrms.info> Mail-Followup-To: Andrew Sullivan , PostgreSQL Performance References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1065396767.466.12.camel@tokyo> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/166 X-Sequence-Number: 3914 On Sun, Oct 05, 2003 at 07:32:47PM -0400, Neil Conway wrote: > been pointed out numerous times on -hackers and in the literature, using > LRU for a DBMS shared buffer cache is far from optimal, and better > algorithms have been proposed (e.g. LRU-K, ARC). We could even have the > VACUUM command inform the bufmgr that the pages it is in the process of > reading in are part of a seqscan, and so are unlikely to be needed in > the immediate future. Hey, when that happens, you'll find me first in line to praise the implementor; but until then, it's important that people not get the idea that vacuum is free. It is _way_ imporved, and on moderately loaded boxes, it'salmost unnoticable. But under heavy load, you need to be _real_ careful about calling vacuum. I think one of the biggest needs in the AVD is some sort of intelligence about current load on the postmaster, but I haven't the foggiest idea how to give it such intelligence. 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 Oct 6 17:12:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B9C08D1B505 for ; Mon, 6 Oct 2003 03:21:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73476-02 for ; Mon, 6 Oct 2003 00:20:17 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id AB29AD1B52E for ; Mon, 6 Oct 2003 00:20:16 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h963KBQh026314 for ; Mon, 6 Oct 2003 03:20:11 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9637YJu024007 for pgsql-performance@postgresql.org; Mon, 6 Oct 2003 03:07:34 GMT From: "Ronald Khoo" X-Newsgroups: comp.databases.postgresql.performance Subject: Re: reindex/vacuum locking/performance? Date: Mon, 6 Oct 2003 11:07:01 +0800 Organization: Hub.Org Networking Services Lines: 10 Message-ID: References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> <15813.1065397428@sss.pgh.pa.us> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/191 X-Sequence-Number: 3939 > This would be relatively easy to fix as far as our own buffering is > concerned, but the thing that's needed to make it really useful is > to prevent caching of seqscan-read pages in the kernel disk buffers. > I don't know any portable way to do that :-( raw disc ? :-) From pgsql-performance-owner@postgresql.org Mon Oct 6 03:07:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BFA49D1B4F6 for ; Mon, 6 Oct 2003 06:07:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90800-06 for ; Mon, 6 Oct 2003 03:06:44 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 9033ED1B4EB for ; Mon, 6 Oct 2003 03:06:41 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h966AmTk013993 for ; Mon, 6 Oct 2003 11:40:49 +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 h966AlYM013922 for ; Mon, 6 Oct 2003 11:40:48 +0530 Message-ID: <3F81066C.90402@persistent.co.in> Date: Mon, 06 Oct 2003 11:36:36 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables References: <200310041819.h94IJkV07596@candle.pha.pa.us> In-Reply-To: <200310041819.h94IJkV07596@candle.pha.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: 200310/167 X-Sequence-Number: 3915 Bruce Momjian wrote: > OK, I beefed up the TODO: > > * Use a fixed row count and a +/- count with MVCC visibility rules > to allow fast COUNT(*) queries with no WHERE clause(?) > > I can always give the details if someone asks. It doesn't seem complex > enough for a separate TODO.detail item. May I propose alternate approach for this optimisation? - Postgresql allows to maintain user defined variables in shared memory. - These variables obey transactions but do not get written to disk at all. - There should be a facility to detect whether such a variable is initialized or not. How it will help? This is in addition to trigger proposal that came up earlier. With triggers it's not possible to make values visible across backends unless trigger updates a table, which eventually leads to vacuum/dead tuples problem. 1. User creates a trigger to check updates/inserts for certain conditions. 2. It updates the count as and when required. 3. If the trigger detects the count is not initialized, it would issue the same query first time. There is no avoiding this issue. Besides providing facility of resident variables could be used imaginatively as well. Does this make sense? IMO this is more generalised approach over all. Just a thought. Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 6 03:13:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BEEA7D1B4E3 for ; Mon, 6 Oct 2003 06:13:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92263-08 for ; Mon, 6 Oct 2003 03:12:12 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 42A54D1B4EB for ; Mon, 6 Oct 2003 03:12:09 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h966FnfA016113 for ; Mon, 6 Oct 2003 11:45:49 +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 h966FiYM016019; Mon, 6 Oct 2003 11:45:47 +0530 Message-ID: <3F810796.8010403@persistent.co.in> Date: Mon, 06 Oct 2003 11:41: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.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stef Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. References: <20031003163040.3641f39a.svb@ucs.co.za> <24646.1065195774@sss.pgh.pa.us> <20031003181002.20cc6912.svb@ucs.co.za> <26554.1065198720@sss.pgh.pa.us> <20031003195238.16fc1229.svb@ucs.co.za> In-Reply-To: <20031003195238.16fc1229.svb@ucs.co.za> 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: 200310/168 X-Sequence-Number: 3916 Stef wrote: > On Fri, 03 Oct 2003 12:32:00 -0400 > Tom Lane wrote: > > => What exactly is failing? And what's the platform, anyway? > > Nothing is really failing atm, except the funds for better > hardware. JBOSS and some other servers need to be > run on these machines, along with linux, which will be > a minimal RH >= 7.2 with kernel 2.4.21 > (Any better suggestions here?) > > In this case, whatever is the least amount of memory > postgres can run on, is what is needed. So this is still > a kind of feasibility study. Of course, it will still be thoroughly > tested, if it turns out to be possible. (Which I know it is, but not how) If you mean to say that postgresql should use just 8 MB of RAM rather than running it on a 8MB machine, then that is impossible given how much postgresql relies upon OS cache. You may configure postgresql with 8MB shared memory or the old holy default of 512K, but if your database is 100MB and OS is caching half of it on behalf of postgresql, your goal is already missed.. Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 6 04:57:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AE70BD1B4F1 for ; Mon, 6 Oct 2003 07:57:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 10749-03 for ; Mon, 6 Oct 2003 04:56:19 -0300 (ADT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id 6704CD1B4E3 for ; Mon, 6 Oct 2003 04:56:14 -0300 (ADT) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id E1B7F2BDEC; Mon, 6 Oct 2003 09:56:00 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id EF8E9D9E78; Mon, 6 Oct 2003 09:56:00 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id 4CD4F973EA; Mon, 6 Oct 2003 09:56:01 +0200 (SAST) Date: Mon, 6 Oct 2003 09:55:51 +0200 From: Stef To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. Message-Id: <20031006095551.1d7bfeb8.svb@ucs.co.za> In-Reply-To: <200310031108.49002.josh@agliodbs.com> References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> X-Mailer: Sylpheed version 0.9.5claws28 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: LV^-*d3kQlL,6{Y:X)M~tuL#y!p.kO_Qbc!xxqhZC4s}Y]L0g)z^aiLsQGY34d|}Xp:HNm)MRsc?^?ZQ}smznF&jx|w@,a**K&QL.Dc~2~M5V`zb>hExCJDB[[o=M)e"; k-n[7tz2TY7+; *_xX's(5cUEtdw*yG-OmKm}6($zpUz8S`Nz@w X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Mon__6_Oct_2003_09_55_52_+0200_um.cP=ST1Zj13T9n" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/169 X-Sequence-Number: 3917 --Signature=_Mon__6_Oct_2003_09_55_52_+0200_um.cP=ST1Zj13T9n Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Thanks for the replies, On Fri, 3 Oct 2003 11:08:48 -0700 Josh Berkus wrote: => 1. Make sure that the WAL files (pg_xlog) are on a seperate disk from the => database files, either through mounting or symlinking. I'm not sure I understand how this helps? => 2. Tweak the .conf file for low vacuum_mem (1024?), but vacuum very => frequently, like every 1-5 minutes. Spend some time tuning your => fsm_max_pages to the ideal level so that you're not allocating any extra => memory to the FSM. => => 3. If your concern is *average* CPU/RAM consumption, and not peak load => activity, increase wal_files and checkpoint_segments to do more efficient => batch processing of pending updates as the cost of some disk space. If peak => load activity is a problem, don't do this. => => 4. Tune all of your queries carefully to avoid anything requiring a => RAM-intensive merge join or CPU-eating calculated expression hash join, or => similar computation-or-RAM-intensive operations. Thanks, I'll try some of these, and post the results. The actual machines seem to be Pentium I machines, with 32M RAM. I've gathered that it is theoretically possible, so no to go try it. Regards Stef --Signature=_Mon__6_Oct_2003_09_55_52_+0200_um.cP=ST1Zj13T9n Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/gSARgDYs3UkRjZkRAts1AKChqytWZyhIRO3Qv9FkkJq021XtzgCfS5pq k3NfOBjojrci3nmE0lnOTFw= =bKRr -----END PGP SIGNATURE----- --Signature=_Mon__6_Oct_2003_09_55_52_+0200_um.cP=ST1Zj13T9n-- From pgsql-performance-owner@postgresql.org Mon Oct 6 09:08:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 47314D1B4E9 for ; Mon, 6 Oct 2003 12:08:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 46353-10 for ; Mon, 6 Oct 2003 09:07:45 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id F1690D1B53E for ; Mon, 6 Oct 2003 09:07:26 -0300 (ADT) Received: (qmail 52211 invoked from network); 6 Oct 2003 12:07:27 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 6 Oct 2003 12:07:27 -0000 Date: Mon, 6 Oct 2003 08:07:27 -0400 (EDT) From: Jeff To: Neil Conway Cc: Tom Lane , Andrew Sullivan , PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? In-Reply-To: <1065397835.471.17.camel@tokyo> 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: 200310/170 X-Sequence-Number: 3918 On Sun, 5 Oct 2003, Neil Conway wrote: > > > I don't know any portable way to do that :-( > > For the non-portable way of doing this, are you referring to O_DIRECT? > > Even if it isn't available everywhere, it might be worth considering > this at least for the platforms on which it is supported. > I strongly agree here only if we can prove there is a benefit. I think it would be silly of us if some OS supported SnazzyFeatureC that was able to speed up PG by a large percentage (hopefully, in a rather non-invasive way in the code). But, I do see the problem here with bloat and PG being radically different platform to platform. I suppose we could dictate that at least N os's had to have it.. or perhaps supply it has contrib/ patches.... Something to think about. I'd be interested in tinkering with this, but I'm more interested at the moment of why (with proof, not antecdotal) Solaris is so much slower than Linux and what we cna do about this. We're looking to move a rather large Informix db to PG and ops has reservations about ditching Sun hardware. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 6 09:15:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 94445D1B4FE for ; Mon, 6 Oct 2003 12:15:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 47370-07 for ; Mon, 6 Oct 2003 09:15:04 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 8394CD1B4FF for ; Mon, 6 Oct 2003 09:15:01 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A6UGS-0001KG-00 for ; Mon, 06 Oct 2003 08:15:00 -0400 Received: by dba2 (Postfix, from userid 1019) id 25332C9FE; Mon, 6 Oct 2003 08:15:00 -0400 (EDT) Date: Mon, 6 Oct 2003 08:15:00 -0400 From: Andrew Sullivan To: PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? Message-ID: <20031006121459.GC4971@libertyrms.info> Mail-Followup-To: Andrew Sullivan , PostgreSQL Performance References: <1065397835.471.17.camel@tokyo> 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: 200310/171 X-Sequence-Number: 3919 On Mon, Oct 06, 2003 at 08:07:27AM -0400, Jeff wrote: > I strongly agree here only if we can prove there is a benefit. There's plenty of academic work which purports to show that LRU is far from the best choice. Just in principle, it seems obvious that a single-case seqscan-type operation (such as vacuum does) is a good way to lose your cache for no real gain. > I'd be interested in tinkering with this, but I'm more interested at the > moment of why (with proof, not antecdotal) Solaris is so much slower than > Linux and what we cna do about this. We're looking to move a rather large > Informix db to PG and ops has reservations about ditching Sun hardware. Interestingly, we're contemplating ditching Solaris because of the terrible reliability we're getting from the hardware. You can use truss to find some of the problems on Solaris. The open() syscall takes forever when you don't hit the Postgres shared buffers (even if you can be sure the page is in filesystem buffers -- we could demonstrate it on a 1 G database on a machine with 10 G of RAM). I've heard grumblings about spinlocks on Solaris which might explain this problem. I certainly notice that performance gets geometrically worse when you add a few hundred extra connections. 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 Oct 6 09:20:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1CD5CD1B4FE for ; Mon, 6 Oct 2003 12:20:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55255-02 for ; Mon, 6 Oct 2003 09:19:58 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 2C2ACD1B50B for ; Mon, 6 Oct 2003 09:19:53 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h96CO8UA007754 for ; Mon, 6 Oct 2003 17:54:08 +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 h96CO6Ns007689; Mon, 6 Oct 2003 17:54:06 +0530 Message-ID: <3F815DE7.3030507@persistent.co.in> Date: Mon, 06 Oct 2003 17:49:51 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Cc: Neil Conway , Tom Lane , Andrew Sullivan , PostgreSQL Performance Subject: Re: reindex/vacuum locking/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: 200310/172 X-Sequence-Number: 3920 Jeff wrote: > I'd be interested in tinkering with this, but I'm more interested at the > moment of why (with proof, not antecdotal) Solaris is so much slower than > Linux and what we cna do about this. We're looking to move a rather large > Informix db to PG and ops has reservations about ditching Sun hardware. Is linux on sparc hardware is an option..:-) Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 6 10:25:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1443CD1B523 for ; Mon, 6 Oct 2003 13:25:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66285-06 for ; Mon, 6 Oct 2003 10:24:34 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id E8F43D1B8BC for ; Mon, 6 Oct 2003 10:21:37 -0300 (ADT) Received: (qmail 25740 invoked by uid 500); 6 Oct 2003 13:29:05 -0000 Date: Mon, 6 Oct 2003 08:29:05 -0500 From: Bruno Wolff III To: Stef Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: Postgres low end processing. Message-ID: <20031006132905.GA25586@wolff.to> Mail-Followup-To: Stef , Josh Berkus , pgsql-performance@postgresql.org References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> <20031006095551.1d7bfeb8.svb@ucs.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031006095551.1d7bfeb8.svb@ucs.co.za> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/173 X-Sequence-Number: 3921 On Mon, Oct 06, 2003 at 09:55:51 +0200, Stef wrote: > > Thanks, I'll try some of these, and post the results. > The actual machines seem to be Pentium I machines, > with 32M RAM. I've gathered that it is theoretically > possible, so no to go try it. I am running 7.4beta2 on a Pentium I machine with 48 MB of memory. I was running an earlier version of Postgres (probably 7.1.x) on it when it only had 32 MB of memory. It doesn't run very fast, but it works OK. I remember increase from 32MB to 48MB was very noticible in the time to serve web pages using information from the DB, but I don't remember the details since it was a couple of years ago. From pgsql-performance-owner@postgresql.org Mon Oct 6 10:34:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA140D1B54E for ; Mon, 6 Oct 2003 13:34:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67839-02 for ; Mon, 6 Oct 2003 10:33:55 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 406BDD1B4E5 for ; Mon, 6 Oct 2003 10:33:51 -0300 (ADT) Received: (qmail 52458 invoked from network); 6 Oct 2003 13:33:58 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 6 Oct 2003 13:33:58 -0000 Date: Mon, 6 Oct 2003 09:33:57 -0400 (EDT) From: Jeff To: Andrew Sullivan Cc: PostgreSQL Performance Subject: locking/performance, Solaris performance discovery In-Reply-To: <20031006121459.GC4971@libertyrms.info> 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: 200310/174 X-Sequence-Number: 3922 On Mon, 6 Oct 2003, Andrew Sullivan wrote: > There's plenty of academic work which purports to show that LRU is > far from the best choice. Just in principle, it seems obvious that a > single-case seqscan-type operation (such as vacuum does) is a good > way to lose your cache for no real gain. > Logically bypassing caches for a seq scan also makes sense. > Interestingly, we're contemplating ditching Solaris because of the > terrible reliability we're getting from the hardware. > The reason ops likes solaris / sun is twofold. 1. we have a pile of big sun machines around. 2. Solaris / Sun is quite a bit more graceful in the egvent of a hardware failure. We've burned out our fair share of cpu's etc and solaris has been rather graceful about it. I've started profiling and running tests... currently it is leaning towards the sysv semaphores. I see in src/backend/port/ that pg_sema.c is linked to the sysv implementation. So what I did was create a semaphore set, and then fired off 5 copies of a program that attaches to that semaphore and then locks/unlocks it 1M times. 2xP2-450, Linux 2.4.18: 1 process: 221680 / sec, 5 process: 98039 / sec 4xUltraSparc II-400Mhz, Solaris 2.6: 1 proc: 142857 / sec, 5 process: 23809 So I'm guessing that is where a LOT of the suck is coming from. What I plan to do next is looking to see if there are other interprocess locking mechanisms on solaris (perhaps pthread_mutex with that inter-process flag or something) to see if I can get those numbers a little closer. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 6 11:31:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 140B8D1B522 for ; Mon, 6 Oct 2003 14:31:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 80164-01 for ; Mon, 6 Oct 2003 11:30:17 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id DC468D1B51E for ; Mon, 6 Oct 2003 11:30:12 -0300 (ADT) 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 h96EUEhn026976; Mon, 6 Oct 2003 10:30:15 -0400 (EDT) To: Jeff Cc: Andrew Sullivan , PostgreSQL Performance Subject: Re: locking/performance, Solaris performance discovery In-reply-to: References: Comments: In-reply-to Jeff message dated "Mon, 06 Oct 2003 09:33:57 -0400" Date: Mon, 06 Oct 2003 10:30:14 -0400 Message-ID: <26975.1065450614@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/175 X-Sequence-Number: 3923 Jeff writes: > I've started profiling and running tests... currently it is leaning > towards the sysv semaphores. I see in src/backend/port/ that pg_sema.c is > linked to the sysv implementation. Does Solaris have Posix semaphores? You could try using those instead. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 6 17:04:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3770CD1B567 for ; Mon, 6 Oct 2003 15:11:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81338-08 for ; Mon, 6 Oct 2003 12:10:22 -0300 (ADT) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id E71D7D1B51E for ; Mon, 6 Oct 2003 12:10:21 -0300 (ADT) Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6X08-0003KO-00 for ; Mon, 06 Oct 2003 17:10:20 +0200 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 1A6Wxn-0003Hh-00 for ; Mon, 06 Oct 2003 17:07:55 +0200 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A6Wxn-0006U8-00 for ; Mon, 06 Oct 2003 17:07:55 +0200 From: Harald Fuchs Subject: Re: count(*) slow on large tables Date: 06 Oct 2003 17:08:36 +0200 Organization: Linux Private Site Lines: 21 Message-ID: References: <20031002191547.GZ87525@rlx11.zapatec.com> <20031002193905.GD18417@wolff.to> <3F7C98B8.C892D0E5@nsd.ca> <60brszcng5.fsf@dev6.int.libertyrms.info> <20031002223313.GE87525@rlx11.zapatec.com> <20031003042754.GH87525@rlx11.zapatec.com> <3F7D172E.3060107@persistent.co.in> Reply-To: hf99@protecting.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-No-Archive: yes User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/190 X-Sequence-Number: 3938 In article <3F7D172E.3060107@persistent.co.in>, Shridhar Daithankar writes: > Dror Matalon wrote: >> I smell a religious war in the aii:-). Can you go several days in a >> row without doing select count(*) on any >> of your tables? I suspect that this is somewhat a domain specific >> issue. In some areas >> you don't need to know the total number of rows in your tables, in >> others you do. > If I were you, I would have an autovacuum daemon running and rather > than doing select count(*), I would look at stats generated by > vacuums. They give approximate number of tuples and it should be good > enough it is accurate within a percent. The stats might indeed be a good estimate presumed there were not many changes since the last VACUUM. But how about a variant of COUNT(*) using an index? It would not be quite exact since it might contain tuples not visible in the current transaction, but it might be a much better estimate than the stats. From pgsql-performance-owner@postgresql.org Mon Oct 6 12:17:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 21C5BD1B57B for ; Mon, 6 Oct 2003 15:17:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 89916-01 for ; Mon, 6 Oct 2003 12:16:57 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 84A5AD1B54F for ; Mon, 6 Oct 2003 12:16:56 -0300 (ADT) Received: (qmail 52881 invoked from network); 6 Oct 2003 15:16:54 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 6 Oct 2003 15:16:54 -0000 Date: Mon, 6 Oct 2003 11:16:54 -0400 (EDT) From: Jeff To: Tom Lane Cc: Andrew Sullivan , PostgreSQL Performance Subject: Re: locking/performance, Solaris performance discovery In-Reply-To: <26975.1065450614@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: 200310/176 X-Sequence-Number: 3924 On Mon, 6 Oct 2003, Tom Lane wrote: > > Does Solaris have Posix semaphores? You could try using those instead. > > regards, tom lane Yep. It does. I learned them quick enough (using posix_sema.c as a guide) and found out that at least on Sol 2.6 they are slower than sysv - with 5 processes it went to about 16k lock/unlock a second. I'm going to try to find a box around here I can get sol(8|9) on that has sufficient disk space and see. I'm guessing sun has likely made improvements... Another odd thing I'm trying to work out is why my profiles come out so radically different on the linux box and the sun box. Sun: 31.17 18.90 18.90 internal_mcount 19.10 30.48 11.58 8075381 0.00 0.00 _bt_checkkeys 5.66 33.91 3.43 24375253 0.00 0.00 FunctionCall2 4.82 36.83 2.92 8073010 0.00 0.00 _bt_step 3.51 38.96 2.13 14198 0.15 0.15 _read 2.77 40.64 1.68 8069040 0.00 0.00 varchareq 2.59 42.21 1.57 28454 0.06 0.23 _bt_next 2.29 43.60 1.39 1003 1.39 1.40 AtEOXact_Buffers 1.86 44.73 1.13 16281197 0.00 0.00 pg_detoast_datum 1.81 45.83 1.10 _mcount 1.68 46.85 1.02 2181 0.47 0.47 pglz_decompress Linux: 11.14 0.62 0.62 1879 0.00 0.00 pglz_decompress 6.71 0.99 0.37 1004 0.00 0.00 AtEOXact_Buffers 3.80 1.20 0.21 1103045 0.00 0.00 AllocSetAlloc 3.23 1.38 0.18 174871 0.00 0.00 nocachegetattr 2.92 1.54 0.16 1634957 0.00 0.00 AllocSetFreeIndex 2.50 1.68 0.14 20303 0.00 0.00 heapgettup 1.93 1.79 0.11 1003 0.00 0.00 AtEOXact_CatCache 1.76 1.89 0.10 128442 0.00 0.00 hash_any 1.72 1.98 0.10 90312 0.00 0.00 FunctionCall3 1.69 2.08 0.09 50632 0.00 0.00 ExecTargetList 1.60 2.17 0.09 51647 0.00 0.00 heap_formtuple 1.55 2.25 0.09 406162 0.00 0.00 newNode 1.46 2.33 0.08 133044 0.00 0.00 hash_search It is the same query with slightly different data (The Sun has probably.. 20-40k more rows in the table the query hits). I'll be digging up more info later today. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 6 12:18:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CD926D1B587 for ; Mon, 6 Oct 2003 15:17:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81338-09 for ; Mon, 6 Oct 2003 12:17:02 -0300 (ADT) Received: from chimta04.algx.net (mta5.algx.net [67.92.168.234]) by svr1.postgresql.org (Postfix) with ESMTP id 8C5BAD1B57C for ; Mon, 6 Oct 2003 12:17:01 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx04.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMC007HRD4CH6@chimmx04.algx.net> for pgsql-performance@postgresql.org; Mon, 06 Oct 2003 10:17:00 -0500 (CDT) Date: Mon, 06 Oct 2003 11:17:00 -0400 From: Jason Hihn Subject: Shopping for hardware To: pgsql-performance@postgresql.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/177 X-Sequence-Number: 3925 Ok, I asked this on [novice], but I was told it's be better to post it here... I've got some money to spend on a new servers. The biggest concern is the PostgreSQL database server that will "be the company." (*Everyone* uses the database server in some form or another) I'm looking for hot-swappable RAID 1 on a Linux platform at the least. Are there any vendors to avoid or prefer? What works best? Am I better off going with a DIY or getting something pre-packaged? In terms of numbers, we expect have an average of 100 active connections (most of which are idle 9/10ths of the time), with about 85% reading traffic. I hope to have one server host about 1000-2000 active databases, with the largest being about 60 meg (no blobs). Inactive databases will only be for reading (archival) purposes, and will seldom be accessed. (I could probably move them off to another server with a r/o disk...) Does any of this represent a problem for Postgres? The datasets are typically not that large, only a few queries on a few databases ever return over 1000 rows. The configuration that is going on in my head is: RAID 1, 200gig disks 1 server, 4g ram Linux 2.4 or 2.6 (depends on when we deploy and 2.6's track record at that time) I want something that can do hot-swaps and auto-mirroring after swap. Unfortunately, this is a new area for me. (I normally stick to S/W for non-high end systems) Thanks! Jason Hihn Paytime Payroll From pgsql-performance-owner@postgresql.org Mon Oct 6 12:53:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EB010D1B4E9 for ; Mon, 6 Oct 2003 15:53:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92762-03 for ; Mon, 6 Oct 2003 12:53:02 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 314F7D1B500 for ; Mon, 6 Oct 2003 12:53:01 -0300 (ADT) 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 h96FpjGQ010773; Mon, 6 Oct 2003 09:51:45 -0600 (MDT) Date: Mon, 6 Oct 2003 09:43:35 -0600 (MDT) From: "scott.marlowe" To: Jason Hihn Cc: Subject: Re: Shopping for hardware In-Reply-To: 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: 200310/178 X-Sequence-Number: 3926 On Mon, 6 Oct 2003, Jason Hihn wrote: > Ok, I asked this on [novice], but I was told it's be better to post it > here... > > I've got some money to spend on a new servers. The biggest concern is the > PostgreSQL database server that will "be the company." (*Everyone* uses the > database server in some form or another) I'm looking for hot-swappable RAID > 1 on a Linux platform at the least. Are there any vendors to avoid or > prefer? What works best? Am I better off going with a DIY or getting > something pre-packaged? Depends on your hardware expertise. You can do quite well either way. I prefer adding my own components to a pre-built vanilla server. > In terms of numbers, we expect have an average of 100 active connections > (most of which are idle 9/10ths of the time), with about 85% reading > traffic. I hope to have one server host about 1000-2000 active databases, > with the largest being about 60 meg (no blobs). Inactive databases will only > be for reading (archival) purposes, and will seldom be accessed. (I could > probably move them off to another server with a r/o disk...) That's not a really big load, but I'm guessing the peaks will be big enough to notice. > Does any of this represent a problem for Postgres? The datasets are > typically not that large, only a few queries on a few databases ever return > over 1000 rows. Nah, this is pretty normal stuff for Postgresql or any other database in its approximate class (Sybase, Oracle, Informix, DB2, MSSQL2k). > The configuration that is going on in my head is: > RAID 1, 200gig disks > 1 server, 4g ram > Linux 2.4 or 2.6 (depends on when we deploy and 2.6's track record at that > time) That's a good starting point. I'd avoid 2.6 until it's had time for the bugs to drop out. The latest 2.4 kernels are pretty stable. List of things to include if you need more performance, in order of priority: proper tuning of the postgresql.conf file (see http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html) hardware RAID card with battery backed cache, the bigger the cache the better. more drives for RAID 1+0 faster CPUs. since you've already got 4 gigs of RAM slated, you're set there on linux, where having more won't likely help a lot unless you go to a 64 bit platform. > I want something that can do hot-swaps and auto-mirroring after swap. > Unfortunately, this is a new area for me. (I normally stick to S/W for > non-high end systems) The LSI/Megaraid cards can handle hot swaps quite well, make sure you get the right kind of hot swap shoes so they isolate the drive from the buss when you turn it off and they don't lock up your scsi buss. From pgsql-performance-owner@postgresql.org Mon Oct 6 13:22:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4D582D1B4F2 for ; Mon, 6 Oct 2003 16:22:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 91537-09 for ; Mon, 6 Oct 2003 13:21:59 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 3A5CFD1B527 for ; Mon, 6 Oct 2003 13:21:59 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id CFFEB3E50 for ; Mon, 6 Oct 2003 12:21:58 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 67309-04 for ; Mon, 6 Oct 2003 12:21:58 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 3315F3E47 for ; Mon, 6 Oct 2003 12:21:58 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h96GLwTP000293 for pgsql-performance@postgresql.org; Mon, 6 Oct 2003 12:21:58 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Shopping for hardware Date: Mon, 06 Oct 2003 12:21:57 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 34 Message-ID: References: NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065457317 94516 216.194.193.105 (6 Oct 2003 16:21:57 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 6 Oct 2003 16:21:57 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:RACxKhXYtmpkmSBpyjvBF0EogR8= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/179 X-Sequence-Number: 3927 >>>>> "JH" == Jason Hihn writes: JH> The configuration that is going on in my head is: JH> RAID 1, 200gig disks JH> 1 server, 4g ram JH> Linux 2.4 or 2.6 (depends on when we deploy and 2.6's track record at that JH> time) My recommendation is to get more disks (smaller and faster) rather than a few large ones. As for vendors, I always buy from Dell because they actually honor their "4-hour 24x7 replacement parts with technician to stick 'em" in guarantee. That and their hardware is rock solid and non-funky (ie, I can run FreeBSD on it with no issues). Here's my latest setup I just got: Dell PE 2650, dual Xeon processors (lowest speed they sell, as this is not a bottleneck) 4Gb RAM Dell PERC3 RAID controller (rebranded AMI controller) dual channel 2x 18Gb internal disks on RAID1 (RAID channel0) 14x 18Gb external disks on RAID5 (RAID channel1, see my posts on this list from a month or so ago on how I arrived at RAID5). All the disks are SCSI 15kRPM U320 drives, tho the controller only does U160. I run FreeBSD, but it should run linux just fine, too. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 6 13:36:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 51B8BD1B4F6 for ; Mon, 6 Oct 2003 16:36:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 94806-09 for ; Mon, 6 Oct 2003 13:35:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id DC81DD1B564 for ; Mon, 6 Oct 2003 13:35:29 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3732345; Mon, 06 Oct 2003 09:35:41 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jason Hihn , pgsql-performance@postgresql.org Subject: Re: Shopping for hardware Date: Mon, 6 Oct 2003 09:33:27 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310060933.27715.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/180 X-Sequence-Number: 3928 Jason, > In terms of numbers, we expect have an average of 100 active connections > (most of which are idle 9/10ths of the time), with about 85% reading > traffic. I hope to have one server host about 1000-2000 active databases, > with the largest being about 60 meg (no blobs). Inactive databases will > only be for reading (archival) purposes, and will seldom be accessed. (I > could probably move them off to another server with a r/o disk...) Hey, two people (one of them me) suggested that rather than putting all 2000 databases on one $15,000 server, that you buy 3 $5000 servers and split things up. You may have considered this suggestion and rejected it, but I'mm wondering if you missed it ... If you're lumping everything on one server, you'll need to remember to increase max_fsm_relations to the total number of tables in all databases ... for example, for 10 tables in 2000 databases you'll want a setting of 20000 (which sounds huge but it's really only about 1mb memory). -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 6 13:56:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 48CCAD1B52E for ; Mon, 6 Oct 2003 16:56:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03408-06 for ; Mon, 6 Oct 2003 13:55:43 -0300 (ADT) Received: from jamesr.best.vwh.net (jamesr.best.vwh.net [192.220.76.165]) by svr1.postgresql.org (Postfix) with SMTP id E3A5ED1B4EC for ; Mon, 6 Oct 2003 13:55:41 -0300 (ADT) Received: (qmail 43202 invoked by uid 19621); 6 Oct 2003 16:55:41 -0000 Received: from unknown (HELO ?10.0.0.210?) ([65.87.16.98]) (envelope-sender ) by 192.220.76.165 (qmail-ldap-1.03) with SMTP for ; 6 Oct 2003 16:55:41 -0000 Subject: Seqscan buffer promotion (was: reindex/vacuum locking/performance?) From: James Rogers To: Andrew Sullivan Cc: PostgreSQL Performance In-Reply-To: <20031006121459.GC4971@libertyrms.info> References: <1065397835.471.17.camel@tokyo> <20031006121459.GC4971@libertyrms.info> Content-Type: text/plain Organization: Message-Id: <1065459338.26229.26.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 06 Oct 2003 09:55:38 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/181 X-Sequence-Number: 3929 On Mon, 2003-10-06 at 05:15, Andrew Sullivan wrote: > There's plenty of academic work which purports to show that LRU is > far from the best choice. Just in principle, it seems obvious that a > single-case seqscan-type operation (such as vacuum does) is a good > way to lose your cache for no real gain. Traditionally, seqscan type operations are accommodated in LRU type managers by having multiple buffer promotion policies, primarily because it is simple to implement. For example, if you are doing a seqscan, a buffer loaded from disk is never promoted to the top of the LRU. Instead it is only partially promoted (say, halfway for example) toward the top of the buffer list. A page that is already in the buffer is promoted either to the halfway point or top depending on where it was found. There are numerous variations on the idea, some being more clever and complex than others. The point of this being that a pathological or rare sequential scan can never trash more than a certain percentage of the cache, while not significantly impacting the performance of a sequential scan. The primary nuisance is that it slightly increases the API complexity. I'll add that I don't know what PostgreSQL actually does in this regard, but from the thread it appears as though seqscans are handled like the default case. Cheers, -James Rogers jamesr@best.com From pgsql-performance-owner@postgresql.org Mon Oct 6 14:02:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E83D7D1B4F2 for ; Mon, 6 Oct 2003 17:02:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03671-08 for ; Mon, 6 Oct 2003 14:01:53 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id DEADDD1B4EC for ; Mon, 6 Oct 2003 14:01:51 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 64CEC21068; Mon, 6 Oct 2003 10:01:36 -0700 (PDT) Date: Mon, 6 Oct 2003 10:01:36 -0700 From: Sean Chittenden To: Shridhar Daithankar Cc: pgsql-performance@postgresql.org Subject: Re: count(*) slow on large tables Message-ID: <20031006170136.GB94718@perrin.nxad.com> References: <200310041819.h94IJkV07596@candle.pha.pa.us> <3F81066C.90402@persistent.co.in> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F81066C.90402@persistent.co.in> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/182 X-Sequence-Number: 3930 > How it will help? This is in addition to trigger proposal that came > up earlier. With triggers it's not possible to make values visible > across backends unless trigger updates a table, which eventually > leads to vacuum/dead tuples problem. > > 1. User creates a trigger to check updates/inserts for certain conditions. > 2. It updates the count as and when required. > 3. If the trigger detects the count is not initialized, it would issue the > same query first time. There is no avoiding this issue. > > Besides providing facility of resident variables could be used > imaginatively as well. > > Does this make sense? IMO this is more generalised approach over all. I do this _VERY_ frequently in my databases, only I have my stored procs do the aggregate in a predefined MVCC table that's always there. Here's a denormalized version for public consumption/thought: CREATE TABLE global.dba_aggregate_cache ( dbl TEXT NOT NULL, -- The database location, doesn't need to be -- qualified (ex: schema.table.col) op TEXT NOT NULL, -- The operation, SUM, COUNT, etc. qual TEXT, -- Any kind of conditional, such as a where clause val_int INT, -- Whatever the value is, of type INT val_bigint BIGINT, -- Whatever the value is, of type BIGINT val_text TEXT, -- Whatever the value is, of type TEXT val_bytea BYTEA, -- Whatever the value is, of type BYTEA ); CREATE UNIQUE INDEX dba_aggregate_cache_dbl_op_udx ON global.dba_aggregate_cache(dbl,op); Then, I use a function to retrieve this value instead of a SELECT COUNT(*). SELECT public.cache_count('dbl','qual'); -- In this case, the op is COUNT SELECT public.cache_count('dbl'); -- Returns the COUNT for the table listed in the dbl Then, I create 4 or 5 functions (depends on the op I'm performing): 1) A private function that _doesn't_ run as security definer, that populates the global.dba_aggregate_cache row if it's empty. 2) A STABLE function for SELECTs, if the row doesn't exist, then it calls function #1 to populate its existence. 3) A STABLE function for INSERTs, if the row doesn't exist, then it calls function #1 to populate its existence, then adds the necessary bits to make it accurate. 4) A STABLE function for DELETEs, if the row doesn't exist, then it calls function #1 to populate its existence, then deletes the necessary bits to make it accurate. 5) A STABLE function for UPDATEs, if the row doesn't exist, then it calls function #1 to populate its existence, then updates the necessary bits to make it accurate. It's not uncommon for me to not have an UPDATE function/trigger. Create triggers for functions 2-5, and test away. It's MVCC, searching through a table that's INDEX'ed for a single row is obviously vastly faster than a seqscan/aggregate. If I need any kind of an aggregate to be fast, I use this system with a derivation of the above table. The problem with it being that I have to retrain others to use cache_count(), or some other function instead of using COUNT(*). That said, it'd be nice if there were a way to tell PostgreSQL to do the above for you and teach COUNT(*), SUM(*), or other aggregates to use an MVCC backed cache similar to the above. If people want their COUNT's to be fast, then they have to live with the INSERT, UPDATE, DELETE cost. The above doesn't work with anything complex such as join's, but it's certainly a start and I think satisfies everyone's gripes other than the tuple churn that _does_ happen (*nudge nudge*, pg_autovacuum could be integrated into the backend to handle this). Those worried about performance, the pages that are constantly being recycled would likely stay in disk cache (PG or the OS). There's still some commit overhead, but still... no need to over optimize by requiring the table to be stored in the out dated, slow, and over used shm (also, *nudge nudge*). Anyway, let me throw that out there as a solution that I use and it works quite well. I didn't explain the use of the qual column, but I think those who grasp the above way of handling things probably grok how to use the qual column in a dynamically executed query. CREATE AGGREGATE CACHE anyone? -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Oct 6 15:00:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F5A4D1B4FF for ; Mon, 6 Oct 2003 17:59:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 16003-03 for ; Mon, 6 Oct 2003 14:59:09 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 400BCD1B523 for ; Mon, 6 Oct 2003 14:58:53 -0300 (ADT) Received: (qmail 53603 invoked from network); 6 Oct 2003 17:58:58 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 6 Oct 2003 17:58:58 -0000 Date: Mon, 6 Oct 2003 13:58:57 -0400 (EDT) From: Jeff To: pgsql-performance@postgresql.org Subject: SOlaris updates 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: 200310/183 X-Sequence-Number: 3931 Ran the test on another linux box - the one that generated the dump the sun loaded (which should have similar data...) and I got a profile plan similar to the Sun. Which makes me feel more comfortable. Still interesting why that other box gave me the different profile. Now off the fun and exciting world of seeing what I can do about it. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 6 15:17:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6A7EDD1B554 for ; Mon, 6 Oct 2003 18:17:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 15562-10 for ; Mon, 6 Oct 2003 15:17:00 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id B691ED1B54D for ; Mon, 6 Oct 2003 15:14:50 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 48E071F24; Mon, 6 Oct 2003 14:14:34 -0400 (EDT) Subject: Re: reindex/vacuum locking/performance? From: Neil Conway To: Tom Lane Cc: Andrew Sullivan , PostgreSQL Performance In-Reply-To: <1065397835.471.17.camel@tokyo> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> <15813.1065397428@sss.pgh.pa.us> <1065397835.471.17.camel@tokyo> Content-Type: text/plain Message-Id: <1065464069.473.31.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 06 Oct 2003 14:14:29 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/184 X-Sequence-Number: 3932 On Sun, 2003-10-05 at 19:50, Neil Conway wrote: > On Sun, 2003-10-05 at 19:43, Tom Lane wrote: > > This would be relatively easy to fix as far as our own buffering is > > concerned, but the thing that's needed to make it really useful is > > to prevent caching of seqscan-read pages in the kernel disk buffers. > For the non-portable way of doing this, are you referring to O_DIRECT? I was hoping you'd reply to this, Tom -- you were referring to O_DIRECT, right? (If you were referring to O_DIRECT, I wanted to add that I wouldn't be surprised if using O_DIRECT on many kernels reduces or eliminates any readahead the OS will be doing on the sequential read, so the net result may actually be a loss for a typical seqscan.) -Neil From pgsql-performance-owner@postgresql.org Mon Oct 6 15:24:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DE351D1B4E9 for ; Mon, 6 Oct 2003 18:24:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25151-01 for ; Mon, 6 Oct 2003 15:23:16 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id C9E1FD1B4FF for ; Mon, 6 Oct 2003 15:23:14 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3732902; Mon, 06 Oct 2003 11:23:51 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Stef Subject: Re: Postgres low end processing. Date: Mon, 6 Oct 2003 11:21:20 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> <20031006095551.1d7bfeb8.svb@ucs.co.za> In-Reply-To: <20031006095551.1d7bfeb8.svb@ucs.co.za> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310061121.20681.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/185 X-Sequence-Number: 3933 Stef, > =3D> 1. Make sure that the WAL files (pg_xlog) are on a seperate disk fro= m the=20 > =3D> database files, either through mounting or symlinking. >=20=20 > I'm not sure I understand how this helps? It gives you better fsync write performance on a low-end disk setup.=20=20= =20 Otherwise, the disk is forced to do a hop-back-and-forth between the databa= se=20 and the xlog, resulting in much slower updates and thus the database tying = up=20 blocks of RAM longer -- particularly if your shared_buffers are set very lo= w,=20 which they will be. On RAID setups, this is unnecessary becuase the RAID takes care of disk acc= ess=20 management. But on a low-end, 2-IDE-disk machine, you have to do it. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 6 15:27:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 50E02D1B4F6 for ; Mon, 6 Oct 2003 18:26:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25267-01 for ; Mon, 6 Oct 2003 15:26:13 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id EBA8DD1B52E for ; Mon, 6 Oct 2003 15:26:11 -0300 (ADT) 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 h96IQAhn029924; Mon, 6 Oct 2003 14:26:11 -0400 (EDT) To: Neil Conway Cc: Andrew Sullivan , PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? In-reply-to: <1065464069.473.31.camel@tokyo> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> <15813.1065397428@sss.pgh.pa.us> <1065397835.471.17.camel@tokyo> <1065464069.473.31.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Mon, 06 Oct 2003 14:14:29 -0400" Date: Mon, 06 Oct 2003 14:26:10 -0400 Message-ID: <29923.1065464770@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/186 X-Sequence-Number: 3934 Neil Conway writes: > On Sun, 2003-10-05 at 19:50, Neil Conway wrote: > I was hoping you'd reply to this, Tom -- you were referring to O_DIRECT, > right? Not necessarily --- as you point out, it's not clear that O_DIRECT would help us. What would be way cool is something similar to what James Rogers was talking about: a way to tell the kernel not to promote this page all the way to the top of its LRU list. I'm not sure that *any* Unixen have such an API, let alone one that's common across more than one platform :-( regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 6 15:40:21 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8ECC4D1B523 for ; Mon, 6 Oct 2003 18:40:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24843-07 for ; Mon, 6 Oct 2003 15:39:31 -0300 (ADT) Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) by svr1.postgresql.org (Postfix) with ESMTP id 00F46D1B4E9 for ; Mon, 6 Oct 2003 15:39:30 -0300 (ADT) Received: from lerlaptop-red.iadfw.net (lerlaptop.iadfw.net [206.66.13.21]) (authenticated bits=0) by lerami.lerctr.org (8.12.10/8.12.10/20030923) with ESMTP id h96IdBHI025709; Mon, 6 Oct 2003 13:39:11 -0500 (CDT) Date: Mon, 06 Oct 2003 13:39:10 -0500 From: Larry Rosenman To: Tom Lane , Neil Conway Cc: Andrew Sullivan , PostgreSQL Performance Subject: Re: reindex/vacuum locking/performance? Message-ID: <326160000.1065465550@lerlaptop-red.iadfw.net> In-Reply-To: <29923.1065464770@sss.pgh.pa.us> References: <60d6de9fah.fsf@dev6.int.libertyrms.info> <20031004152241.GL580@libertyrms.info> <1065396767.466.12.camel@tokyo> <15813.1065397428@sss.pgh.pa.us> <1065397835.471.17.camel@tokyo> <1065464069.473.31.camel@tokyo> <29923.1065464770@sss.pgh.pa.us> X-Mailer: Mulberry/3.1.0b8 (Linux/x86) X-PGP-Info: All other keys are old/dead. X-PGP-Key: 0x3c49bdd6 X-PGP-Fingerprint: D0D1 3C11 F42F 6B29 FA67 6BF3 AD13 4685 3C49 BDD6 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="==========9B010721BDBBC20A16F6==========" X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/187 X-Sequence-Number: 3935 --==========9B010721BDBBC20A16F6========== Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline --On Monday, October 06, 2003 14:26:10 -0400 Tom Lane = =20 wrote: > Neil Conway writes: >> On Sun, 2003-10-05 at 19:50, Neil Conway wrote: >> I was hoping you'd reply to this, Tom -- you were referring to O_DIRECT, >> right? > > Not necessarily --- as you point out, it's not clear that O_DIRECT would > help us. What would be way cool is something similar to what James > Rogers was talking about: a way to tell the kernel not to promote this > page all the way to the top of its LRU list. I'm not sure that *any* > Unixen have such an API, let alone one that's common across more than > one platform :-( I think Verita's VxFS has this as an option/IOCTL. You can read the Veritas doc on my http://www.lerctr.org:8458/ pages under filesystems. That should work on UnixWare and Solaris sites that have VxFS installed. VxFS is standard on UW. LER --=20 Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 --==========9B010721BDBBC20A16F6========== Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD4DBQE/gbbOrRNGhTxJvdYRAk9uAKCHI0Wh9rWaDc3d8pYXYm8eYcICrACYoVyS iwo0PZIhIGrZ/BVHY2s5Dg== =byTT -----END PGP SIGNATURE----- --==========9B010721BDBBC20A16F6==========-- From pgsql-performance-owner@postgresql.org Mon Oct 6 15:58:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2EC16D1B506 for ; Mon, 6 Oct 2003 18:58:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25267-09 for ; Mon, 6 Oct 2003 15:57:20 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 07856D1B4E9 for ; Mon, 6 Oct 2003 15:57:17 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h96IuxO13756; Mon, 6 Oct 2003 14:56:59 -0400 (EDT) From: Bruce Momjian Message-Id: <200310061856.h96IuxO13756@candle.pha.pa.us> Subject: Re: reindex/vacuum locking/performance? In-Reply-To: <29923.1065464770@sss.pgh.pa.us> To: Tom Lane Date: Mon, 6 Oct 2003 14:56:59 -0400 (EDT) Cc: Neil Conway , Andrew Sullivan , PostgreSQL Performance X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/188 X-Sequence-Number: 3936 Tom Lane wrote: > Neil Conway writes: > > On Sun, 2003-10-05 at 19:50, Neil Conway wrote: > > I was hoping you'd reply to this, Tom -- you were referring to O_DIRECT, > > right? > > Not necessarily --- as you point out, it's not clear that O_DIRECT would > help us. What would be way cool is something similar to what James > Rogers was talking about: a way to tell the kernel not to promote this > page all the way to the top of its LRU list. I'm not sure that *any* > Unixen have such an API, let alone one that's common across more than > one platform :-( Solaris has "free-behind", which prevents a large kernel sequential scan from blowing out the cache. I only read about it in the Mauro Solaris Internals book, and it seems to be done automatically. I guess most OS's don't do this optimization because they usually don't read files larger than their cache. I see BSD/OS madvise() has: #define MADV_NORMAL 0 /* no further special treatment */ #define MADV_RANDOM 1 /* expect random page references */ #define MADV_SEQUENTIAL 2 /* expect sequential references */ #define MADV_WILLNEED 3 /* will need these pages */ --> #define MADV_DONTNEED 4 /* don't need these pages */ #define MADV_SPACEAVAIL 5 /* insure that resources are reserved */ The marked one seems to have the control we need. Of course, the kernel madvise() code has: /* Not yet implemented */ Looks like NetBSD implements it, but it also unmaps the page from the address space, which might be more than we want. NetBSD alao has: #define MADV_FREE 6 /* pages are empty, free them */ which frees the page. I am unclear on its us. FreeBSD has this comment: /* * vm_page_dontneed * * Cache, deactivate, or do nothing as appropriate. This routine * is typically used by madvise() MADV_DONTNEED. * * Generally speaking we want to move the page into the cache so * it gets reused quickly. However, this can result in a silly syndrome * due to the page recycling too quickly. Small objects will not be * fully cached. On the otherhand, if we move the page to the inactive * queue we wind up with a problem whereby very large objects * unnecessarily blow away our inactive and cache queues. * * The solution is to move the pages based on a fixed weighting. We * either leave them alone, deactivate them, or move them to the cache, * where moving them to the cache has the highest weighting. * By forcing some pages into other queues we eventually force the * system to balance the queues, potentially recovering other unrelated * space from active. The idea is to not force this to happen too * often. */ The Linux comment is: /* * Application no longer needs these pages. If the pages are dirty, * it's OK to just throw them away. The app will be more careful about * data it wants to keep. Be sure to free swap resources too. The * zap_page_range call sets things up for refill_inactive to actually free * these pages later if no one else has touched them in the meantime, * although we could add these pages to a global reuse list for * refill_inactive to pick up before reclaiming other pages. * * NB: This interface discards data rather than pushes it out to swap, * as some implementations do. This has performance implications for * applications like large transactional databases which want to discard * pages in anonymous maps after committing to backing store the data * that was kept in them. There is no reason to write this data out to * the swap area if the application is discarding it. * * An interface that causes the system to free clean pages and flush * dirty pages is already available as msync(MS_INVALIDATE). */ It seems mmap is more for controlling the memory mapping of files rather than controlling the cache itself. -- 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 Oct 6 16:15:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DBCFAD1B4F2 for ; Mon, 6 Oct 2003 19:15:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 27083-10 for ; Mon, 6 Oct 2003 16:14:40 -0300 (ADT) Received: from chimta03.algx.net (mta8.algx.net [67.92.168.237]) by svr1.postgresql.org (Postfix) with ESMTP id 95C24D1B4E9 for ; Mon, 6 Oct 2003 16:14:38 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx03.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMC0027QO4E3T@chimmx03.algx.net> for pgsql-performance@postgresql.org; Mon, 06 Oct 2003 14:14:39 -0500 (CDT) Date: Mon, 06 Oct 2003 15:14:38 -0400 From: Jason Hihn Subject: Re: reindex/vacuum locking/performance? In-reply-to: <29923.1065464770@sss.pgh.pa.us> To: Tom Lane , Neil Conway Cc: Andrew Sullivan , PostgreSQL Performance Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/189 X-Sequence-Number: 3937 Stepping out on a limb... (I'm not a disk kernel guy) I have long thought that as part of a cache descriptor, there should be a process-definable replacement-strategy (RS). Each cache entry would be associated to each process's replacement-strategy variable and the page-replacement algorithm would then take into consideration the desired policy. Imagine for simplicity sake, that each strategy gets its own cache table. When it comes time to replace a page, the system scans the cache tables, picks the most likely page for replacement from each table, then selects the most likely page between all policies. This allows the 99% of apps that can make excellent use of use LRU to use LRU among themselves (best for everyone), and the MRU (better for databases) (best for everyone too) to only sacrifice the best pages between MRU apps. Though, once you have an MRU process, the final decision between taking the page should be use MRU, and not LRU. Of course there are a number of questions: does each RS get its own table, to be managed independently, or can we combine them all into one table? What are the performance implications of the multiple table management? One day, I'd like to see function pointers and kernel modules used as ways for apps to manage replacement policy. fantasyland# insmod MRU.o fantasyland# vi postgresql.conf { replacement_policy=MRU } {meanwhile in some postgre .c file:} set_cache_policy(get_cfg_replacement_policy()); fantasyland# service postmaster restart Anyone want to throw this at the kernel developers? > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Tom Lane > Sent: Monday, October 06, 2003 2:26 PM > To: Neil Conway > Cc: Andrew Sullivan; PostgreSQL Performance > Subject: Re: [PERFORM] reindex/vacuum locking/performance? > > > Neil Conway writes: > > On Sun, 2003-10-05 at 19:50, Neil Conway wrote: > > I was hoping you'd reply to this, Tom -- you were referring to O_DIRECT, > > right? > > Not necessarily --- as you point out, it's not clear that O_DIRECT would > help us. What would be way cool is something similar to what James > Rogers was talking about: a way to tell the kernel not to promote this > page all the way to the top of its LRU list. I'm not sure that *any* > Unixen have such an API, let alone one that's common across more than > one platform :-( > > regards, tom lane > > ---------------------------(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 Tue Oct 7 12:29:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 20D8ED1B4F4 for ; Tue, 7 Oct 2003 15:29:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 36073-07 for ; Tue, 7 Oct 2003 12:28:34 -0300 (ADT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4A6DBD1B500 for ; Tue, 7 Oct 2003 12:28:33 -0300 (ADT) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id AEDD42BD95 for ; Tue, 7 Oct 2003 17:28:28 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id B29ECD9F17 for ; Tue, 7 Oct 2003 17:28:28 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id 021CC976E3 for ; Tue, 7 Oct 2003 17:28:28 +0200 (SAST) Date: Tue, 7 Oct 2003 17:28:22 +0200 From: Stef To: pg-perform Subject: Re: Postgres low end processing. Message-Id: <20031007172822.59df027d.svb@ucs.co.za> In-Reply-To: <20031006095551.1d7bfeb8.svb@ucs.co.za> References: <20031003163040.3641f39a.svb@ucs.co.za> <200310031108.49002.josh@agliodbs.com> <20031006095551.1d7bfeb8.svb@ucs.co.za> X-Mailer: Sylpheed version 0.9.5claws28 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: LV^-*d3kQlL,6{Y:X)M~tuL#y!p.kO_Qbc!xxqhZC4s}Y]L0g)z^aiLsQGY34d|}Xp:HNm)MRsc?^?ZQ}smznF&jx|w@,a**K&QL.Dc~2~M5V`zb>hExCJDB[[o=M)e"; k-n[7tz2TY7+; *_xX's(5cUEtdw*yG-OmKm}6($zpUz8S`Nz@w X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Tue__7_Oct_2003_17_28_22_+0200_g7OKzaPf8NELWA29" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/192 X-Sequence-Number: 3940 --Signature=_Tue__7_Oct_2003_17_28_22_+0200_g7OKzaPf8NELWA29 Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Hi again all, I've tested postgres 7.3.4 on Linux version 2.4.17 and this is what I found : The initial instance took up 8372K and this fluctuated between +- 8372K and 10372K, plus +- 3500K for every connection. I did quite a few transactions on both connections, plus a few vacuums and a pg_dump and the total memory usage didn't seem to go over 16M I set all the _buffers, _mem, _fsm settings to the minimum, restarted every time, but this had absolutely no noticeable increase or decrease in total memory usage. (I used a program called gmemusage to get these stats.) On the same machine , I tested postgres 7.1.2 with basically the same conf options (not _fsm) and got the following : The initial instance was 1772K and fluctuated to +- 4000K, plus +- 3400K for every connection. Doing the same transactions, vacuum + pg_dump, total memory usage didn't really go over 11M, which was exactly what I needed. Although I've lived through some of the shortcomings of 7.1.2, it is still very stable, and works perfectly for what it is going to be used for. Again, here, I was only able to restrict things a little by changing the configuration options, but no major difference in memory usage. Regards Stef On Mon, 6 Oct 2003 09:55:51 +0200 Stef wrote: => Thanks for the replies, => => On Fri, 3 Oct 2003 11:08:48 -0700 => Josh Berkus wrote: => => 1. Make sure that the WAL files (pg_xlog) are on a seperate disk from the => => database files, either through mounting or symlinking. => => I'm not sure I understand how this helps? => => => 2. Tweak the .conf file for low vacuum_mem (1024?), but vacuum very => => frequently, like every 1-5 minutes. Spend some time tuning your => => fsm_max_pages to the ideal level so that you're not allocating any extra => => memory to the FSM. => => => => 3. If your concern is *average* CPU/RAM consumption, and not peak load => => activity, increase wal_files and checkpoint_segments to do more efficient => => batch processing of pending updates as the cost of some disk space. If peak => => load activity is a problem, don't do this. => => => => 4. Tune all of your queries carefully to avoid anything requiring a => => RAM-intensive merge join or CPU-eating calculated expression hash join, or => => similar computation-or-RAM-intensive operations. => => Thanks, I'll try some of these, and post the results. => The actual machines seem to be Pentium I machines, => with 32M RAM. I've gathered that it is theoretically => possible, so no to go try it. => => Regards => Stef => --Signature=_Tue__7_Oct_2003_17_28_22_+0200_g7OKzaPf8NELWA29 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/gtubgDYs3UkRjZkRAhfEAJ4vWSOLjAc/n3sjeyfNfJJ17aYVjACeMMI1 V0y7yzdoFIJb85J9dv+ADPA= =SSHs -----END PGP SIGNATURE----- --Signature=_Tue__7_Oct_2003_17_28_22_+0200_g7OKzaPf8NELWA29-- From pgsql-performance-owner@postgresql.org Tue Oct 7 12:41:04 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0646CD1B500 for ; Tue, 7 Oct 2003 15:41:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 39449-01 for ; Tue, 7 Oct 2003 12:40:14 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id B98F5D1B4ED for ; Tue, 7 Oct 2003 12:39:58 -0300 (ADT) Received: (qmail 57932 invoked from network); 7 Oct 2003 15:40:01 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 7 Oct 2003 15:40:01 -0000 Date: Tue, 7 Oct 2003 11:40:01 -0400 (EDT) From: Jeff To: Stef Cc: pg-perform Subject: Re: Postgres low end processing. In-Reply-To: <20031007172822.59df027d.svb@ucs.co.za> 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: 200310/193 X-Sequence-Number: 3941 On Tue, 7 Oct 2003, Stef wrote: > The initial instance took up 8372K and this fluctuated > between +- 8372K and 10372K, plus +- 3500K for > every connection. > Does that include/exlude the size of say, shared code & libraries? I know linux does copy-on-write forking.. so it may be less in reality... -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 7 15:37:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 46465D1B547 for ; Tue, 7 Oct 2003 18:35:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 69264-09 for ; Tue, 7 Oct 2003 15:34:55 -0300 (ADT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id CA8CAD1B4EF for ; Tue, 7 Oct 2003 15:34:51 -0300 (ADT) Received: from localhost (build.pdx.osdl.net [172.20.1.2]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h97IYX103123; Tue, 7 Oct 2003 11:34:33 -0700 Subject: Re: TPC-R benchmarks From: "Timothy D. Witham" To: Jenny Zhang Cc: Oleg Lebedev , pgsql-performance@postgresql.org, osdldbt-general@lists.courceforge.net In-Reply-To: <1064525555.2082.39.camel@ibm-a.pdx.osdl.net> References: <993DBE5B4D02194382EC8DF8554A52731D75CD@postoffice.waterford.org> <1064525555.2082.39.camel@ibm-a.pdx.osdl.net> Content-Type: text/plain Organization: Open Source Development Lab, Inc. Message-Id: <1065551673.1376.88.camel@wookie-t23> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Tue, 07 Oct 2003 11:34:33 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/194 X-Sequence-Number: 3942 On Thu, 2003-09-25 at 14:32, Jenny Zhang wrote: > I am running TPC-H with scale factor of 1 on RedHat7.2 with the kernel > 2.5.74. Q17 can always finish in about 7 seconds on my system. The > execution plan is: I just want to point out that we are the OSDL are not running a TPC-X anything. We have fair use implementations of these benchmarks but because of differences our performance tests can not be compared with the TPCC's benchmark results. > ---------------------------------------------------------------------------------------------------- > Aggregate (cost=780402.43..780402.43 rows=1 width=48) > -> Nested Loop (cost=0.00..780397.50 rows=1973 width=48) > Join Filter: ("inner".l_quantity < (subplan)) > -> Seq Scan on part (cost=0.00..8548.00 rows=197 width=12) > Filter: ((p_brand = 'Brand#31'::bpchar) AND (p_container > = 'LG CASE'::bpchar)) > -> Index Scan using i_l_partkey on lineitem > (cost=0.00..124.32 rows=30 width=36) > Index Cond: ("outer".p_partkey = lineitem.l_partkey) > SubPlan > -> Aggregate (cost=124.40..124.40 rows=1 width=11) > -> Index Scan using i_l_partkey on lineitem > (cost=0.00..124.32 rows=30 width=11) > Index Cond: (l_partkey = $0) > (11 rows) > > Hope this helps, > Jenny > On Thu, 2003-09-25 at 12:40, Oleg Lebedev wrote: > > I am running TPC-R benchmarks with a scale factor of 1, which correspond > > to approximately 1 GB database size on PostgreSQL 7.3.4 installed on > > CygWin on Windows XP. I dedicated 128 MB of shared memory to my postrges > > installation. > > Most of the queries were able to complete in a matter of minutes, but > > query 17 was taking hours and hours. The query is show below. Is there > > any way to optimize it ? > > > > select > > sum(l_extendedprice) / 7.0 as avg_yearly > > from > > lineitem, > > part > > where > > p_partkey = l_partkey > > and p_brand = 'Brand#11' > > and p_container = 'SM PKG' > > and l_quantity < ( > > select > > 0.2 * avg(l_quantity) > > from > > lineitem > > where > > l_partkey = p_partkey > > ); > > > > Thanks. > > > > Oleg > > > > ************************************* > > > > This e-mail may contain privileged or confidential material intended for the named recipient only. > > If you are not the named recipient, delete this message and all attachments. > > Unauthorized reviewing, copying, printing, disclosing, or otherwise using information in this e-mail is prohibited. > > We reserve the right to monitor e-mail sent through our network. > > > > ************************************* > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Timothy D. Witham - Lab Director - wookie@osdlab.org Open Source Development Lab Inc - A non-profit corporation 12725 SW Millikan Way - Suite 400 - Beaverton OR, 97005 (503)-626-2455 x11 (office) (503)-702-2871 (cell) (503)-626-2436 (fax) From pgsql-performance-owner@postgresql.org Tue Oct 7 21:02:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2A933D1B515 for ; Wed, 8 Oct 2003 00:02:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24912-06 for ; Tue, 7 Oct 2003 21:01:14 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 63117D1B527 for ; Tue, 7 Oct 2003 21:01:10 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3738819; Tue, 07 Oct 2003 17:01:48 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Oleg Lebedev , Tom Lane Subject: Re: TPC-R benchmarks Date: Tue, 7 Oct 2003 16:59:17 -0700 User-Agent: KMail/1.4.3 References: <993DBE5B4D02194382EC8DF8554A52731D7661@postoffice.waterford.org> In-Reply-To: <993DBE5B4D02194382EC8DF8554A52731D7661@postoffice.waterford.org> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310071659.17863.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/195 X-Sequence-Number: 3943 Tom, I've found the problem with TPC-R query #19. And it, unfortunately, appear= s=20 to be a problem in the PostgreSQL query planner. To sum up the below: it appears that whenever a set of WHERE conditions=20 exceeds a certain level of complexity, the planner just ignores all=20 applicable indexes and goes for a seq scan. While this may be unavoidable= =20 to some degree, it seems to me that we need to raise the threshold of=20 complexity at which it does this. tpcr=3D# select version(); version ---------------------------------------------------------------------------= ------------------------------ PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3 20030= 226=20 (prerelease) (SuSE Linux) (1 row) I've tested a number of indexes on the query, and found the two most effici= ent=20 on subsets of the query. Thus: explain analyze select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey =3D l_partkey and p_brand =3D 'Brand#33' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >=3D 8 and l_quantity <=3D 8 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------- Aggregate (cost=3D10380.70..10380.70 rows=3D1 width=3D30) (actual=20 time=3D161.61..161.61 rows=3D1 loops=3D1) -> Nested Loop (cost=3D0.00..10380.67 rows=3D13 width=3D30) (actual=20 time=3D81.54..161.47 rows=3D17 loops=3D1) -> Index Scan using idx_part_1 on part (cost=3D0.00..9466.33 row= s=3D62=20 width=3D4) (actual time=3D81.21..137.24 rows=3D98 loops=3D1) Index Cond: (p_brand =3D 'Brand#33'::bpchar) Filter: (((p_container =3D 'SM CASE'::bpchar) OR (p_containe= r =3D=20 'SM BOX'::bpchar) OR (p_container =3D 'SM PACK'::bpchar) OR (p_container = =3D 'SM=20 PKG'::bpchar)) AND (p_size >=3D 1) AND (p_size <=3D 5)) -> Index Scan using idx_lineitem_3 on lineitem (cost=3D0.00..14.= 84=20 rows=3D1 width=3D26) (actual time=3D0.22..0.24 rows=3D0 loops=3D98) Index Cond: (("outer".p_partkey =3D lineitem.l_partkey) AND= =20 (lineitem.l_quantity >=3D 8::numeric) AND (lineitem.l_quantity <=3D 18::num= eric)) Filter: (((l_shipmode =3D 'AIR'::bpchar) OR (l_shipmode =3D = 'AIR=20 REG'::bpchar)) AND (l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) Total runtime: 161.71 msec This also works for a similar query: explain analyze select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey =3D l_partkey and p_brand =3D 'Brand#52' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >=3D 14 and l_quantity <=3D 14 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ); Aggregate (cost=3D11449.36..11449.36 rows=3D1 width=3D30) (actual=20 time=3D195.72..195.72 rows=3D1 loops=3D1) -> Nested Loop (cost=3D0.00..11449.29 rows=3D28 width=3D30) (actual=20 time=3D56.42..195.39 rows=3D48 loops=3D1) -> Index Scan using idx_part_1 on part (cost=3D0.00..9466.33 row= s=3D139=20 width=3D4) (actual time=3D56.15..153.17 rows=3D166 loops=3D1) Index Cond: (p_brand =3D 'Brand#52'::bpchar) Filter: (((p_container =3D 'MED BAG'::bpchar) OR (p_containe= r =3D=20 'MED BOX'::bpchar) OR (p_container =3D 'MED PKG'::bpchar) OR (p_container = =3D=20 'MED PACK'::bpchar)) AND (p_size >=3D 1) AND (p_size <=3D 10)) -> Index Scan using idx_lineitem_3 on lineitem (cost=3D0.00..14.= 29=20 rows=3D1 width=3D26) (actual time=3D0.23..0.25 rows=3D0 loops=3D166) Index Cond: (("outer".p_partkey =3D lineitem.l_partkey) AND= =20 (lineitem.l_quantity >=3D 14::numeric) AND (lineitem.l_quantity <=3D=20 24::numeric)) Filter: (((l_shipmode =3D 'AIR'::bpchar) OR (l_shipmode =3D = 'AIR=20 REG'::bpchar)) AND (l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) Total runtime: 195.82 msec (9 rows) If, however, I combine the two where clauses with an OR, the planner gets= =20 confused and insists on loading the entire tables into memory (even though = I=20 don't have that much memory): explain select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey =3D l_partkey and p_brand =3D 'Brand#33' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >=3D 8 and l_quantity <=3D 8 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ) or ( p_partkey =3D l_partkey and p_brand =3D 'Brand#52' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >=3D 14 and l_quantity <=3D 14 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct =3D 'DELIVER IN PERSON' ); Aggregate (cost=3D488301096525.25..488301096525.25 rows=3D1 width=3D146) -> Nested Loop (cost=3D0.00..488301096525.15 rows=3D42 width=3D146) Join Filter: ((("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'SM CASE'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#33'::bpchar) AND=20 ("outer".l_quantity >=3D 8::numeric) AND ("outer".l_quantity <=3D 18::numer= ic)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 5) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'S= M=20 CASE'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#33'::bpchar) AND ("outer".l_quantity >=3D 8::nu= meric)=20 AND ("outer".l_quantity <=3D 18::numeric) AND ("inner".p_size >=3D 1) AND= =20 ("inner".p_size <=3D 5) AND ("outer".l_shipinstruct =3D 'DELIVER IN=20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'SM BOX'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#33'::bpchar) AND=20 ("outer".l_quantity >=3D 8::numeric) AND ("outer".l_quantity <=3D 18::numer= ic)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 5) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'S= M=20 BOX'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#33'::bpchar) AND ("outer".l_quantity >=3D 8::nu= meric)=20 AND ("outer".l_quantity <=3D 18::numeric) AND ("inner".p_size >=3D 1) AND= =20 ("inner".p_size <=3D 5) AND ("outer".l_shipinstruct =3D 'DELIVER IN=20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'SM PACK'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#33'::bpchar) AND=20 ("outer".l_quantity >=3D 8::numeric) AND ("outer".l_quantity <=3D 18::numer= ic)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 5) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'S= M=20 PACK'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#33'::bpchar) AND ("outer".l_quantity >=3D 8::nu= meric)=20 AND ("outer".l_quantity <=3D 18::numeric) AND ("inner".p_size >=3D 1) AND= =20 ("inner".p_size <=3D 5) AND ("outer".l_shipinstruct =3D 'DELIVER IN=20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'SM PKG'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#33'::bpchar) AND=20 ("outer".l_quantity >=3D 8::numeric) AND ("outer".l_quantity <=3D 18::numer= ic)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 5) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'S= M=20 PKG'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#33'::bpchar) AND ("outer".l_quantity >=3D 8::nu= meric)=20 AND ("outer".l_quantity <=3D 18::numeric) AND ("inner".p_size >=3D 1) AND= =20 ("inner".p_size <=3D 5) AND ("outer".l_shipinstruct =3D 'DELIVER IN=20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'MED BAG'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#52'::bpchar) AND=20 ("outer".l_quantity >=3D 14::numeric) AND ("outer".l_quantity <=3D 24::nume= ric)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 10) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'M= ED=20 BAG'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#52'::bpchar) AND ("outer".l_quantity >=3D=20 14::numeric) AND ("outer".l_quantity <=3D 24::numeric) AND ("inner".p_size = >=3D=20 1) AND ("inner".p_size <=3D 10) AND ("outer".l_shipinstruct =3D 'DELIVER IN= =20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'MED BOX'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#52'::bpchar) AND=20 ("outer".l_quantity >=3D 14::numeric) AND ("outer".l_quantity <=3D 24::nume= ric)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 10) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'M= ED=20 BOX'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#52'::bpchar) AND ("outer".l_quantity >=3D=20 14::numeric) AND ("outer".l_quantity <=3D 24::numeric) AND ("inner".p_size = >=3D=20 1) AND ("inner".p_size <=3D 10) AND ("outer".l_shipinstruct =3D 'DELIVER IN= =20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'MED PKG'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#52'::bpchar) AND=20 ("outer".l_quantity >=3D 14::numeric) AND ("outer".l_quantity <=3D 24::nume= ric)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 10) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'M= ED=20 PKG'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#52'::bpchar) AND ("outer".l_quantity >=3D=20 14::numeric) AND ("outer".l_quantity <=3D 24::numeric) AND ("inner".p_size = >=3D=20 1) AND ("inner".p_size <=3D 10) AND ("outer".l_shipinstruct =3D 'DELIVER IN= =20 PERSON'::bpchar)) OR (("outer".l_shipmode =3D 'AIR'::bpchar) AND=20 ("inner".p_container =3D 'MED PACK'::bpchar) AND ("inner".p_partkey =3D=20 "outer".l_partkey) AND ("inner".p_brand =3D 'Brand#52'::bpchar) AND=20 ("outer".l_quantity >=3D 14::numeric) AND ("outer".l_quantity <=3D 24::nume= ric)=20 AND ("inner".p_size >=3D 1) AND ("inner".p_size <=3D 10) AND=20 ("outer".l_shipinstruct =3D 'DELIVER IN PERSON'::bpchar)) OR=20 (("outer".l_shipmode =3D 'AIR REG'::bpchar) AND ("inner".p_container =3D 'M= ED=20 PACK'::bpchar) AND ("inner".p_partkey =3D "outer".l_partkey) AND=20 ("inner".p_brand =3D 'Brand#52'::bpchar) AND ("outer".l_quantity >=3D=20 14::numeric) AND ("outer".l_quantity <=3D 24::numeric) AND ("inner".p_size = >=3D=20 1) AND ("inner".p_size <=3D 10) AND ("outer".l_shipinstruct =3D 'DELIVER IN= =20 PERSON'::bpchar))) -> Seq Scan on lineitem (cost=3D0.00..235620.15 rows=3D6001215= =20 width=3D95) -> Seq Scan on part (cost=3D0.00..7367.00 rows=3D200000 width=3D= 51) You'll pardon me for not doing an "ANALYZE", but I didn't want to wait=20 overnight. Manually disabling Seqscan and Nestloop did nothing to affect= =20 this query plan; neither did removing the aggregate. Tommorrow I will test 7.4 Beta 4. How can we fix this? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 01:16:49 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5C5FED1B570 for ; Wed, 8 Oct 2003 04:16:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66736-07 for ; Wed, 8 Oct 2003 01:16:02 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id A751AD1B57F for ; Wed, 8 Oct 2003 01:16:00 -0300 (ADT) 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 h984Fvhn029372; Wed, 8 Oct 2003 00:15:58 -0400 (EDT) To: josh@agliodbs.com Cc: Oleg Lebedev , pgsql-performance@postgresql.org Subject: Re: TPC-R benchmarks In-reply-to: <200310071659.17863.josh@agliodbs.com> References: <993DBE5B4D02194382EC8DF8554A52731D7661@postoffice.waterford.org> <200310071659.17863.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Tue, 07 Oct 2003 16:59:17 -0700" Date: Wed, 08 Oct 2003 00:15:57 -0400 Message-ID: <29371.1065586557@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/196 X-Sequence-Number: 3944 Josh Berkus writes: > To sum up the below: it appears that whenever a set of WHERE conditions > exceeds a certain level of complexity, the planner just ignores all > applicable indexes and goes for a seq scan. It looks to me like the planner is coercing the WHERE clause into canonical OR-of-ANDs form (DNF). Which is often a good heuristic but it seems unhelpful for this query. > How can we fix this? Feel free to propose improvements to the heuristics in src/backend/optimizer/prep/prepqual.c ... regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 8 09:38:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C50E9D1B4F8 for ; Wed, 8 Oct 2003 12:38:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51583-01 for ; Wed, 8 Oct 2003 09:37:18 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 430EDD1B4E2 for ; Wed, 8 Oct 2003 09:36:50 -0300 (ADT) Received: (qmail 62619 invoked from network); 8 Oct 2003 12:36:56 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 12:36:56 -0000 Date: Wed, 8 Oct 2003 08:36:56 -0400 (EDT) From: Jeff To: pgsql-performance@postgresql.org Subject: Sun performance - Major discovery! 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: 200310/197 X-Sequence-Number: 3945 Well, as you guys know I've been tinkering with sun-vs-linux postgres for a while trying to come up with reasons for the HUGE performance differences. We've all had our anecdotal thoughts (fork sucks, ipc sucks, ufs sucks, etc) and I've had a breakthrough. Knowing that GCC only produces good code on x86 (and powerpc with apple's mods, but it is doubtful that is as good as ibm's power compiler) I decided to try out Sunsoft CC. I'd heard from more than one person/place that gcc makes abysmal sparc code. Given that the performance profiles for both the linux and sun boxes showed the same functions taking up most of the time I thought I'd see what a difference sunsoft could give me. So - hardware - Sun E450 4x400mhz ultrasparc IIi, 4GB ram, scsi soemthing disk. (not raid) solaris 2.6 Linux - 2xP3 500mhz, 2GB, scsi disk of some flavor (not raid) linux 2.2.17 (old I know!) So here's the results using my load tester (single connection per beater, repeats the query 1000 times with different input each time (we'll get ~20k rows back), the query is a common query around here. I discounted the first run of the test as caches populated. Linux - 1x - 35 seconds, 20x - 180 seconds Sun - gcc - 1x 60 seconds 20x 245 seconds Sun - sunsoft defaults - 1x 52 seonds 20x [similar to gcc most likely] Sun - sunsoft -fast - 1x 28 seconds 20x 164 seconds As you math guru's can probably deduce - that is a rather large improvement. And by rather large I mean hugely significant. With results like this, I think it warrants mentioning in the FAQ_Solaris, and probably the performance guide. Connecting will always be a bit slower. But I think most people realize that connecting to a db is not cheap. I think update/etc will cause more locking, but I think IO will become the bottle neck much sooner than lock/unlock will. (This is mostly anecdotal given how fast solaris can lock/unlock a semaphore and how much IO I know I have) Oh yes, with was with 7.3.4 and sunsoft cc Sun WorkShop 6 update 1 C 5.2 2000/09/11 (which is old, perhaps newer ones make even better code?) I'm not sure of PG's policy of non-gcc things in configure, but perhaps if we detect sunsoft we toss in the -fast flag and maybe make it the preferred one on sun? [btw, it compiled with no changes but it did spew out tons of warnings] comments? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 10:17:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA8C1D1B4F6 for ; Wed, 8 Oct 2003 13:17:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50830-10 for ; Wed, 8 Oct 2003 10:17:02 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id BF3E5D1B517 for ; Wed, 8 Oct 2003 10:16:55 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h98DGr4r026403 for ; Wed, 8 Oct 2003 16:16:54 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h98DGqRQ026400 for ; Wed, 8 Oct 2003 16:16:53 +0300 (EEST) (envelope-from ant@imt.com.ua) Date: Wed, 8 Oct 2003 16:16:52 +0300 (EEST) From: Andriy Tkachuk To: pgsql-performance@postgresql.org Subject: IMMUTABLE function's flag do not work: 7.3.4, plpgsql Message-ID: <20031008152741.P17672-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/198 X-Sequence-Number: 3946 Hi folks. I notice that immutable flag does nothing when i invoke my plpgsql function within one session with same args. tele=# SELECT version(); version ------------------------------------------------------------- PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC 2.96 At first EXPLAIN ANALYZE shown strange runtime :) [15:41]/0:ant@monstr:~>time psql -c 'EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599)' tele QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1) Total runtime: 0.02 msec ^^^^^^^^^ (2 rows) real 0m19.282s ^^^^^^^^^ At second. calc_total() is immutable function: tele=# SELECT provolatile from pg_proc where proname = 'calc_total' and pronargs =3; provolatile ------------- i but it seems that it's not cached in one session: [15:38]/0:ant@monstr:~>psql tele Welcome to psql 7.3.4, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit tele=# EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599); QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1) Total runtime: 0.02 msec (2 rows) tele=# EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599); QUERY PLAN ---------------------------------------------------------------------------------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1) Total runtime: 0.02 msec (2 rows) What i miss? Thanks, Andriy Tkachuk http://www.imt.com.ua From pgsql-performance-owner@postgresql.org Wed Oct 8 11:08:45 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0116BD1B585 for ; Wed, 8 Oct 2003 14:08:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 69975-01 for ; Wed, 8 Oct 2003 11:07:56 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id A9943D1B588 for ; Wed, 8 Oct 2003 11:07:52 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Wed, 8 Oct 2003 10:09:52 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFFAK; Wed, 8 Oct 2003 10:10:32 -0400 Message-ID: <3F841A28.8060504@cranel.com> Date: Wed, 08 Oct 2003 10:07:36 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Compare rows 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: 200310/199 X-Sequence-Number: 3947 All, Anyone have any suggestions on how to efficiently compare rows in the same table? This table has 637 columns to be compared and 642 total columns. TIA, Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 11:09:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED052D1B4F6 for ; Wed, 8 Oct 2003 14:09:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 68507-03 for ; Wed, 8 Oct 2003 11:08:59 -0300 (ADT) Received: from web10510.mail.yahoo.com (web10510.mail.yahoo.com [216.136.130.193]) by svr1.postgresql.org (Postfix) with SMTP id 6ED86D1B517 for ; Wed, 8 Oct 2003 11:08:55 -0300 (ADT) Message-ID: <20031008140859.21016.qmail@web10510.mail.yahoo.com> Received: from [200.55.12.27] by web10510.mail.yahoo.com via HTTP; Wed, 08 Oct 2003 09:08:59 CDT Date: Wed, 8 Oct 2003 09:08:59 -0500 (CDT) From: =?iso-8859-1?q?Adrian=20Demaestri?= Subject: planner doesn't use multicolumn index To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-623169799-1065622139=:20008" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/200 X-Sequence-Number: 3948 --0-623169799-1065622139=:20008 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit We've a table with about 8 million rows, and we need to get rows by the value of two of its fields( the type of the fields are int2 and int4, the where condition is v.g. partido=99 and partida=123). We created a multicolumn index on that fields but the planner doesn't use it, it still use a seqscan. That fields are primary key of the table and we clusterded the table based on that index, but it still doesn't work. We also set the enviroment variable enable_seqscan to false and nathing happends. The only way the planner use it is in querys that order by the expression of the index. Any idea? thanks. Adri�n --------------------------------- Do You Yahoo!? Todo lo que quieres saber de Estados Unidos, Am�rica Latina y el resto del Mundo. Vis�ta Yahoo! Noticias. --0-623169799-1065622139=:20008 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
We've a table with about 8 million rows, and we need to get rows by the value of two of its fields( the type of the fields are int2 and int4, the where condition is v.g. partido=99 and partida=123). We created a multicolumn index on that fields but the planner doesn't use it, it still use a seqscan. That fields are primary key of the table and we clusterded the table based on that index, but it still doesn't work. We also set the enviroment variable enable_seqscan to false and nathing happends. The only way the planner use it is in querys that order by the expression of the index.
Any idea?
thanks.
Adri�n



Do You Yahoo!?
Todo lo que quieres saber de Estados Unidos, Am�rica Latina y el resto del Mundo.
Vis�ta Yahoo! Noticias.
--0-623169799-1065622139=:20008-- From pgsql-performance-owner@postgresql.org Wed Oct 8 11:19:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 01478D1B517 for ; Wed, 8 Oct 2003 14:19:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71438-01 for ; Wed, 8 Oct 2003 11:18:58 -0300 (ADT) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id 33716D1B577 for ; Wed, 8 Oct 2003 11:18:54 -0300 (ADT) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 04A232B3CB; Wed, 8 Oct 2003 16:18:08 +0200 (CEST) Message-ID: <3F841CAF.6070202@klaster.net> Date: Wed, 08 Oct 2003 16:18:23 +0200 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5) Gecko/20030916 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Adrian Demaestri Cc: pgsql-performance@postgresql.org Subject: Re: planner doesn't use multicolumn index References: <20031008140859.21016.qmail@web10510.mail.yahoo.com> In-Reply-To: <20031008140859.21016.qmail@web10510.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/201 X-Sequence-Number: 3949 > We've a table with about 8 million rows, and we need to get rows by the > value of two of its fields( the type of the fields are int2 and int4, > the where condition is v.g. partido=99 and partida=123). We created a > multicolumn index on that fields but the planner doesn't use it, it > still use a seqscan. That fields are primary key of the table and we > clusterded the table based on that index, but it still doesn't work. We > also set the enviroment variable enable_seqscan to false and nathing > happends. The only way the planner use it is in querys that order by the > expression of the index. > Any idea? > thanks. > Adri�n where partido=99::int2 and partida=123; Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Wed Oct 8 11:28:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 54684D1B587 for ; Wed, 8 Oct 2003 14:28:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62545-09 for ; Wed, 8 Oct 2003 11:27:43 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id D8A42D1B575 for ; Wed, 8 Oct 2003 11:27:37 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h98EWUJf012471 for ; Wed, 8 Oct 2003 20:02:30 +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 h98EWSNs012398; Wed, 8 Oct 2003 20:02:28 +0530 Message-ID: <3F841EDA.7000207@persistent.co.in> Date: Wed, 08 Oct 2003 19:57:38 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Adrian Demaestri Cc: pgsql-performance@postgresql.org Subject: Re: planner doesn't use multicolumn index References: <20031008140859.21016.qmail@web10510.mail.yahoo.com> In-Reply-To: <20031008140859.21016.qmail@web10510.mail.yahoo.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: 200310/202 X-Sequence-Number: 3950 Adrian Demaestri wrote: > We've a table with about 8 million rows, and we need to get rows by the value >of two of its fields( the type of the fields are int2 and int4, >the where condition is v.g. partido=99 and partida=123). We created a >multicolumn index on that fields but the planner doesn't use it, it still use >a seqscan. That fields are primary key of the table and we clusterded the table >based on that index, but it still doesn't work. We also set the enviroment > variable enable_seqscan to false and nathing happends. The only way the >planner use it is in querys that order by the expression of the index. Use partido=99::int2 and partida=123::int4 Match the data types basically.. Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 8 12:22:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2566ED1B51E for ; Wed, 8 Oct 2003 15:21:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74838-08 for ; Wed, 8 Oct 2003 12:21:10 -0300 (ADT) Received: from email04.aon.at (WARSL402PIP2.highway.telekom.at [195.3.96.74]) by svr1.postgresql.org (Postfix) with SMTP id E434AD1B8A9 for ; Wed, 8 Oct 2003 12:21:09 -0300 (ADT) Received: (qmail 388442 invoked from network); 8 Oct 2003 14:37:25 -0000 Received: from m171p010.dipool.highway.telekom.at (HELO cantor) ([62.46.11.74]) (envelope-sender ) by qmail7rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 8 Oct 2003 14:37:25 -0000 From: Manfred Koizar To: Adrian Demaestri Cc: pgsql-performance@postgresql.org Subject: Re: planner doesn't use multicolumn index Date: Wed, 08 Oct 2003 16:35:24 +0200 Message-ID: References: <20031008140859.21016.qmail@web10510.mail.yahoo.com> In-Reply-To: <20031008140859.21016.qmail@web10510.mail.yahoo.com> 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: 200310/209 X-Sequence-Number: 3957 On Wed, 8 Oct 2003 09:08:59 -0500 (CDT), Adrian Demaestri wrote: >the type of the fields are int2 and >int4, the where condition is v.g. partido=99 and partida=123). Write your search condition as WHERE partido=99::int2 and partida=123 Servus Manfred From pgsql-performance-owner@postgresql.org Wed Oct 8 11:49:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA4D2D1B4F0 for ; Wed, 8 Oct 2003 14:49:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 70372-08 for ; Wed, 8 Oct 2003 11:48:55 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 06C99D1B50A for ; Wed, 8 Oct 2003 11:48:51 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A7FcV-0001Wo-00 for ; Wed, 08 Oct 2003 10:48:55 -0400 Received: by dba2 (Postfix, from userid 1019) id 9C478CCA5; Wed, 8 Oct 2003 10:48:55 -0400 (EDT) Date: Wed, 8 Oct 2003 10:48:55 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Sun performance - Major discovery! Message-ID: <20031008144855.GB11507@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: 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: 200310/203 X-Sequence-Number: 3951 On Wed, Oct 08, 2003 at 08:36:56AM -0400, Jeff wrote: > > So here's the results using my load tester (single connection per beater, > repeats the query 1000 times with different input each time (we'll get > ~20k rows back), the query is a common query around here. My worry about this test is that it gives us precious little knowledge about concurrent connection slowness, which is where I find the most significant problems. When we tried a Sunsoft cc vs gcc 2.95 on Sol 7 about 1 1/2 years ago, we found more or less no difference once we added more than 5 connections (and we always have more than 5 connections). It might be worth trying again, though, since we moved to Sol 8. Thanks for the result. -- ---- 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 Oct 8 11:53:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 84326D1B4F6 for ; Wed, 8 Oct 2003 14:53:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72440-06 for ; Wed, 8 Oct 2003 11:52:46 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id BD103D1B50A for ; Wed, 8 Oct 2003 11:52:41 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id D94711F4F; Wed, 8 Oct 2003 10:52:40 -0400 (EDT) Subject: Re: Sun performance - Major discovery! From: Neil Conway To: Jeff Cc: PostgreSQL Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1065624759.377.20.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 10:52:39 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/204 X-Sequence-Number: 3952 On Wed, 2003-10-08 at 08:36, Jeff wrote: > So here's the results using my load tester (single connection per beater, > repeats the query 1000 times with different input each time (we'll get > ~20k rows back), the query is a common query around here. What is the query? > Linux - 1x - 35 seconds, 20x - 180 seconds "20x" means 20 concurrent testing processes, right? > Sun - gcc - 1x 60 seconds 20x 245 seconds > Sun - sunsoft defaults - 1x 52 seonds 20x [similar to gcc most likely] > Sun - sunsoft -fast - 1x 28 seconds 20x 164 seconds Interesting (and surprising that the performance differential is that large, to me at least). Can you tell if the performance gain comes from an improvement in a particular subsystem? (i.e. could you get a profile of Sun/gcc and compare it with Sun/sunsoft). -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 11:55:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D2D65D1B50A for ; Wed, 8 Oct 2003 14:55:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72925-05 for ; Wed, 8 Oct 2003 11:54:30 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id C1420D1B4F0 for ; Wed, 8 Oct 2003 11:54:25 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 3B3FA369F8; Wed, 8 Oct 2003 10:54:25 -0400 (EDT) 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 1A7Fho-0008Lz-00; Wed, 08 Oct 2003 10:54:24 -0400 To: Rod Taylor Cc: Dror Matalon , Postgresql Performance Subject: Re: Speeding up Aggregates References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> In-Reply-To: <1065219028.91586.8.camel@jester> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 08 Oct 2003 10:54:24 -0400 Message-ID: <87llrvbx0f.fsf@stark.dyndns.tv> Lines: 33 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: 200310/205 X-Sequence-Number: 3953 Rod Taylor writes: > On Fri, 2003-10-03 at 17:53, Dror Matalon wrote: > > On Fri, Oct 03, 2003 at 05:44:49PM -0400, Rod Taylor wrote: > > > > > > It is too bad the (channel, link) index doesn't have dtstamp at the end > > > of it, otherwise the below query would be a gain (might be a small one > > > anyway). > > > > > > select dtstamp > > > from items > > > where channel = $1 > > > and link = $2 > > > ORDER BY dtstamp DESC > > > LIMIT 1; > > It didn't make a difference even with the 3 term index? I guess you > don't have very many common values for channel / link combination. You need to do: ORDER BY channel DESC, link DESC, dtstamp DESC This is an optimizer nit. It doesn't notice that since it selected on channel and link already the remaining tuples in the index will be ordered simply by dtstamp. (This is the thing i pointed out previously in <87el6ckrlu.fsf@stark.dyndns.tv> on Feb 13th 2003 on pgsql-general) -- greg From pgsql-performance-owner@postgresql.org Wed Oct 8 11:58:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D8437D1B592 for ; Wed, 8 Oct 2003 14:58:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74033-03 for ; Wed, 8 Oct 2003 11:57:33 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 835ACD1B580 for ; Wed, 8 Oct 2003 11:57:28 -0300 (ADT) Received: (qmail 63362 invoked from network); 8 Oct 2003 14:57:34 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 14:57:34 -0000 Date: Wed, 8 Oct 2003 10:57:34 -0400 (EDT) From: Jeff To: Andrew Sullivan Cc: "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <20031008144855.GB11507@libertyrms.info> 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: 200310/206 X-Sequence-Number: 3954 On Wed, 8 Oct 2003, Andrew Sullivan wrote: > My worry about this test is that it gives us precious little > knowledge about concurrent connection slowness, which is where I find > the most significant problems. When we tried a Sunsoft cc vs gcc 2.95 > on Sol 7 about 1 1/2 years ago, we found more or less no difference > once we added more than 5 connections (and we always have more than 5 > connections). It might be worth trying again, though, since we moved > to Sol 8. > The 20x column are the results when I fired up 20 beater concurrently. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 12:01:19 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6C00DD1B89B for ; Wed, 8 Oct 2003 15:01:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74033-04 for ; Wed, 8 Oct 2003 12:00:28 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id A5745D1B4F6 for ; Wed, 8 Oct 2003 12:00:27 -0300 (ADT) Received: (qmail 63431 invoked from network); 8 Oct 2003 15:00:30 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 15:00:30 -0000 Date: Wed, 8 Oct 2003 11:00:30 -0400 (EDT) From: Jeff To: Neil Conway Cc: PostgreSQL Performance Subject: Re: Sun performance - Major discovery! In-Reply-To: <1065624759.377.20.camel@tokyo> 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: 200310/207 X-Sequence-Number: 3955 On Wed, 8 Oct 2003, Neil Conway wrote: > What is the query? > It retrieves an index listing for our boards. The boards are flat (not threaded) and messages are numbered starting at 1 for each board. If you pass in 0 for the start_from it assumes the latest 60. And it should be noted - in some cases some boards have nearly 2M posts. Index on board_name, number. I cannot give out too too much stuff ;) create or replace function get_index2(integer, varchar, varchar) returns setof snippet as ' DECLARE p_start alias for $1; p_board alias for $2; v_start integer; v_num integer; v_body text; v_sender varchar(35); v_time timestamptz; v_finish integer; v_row record; v_ret snippet; BEGIN v_start := p_start; if v_start = 0 then select * into v_start from get_high_msg(p_board); v_start := v_start - 59; end if; v_finish := v_start + 60; for v_row in select number, substr(body, 0, 50) as snip, member_handle, timestamp from posts where board_name = p_board and number >= v_start and number < v_finish order by number desc LOOP return next v_row; END LOOP; return; END; ' language 'plpgsql'; > Interesting (and surprising that the performance differential is that > large, to me at least). Can you tell if the performance gain comes from > an improvement in a particular subsystem? (i.e. could you get a profile > of Sun/gcc and compare it with Sun/sunsoft). > I'll get these later today. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 12:03:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 69DF9D1B590 for ; Wed, 8 Oct 2003 15:03:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72440-10 for ; Wed, 8 Oct 2003 12:02:11 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 4644DD1B50A for ; Wed, 8 Oct 2003 12:02:11 -0300 (ADT) Received: (qmail 63442 invoked from network); 8 Oct 2003 15:02:14 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 15:02:14 -0000 Date: Wed, 8 Oct 2003 11:02:14 -0400 (EDT) From: Jeff To: pgsql-performance@postgresql.org Subject: Presentation 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: 200310/208 X-Sequence-Number: 3956 The boss cleared my de-company info-ified pg presentation. It deals with PG features, crude comparison to other dbs, install, admin, and most importantly - optimization & quirks. Its avail in powerpoint and (ugg) powerpoint exported html. Let me know if there are blatant errors, etc in there. Maybe even slightly more subtle blatant errors :) The people here thought it was good. http://postgres.jefftrout.com/ -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 12:47:05 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 981E7D1B54D for ; Wed, 8 Oct 2003 15:47:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81863-09 for ; Wed, 8 Oct 2003 12:46:13 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 47D63D1B4F0 for ; Wed, 8 Oct 2003 12:46:12 -0300 (ADT) Received: (qmail 63664 invoked from network); 8 Oct 2003 15:46:09 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 15:46:09 -0000 Date: Wed, 8 Oct 2003 11:46:09 -0400 (EDT) From: Jeff To: Neil Conway Cc: PostgreSQL Performance Subject: Re: Sun performance - Major discovery! In-Reply-To: <1065624759.377.20.camel@tokyo> 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: 200310/210 X-Sequence-Number: 3958 On Wed, 8 Oct 2003, Neil Conway wrote: > Interesting (and surprising that the performance differential is that > large, to me at least). Can you tell if the performance gain comes from > an improvement in a particular subsystem? (i.e. could you get a profile > of Sun/gcc and compare it with Sun/sunsoft). > Yeah - like I expected it was able to generate much better code for _bt_checkkeys which was the #1 function in gcc on both sun & linux. and as you can see, suncc was just able to generate much nicer code. I'd look at the assembler output but that won't be useful since I am very unfamiliar with the [ultra]sparc instruction set.. Here's the prof and gprof output for the latest run: GCC: % cumulative self self total time seconds seconds calls ms/call ms/call name 31.52 19.44 19.44 internal_mcount 20.28 31.95 12.51 8199466 0.00 0.00 _bt_checkkeys 5.61 35.41 3.46 8197422 0.00 0.00 _bt_step 5.01 38.50 3.09 24738620 0.00 0.00 FunctionCall2 3.00 40.35 1.85 8194186 0.00 0.00 varchareq 2.61 41.96 1.61 24309 0.07 0.28 _bt_next 2.42 43.45 1.49 1003 1.49 1.51 AtEOXact_Buffers 2.37 44.91 1.46 12642 0.12 0.12 _read 2.33 46.35 1.44 16517771 0.00 0.00 pg_detoast_datum 2.08 47.63 1.28 8193186 0.00 0.00 int4lt 1.35 48.46 0.83 8237204 0.00 0.00 BufferGetBlockNumber 1.35 49.29 0.83 8193888 0.00 0.00 int4ge 1.35 50.12 0.83 _mcount SunCC -pg -fast. %Time Seconds Cumsecs #Calls msec/call Name 23.2 4.27 4.27108922056 0.0000 _mcount 20.7 3.82 8.09 8304052 0.0005 _bt_checkkeys 13.7 2.53 10.6225054788 0.0001 FunctionCall2 5.1 0.94 11.56 24002 0.0392 _bt_next 4.4 0.81 12.37 8301867 0.0001 _bt_step 3.4 0.63 13.00 8298219 0.0001 varchareq 2.7 0.50 13.5016726855 0.0000 pg_detoast_datum 2.4 0.45 13.95 8342464 0.0001 BufferGetBlockNumber 2.4 0.44 14.39 8297941 0.0001 int4ge 2.2 0.41 14.80 1003 0.409 AtEOXact_Buffers 2.0 0.37 15.17 4220349 0.0001 lc_collate_is_c 2.0 0.37 15.54 8297219 0.0000 int4lt 1.6 0.29 15.83 26537 0.0109 AllocSetContextCreate 0.9 0.16 15.99 1887 0.085 pglz_decompress 0.7 0.13 16.12 159966 0.0008 nocachegetattr 0.7 0.13 16.25 4220349 0.0000 varstr_cmp 0.6 0.11 16.36 937576 0.0001 MemoryContextAlloc 0.5 0.09 16.45 150453 0.0006 hash_search > -Neil > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 14 13:44:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8A6CDD1B4E1 for ; Wed, 8 Oct 2003 15:49:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83121-06 for ; Wed, 8 Oct 2003 12:48:19 -0300 (ADT) Received: from buckaroo.freeuk.net (buckaroo.freeuk.net [212.126.144.5]) by svr1.postgresql.org (Postfix) with ESMTP id 63555D1B573 for ; Wed, 8 Oct 2003 12:48:18 -0300 (ADT) Received: from claranet by buckaroo.freeuk.net with local (Exim 4.24) id 1A7GXx-0007J5-PM for pgsql-performance@postgresql.org; Wed, 08 Oct 2003 16:48:17 +0100 To: pgsql-performance@postgresql.org Reply-To: psql-mail@freeuk.com Subject: Large Text Search Help Cc: X-Remote_Addr: 212.126.153.165 Precedence: normal Message-Id: From: psql-mail@freeuk.com Date: Wed, 08 Oct 2003 16:48:17 +0100 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/447 X-Sequence-Number: 4195 Hi, I am trying to design a large text search database. It will have upwards of 6 million documents, along with meta data on each. I am currently looking at tsearch2 to provide fast text searching and also playing around with different hardware configurations. 1. With tsearch2 I get very good query times up until I insert more records. For example with 100,000 records tsearch2 returns in around 6 seconds, with 200,000 records tsearch2 returns in just under a minute. Is this due to the indices fitting entirely in memory with 100,000 records? 2. As well as whole word matching i also need to be able to do substring matching. Is the FTI module the way to approach this? 3. I have just begun to look into distibuted queries. Is there an existing solution for distibuting a postgresql database amongst multiple servers, so each has the same schema but only a subset of the total data? Any other helpful comments or sugestions on how to improve query times using different hardware or software techniques would be appreciated. Thanks, Mat From pgsql-performance-owner@postgresql.org Wed Oct 8 12:52:08 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B8808D1B4FC for ; Wed, 8 Oct 2003 15:52:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83364-06 for ; Wed, 8 Oct 2003 12:51:21 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 58164D1B4F0 for ; Wed, 8 Oct 2003 12:51:19 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h98Fu8xZ004898 for ; Wed, 8 Oct 2003 21:26:08 +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 h98Fu7Ns004869; Wed, 8 Oct 2003 21:26:07 +0530 Message-ID: <3F843274.30500@persistent.co.in> Date: Wed, 08 Oct 2003 21:21:16 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: Presentation 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: 200310/211 X-Sequence-Number: 3959 Jeff wrote: > Let me know if there are blatant errors, etc in there. > Maybe even slightly more subtle blatant errors :) Some minor nitpicks, * Slide 5, postgresql already features 64 bit port. The sentence is slightly confusing * Same slide. IIRC postgresql always compresses bytea/varchar. Not too much sure about which but there is something that is compressed by default..:-) * Tablespaces has a patch floating somewhere. IIRC Gavin Sherry is the one who is most ahead of it. For all goodness, they will feature in 7.5 and design is done. There aren't much issues there. * Mysql transaction breaks down if tables from different table types are involved. * Mysql transactions do not feature constant time commit/rollback like postgresql. The time to rollback depends upon size of transaction * Mysql does not split large files in segments the way postgresql do. Try storing 60GB of data in single mysql table. * Slide on informix. It would be better if you mention what database you were using on your pentium. Assuming postgresql is fine, but being specific helps. * Slide on caching. Postgresql can use 7000MB of caching. Important part is it does not lock that memory in it's own process space. OS can move around buffer cache but not memory space of an application. * Installation slide. We can do without 'yada' for being formal, right..:-) (Sorry if thats too nitpicky but couldn't help it..:-)) * initdb could be coupled with configure/make install but again, it's a matter of choice. * Slide on configuration. 'Reliable DB corruption' is a confusing term. 'DB corruption for sure' or something on that line would be more appropriate especially if presentation is read in documentation form and not explained in a live session. but you decide. * I doubt pg_autovacuum will be in core source but predicting that long is always risky..:-) * Using trigger for maintening a row count would generate as much dead rows as you wanted to avoid in first place..:-) All of them are really minor. It's a very well done presentation but 45 slides could be bit too much at a time. I suggest splitting the presentation in 3. Intro and comparison, features, administration, programming and tuning. Wow.. they are 5..:-) Can you rip out informix migration? It could be a good guide by itself. Thanks again for documentation. After you decide what license you want to release it under, the team can put it on techdocs.postgresql.org.. Again, thanks for a good presentation.. Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 8 12:59:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8AF76D1B8A2 for ; Wed, 8 Oct 2003 15:59:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86041-02 for ; Wed, 8 Oct 2003 12:58:49 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 5F718D1B4FC for ; Wed, 8 Oct 2003 12:58:43 -0300 (ADT) Received: (qmail 7891 invoked from network); 8 Oct 2003 15:58:37 -0000 Received: from unknown (HELO ?10.0.2.5?) (216.208.117.7) by 205.178.180.9 with SMTP; 8 Oct 2003 15:58:37 -0000 Subject: Re: Presentation From: Rod Taylor To: Shridhar Daithankar Cc: Jeff , Postgresql Performance In-Reply-To: <3F843274.30500@persistent.co.in> References: <3F843274.30500@persistent.co.in> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-eXlwjDnkSZPG3NxKH9c0" Message-Id: <1065628756.59262.10.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 11:59:17 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/212 X-Sequence-Number: 3960 --=-eXlwjDnkSZPG3NxKH9c0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > * Same slide. IIRC postgresql always compresses bytea/varchar. Not too mu= ch sure=20 > about which but there is something that is compressed by default..:-) I'm not sure about that. Even toasted values are not always compressed, though they certainly can be and usually are. --=-eXlwjDnkSZPG3NxKH9c0 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/hDRU6DETLow6vwwRAl1QAJ96a8ie6YfuvIsHttzI8r+Rt+o64ACfbXRV JPetGUFcmbbr7CncptoeLpU= =S/KR -----END PGP SIGNATURE----- --=-eXlwjDnkSZPG3NxKH9c0-- From pgsql-performance-owner@postgresql.org Wed Oct 8 13:04:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 34BA3D1B8A2 for ; Wed, 8 Oct 2003 16:04:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86414-04 for ; Wed, 8 Oct 2003 13:03:49 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id C7452D1B8B0 for ; Wed, 8 Oct 2003 13:03:48 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741192; Wed, 08 Oct 2003 09:04:15 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Greg Spiegelberg , PgSQL Performance ML Subject: Re: Compare rows Date: Wed, 8 Oct 2003 09:01:45 -0700 User-Agent: KMail/1.4.3 References: <3F841A28.8060504@cranel.com> In-Reply-To: <3F841A28.8060504@cranel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310080901.45093.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/213 X-Sequence-Number: 3961 Greg, > Anyone have any suggestions on how to efficiently compare > rows in the same table? This table has 637 columns to be > compared and 642 total columns. 637 columns? Are you sure that's normalized? It's hard for me to conceive of a circumstance where that many columns would be necessary. If this isn't a catastrophic normalization problem (which it sounds like), then you will probably still need to work through procedureal normalization code, as SQL simply doesn't offer any way around naming all the columns by hand. Perhaps you could describe the problem in more detail? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 13:05:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 49423D1B53B for ; Wed, 8 Oct 2003 16:05:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92914-02 for ; Wed, 8 Oct 2003 13:04:35 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 09E51D1B8A0 for ; Wed, 8 Oct 2003 13:04:35 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741194; Wed, 08 Oct 2003 09:05:06 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jeff , pgsql-performance@postgresql.org Subject: Re: Presentation Date: Wed, 8 Oct 2003 09:02:37 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310080902.37026.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/214 X-Sequence-Number: 3962 Jeff, > Its avail in powerpoint and (ugg) powerpoint exported html. I can probably convert it to OpenOffice.org and Flash. OK? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Wed Oct 8 13:09:29 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 38FC3D1B584 for ; Wed, 8 Oct 2003 16:08:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 86635-07 for ; Wed, 8 Oct 2003 13:08:06 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 80E11D1B8B7 for ; Wed, 8 Oct 2003 13:07:45 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741200; Wed, 08 Oct 2003 09:08:21 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jeff , pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] Presentation Date: Wed, 8 Oct 2003 09:05:52 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310080905.52097.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/48 X-Sequence-Number: 2336 Jeff, I'm jumping this thread to ADVOCACY, where it belongs, not PERFORMANCE. > The boss cleared my de-company info-ified pg presentation. > It deals with PG features, crude comparison to other dbs, install, admin, > and most importantly - optimization & quirks. > > Its avail in powerpoint and (ugg) powerpoint exported html. > > Let me know if there are blatant errors, etc in there. > Maybe even slightly more subtle blatant errors :) > > The people here thought it was good. > > http://postgres.jefftrout.com/ I'll check it out later today. As I said in my e-mail, I'm happy to convert the format to something Open Source. Can you release it under an OSS license? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Wed Oct 8 13:11:10 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E5B1FD1B89E for ; Wed, 8 Oct 2003 16:10:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 93519-02 for ; Wed, 8 Oct 2003 13:10:01 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 0CD36D1B575 for ; Wed, 8 Oct 2003 13:09:57 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741208; Wed, 08 Oct 2003 09:10:33 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Shridhar Daithankar Subject: Re: [PERFORM] Presentation Date: Wed, 8 Oct 2003 09:08:03 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-advocacy@postgresql.org References: <3F843274.30500@persistent.co.in> In-Reply-To: <3F843274.30500@persistent.co.in> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310080908.03864.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/49 X-Sequence-Number: 2337 Shridhar, I'm jumping your reply to the proper mailing list. I have one comment at the bottom; the rest of this quote is for the people on the Advocacy list. > > Let me know if there are blatant errors, etc in there. > > Maybe even slightly more subtle blatant errors :) > > Some minor nitpicks, > > * Slide 5, postgresql already features 64 bit port. The sentence is > slightly confusing > * Same slide. IIRC postgresql always compresses bytea/varchar. Not too much > sure about which but there is something that is compressed by default..:-) > * Tablespaces has a patch floating somewhere. IIRC Gavin Sherry is the one > who is most ahead of it. For all goodness, they will feature in 7.5 and > design is done. There aren't much issues there. > * Mysql transaction breaks down if tables from different table types are > involved. * Mysql transactions do not feature constant time commit/rollback > like postgresql. The time to rollback depends upon size of transaction > * Mysql does not split large files in segments the way postgresql do. Try > storing 60GB of data in single mysql table. > * Slide on informix. It would be better if you mention what database you > were using on your pentium. Assuming postgresql is fine, but being specific > helps. * Slide on caching. Postgresql can use 7000MB of caching. Important > part is it does not lock that memory in it's own process space. OS can move > around buffer cache but not memory space of an application. > * Installation slide. We can do without 'yada' for being formal, right..:-) > (Sorry if thats too nitpicky but couldn't help it..:-)) > * initdb could be coupled with configure/make install but again, it's a > matter of choice. > * Slide on configuration. 'Reliable DB corruption' is a confusing term. 'DB > corruption for sure' or something on that line would be more appropriate > especially if presentation is read in documentation form and not explained > in a live session. but you decide. > * I doubt pg_autovacuum will be in core source but predicting that long is > always risky..:-) > * Using trigger for maintening a row count would generate as much dead rows > as you wanted to avoid in first place..:-) > > All of them are really minor. It's a very well done presentation but 45 > slides could be bit too much at a time. I suggest splitting the > presentation in 3. Intro and comparison, features, administration, > programming and tuning. Wow.. they are 5..:-) > > Can you rip out informix migration? It could be a good guide by itself. > > Thanks again for documentation. After you decide what license you want to > release it under, the team can put it on techdocs.postgresql.org.. I'd suggest just having him release it under an OSS license now. That way, you can make the corrections yourself, and we can convert it to OOo and Flash and offer it in a variety of configurations. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Wed Oct 8 13:21:58 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 82A10D1B8C4 for ; Wed, 8 Oct 2003 16:14:32 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 93926-02 for ; Wed, 8 Oct 2003 13:13:46 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 1AF73D1B586 for ; Wed, 8 Oct 2003 13:13:44 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h98GIXr8010543 for ; Wed, 8 Oct 2003 21:48:33 +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 h98GIWNs010529 for ; Wed, 8 Oct 2003 21:48:32 +0530 Message-ID: <3F8437B5.7020704@persistent.co.in> Date: Wed, 08 Oct 2003 21:43:41 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] Presentation References: <3F843274.30500@persistent.co.in> <200310080908.03864.josh@agliodbs.com> In-Reply-To: <200310080908.03864.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: 200310/50 X-Sequence-Number: 2338 Josh Berkus wrote: > Shridhar, > > I'm jumping your reply to the proper mailing list. I have one comment at the > bottom; the rest of this quote is for the people on the Advocacy list. > I'd suggest just having him release it under an OSS license now. That way, > you can make the corrections yourself, and we can convert it to OOo and Flash > and offer it in a variety of configurations. Yeah. I read the request. After he does that, I could take some time off to conevrt it. Long time since I have actually done on postgresql other than posts on mailing list but.. anyways.. Sorry I should have put that on advocacy.. got left out.. Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 8 13:31:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EBEB7D1B8B9 for ; Wed, 8 Oct 2003 16:31:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 94487-10 for ; Wed, 8 Oct 2003 13:30:29 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 0393AD1B89E for ; Wed, 8 Oct 2003 13:27:28 -0300 (ADT) Received: (qmail 64015 invoked from network); 8 Oct 2003 16:27:31 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 16:27:31 -0000 Date: Wed, 8 Oct 2003 12:27:31 -0400 (EDT) From: Jeff To: Shridhar Daithankar Cc: "pgsql-performance@postgresql.org" Subject: Re: Presentation In-Reply-To: <3F843274.30500@persistent.co.in> 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: 200310/215 X-Sequence-Number: 3963 On Wed, 8 Oct 2003, Shridhar Daithankar wrote: Thanks for the nitpicks :) I've taken some into consideration. I also signed onto the advocacy list so I can be in on discussions there. Feel free to convert to whatever format you'd like. I originally started working on it in OpenOffice, but I got mad at it. So I switched to powerpoint and got mad at that too :) -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 13:32:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F1C27D1B949 for ; Wed, 8 Oct 2003 16:32:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 95925-05 for ; Wed, 8 Oct 2003 13:31:23 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 10430D1B8B7 for ; Wed, 8 Oct 2003 13:28:06 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Wed, 8 Oct 2003 12:30:09 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFGGX; Wed, 8 Oct 2003 12:30:37 -0400 Message-ID: <3F843AFD.3020700@cranel.com> Date: Wed, 08 Oct 2003 12:27:41 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> In-Reply-To: <200310080901.45093.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: 200310/216 X-Sequence-Number: 3964 Josh Berkus wrote: > Greg, > > >>Anyone have any suggestions on how to efficiently compare >>rows in the same table? This table has 637 columns to be >>compared and 642 total columns. > > > 637 columns? Are you sure that's normalized? It's hard for me to conceive > of a circumstance where that many columns would be necessary. > > If this isn't a catastrophic normalization problem (which it sounds like), > then you will probably still need to work through procedureal normalization > code, as SQL simply doesn't offer any way around naming all the columns by > hand. Perhaps you could describe the problem in more detail? > The data represents metrics at a point in time on a system for network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, speed, and whatever else can be gathered. We arrived at this one 642 column table after testing the whole process from data gathering, methods of temporarily storing then loading to the database. Initially, 37+ tables were in use but the one big-un has saved us over 3.4 minutes. The reason for my initial question was this. We save changes only. In other words, if system S has row T1 for day D1 and if on day D2 we have another row T1 (excluding our time column) we don't want to save it. That said, if the 3.4 minutes gets burned during our comparison which saves changes only we may look at reverting to separate tables. There are only 1,700 to 3,000 rows on average per load. Oh, PostgreSQL 7.3.3, PHP 4.3.1, RedHat 7.3, kernel 2.4.20-18.7smp, 2x1.4GHz PIII, 2GB memory, and 1Gbs SAN w/ Hitachi 9910 LUN's. Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 13:39:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F3799D1B506 for ; Wed, 8 Oct 2003 16:38:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96807-06 for ; Wed, 8 Oct 2003 13:38:11 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id CD8A6D1B8AE for ; Wed, 8 Oct 2003 13:37:48 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h98GgcwK015248 for ; Wed, 8 Oct 2003 22:12:38 +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 h98GgbNs015222; Wed, 8 Oct 2003 22:12:37 +0530 Message-ID: <3F843D59.3060204@persistent.co.in> Date: Wed, 08 Oct 2003 22:07:45 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Spiegelberg Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> In-Reply-To: <3F843AFD.3020700@cranel.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: 200310/217 X-Sequence-Number: 3965 Greg Spiegelberg wrote: > The data represents metrics at a point in time on a system for > network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, > speed, and whatever else can be gathered. > > We arrived at this one 642 column table after testing the whole > process from data gathering, methods of temporarily storing then > loading to the database. Initially, 37+ tables were in use but > the one big-un has saved us over 3.4 minutes. I am sure you changed the desing because those 3.4 minutes were significant to you. But I suggest you go back to 37 table design and see where bottleneck is. Probably you can tune a join across 37 tables much better than optimizing a difference between two 637 column rows. Besides such a large number of columns will cost heavily in terms of defragmentation across pages. The wasted space and IO therof could be significant issue for large number of rows. 642 column is a bad design. Theoretically and from implementation of postgresql point of view. You did it because of speed problem. Now if we can resolve those speed problems, perhaps you could go back to other design. Is it feasible for you right now or you are too much committed to the big table? And of course, then it is routing postgresql tuning exercise..:-) Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 8 13:42:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5C500D1B506 for ; Wed, 8 Oct 2003 16:42:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96432-10 for ; Wed, 8 Oct 2003 13:41:59 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 561ECD1B4E1 for ; Wed, 8 Oct 2003 13:41:58 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id B83B51F62; Wed, 8 Oct 2003 12:41:57 -0400 (EDT) Subject: Re: Sun performance - Major discovery! From: Neil Conway To: Andrew Sullivan Cc: PostgreSQL Performance In-Reply-To: <20031008144855.GB11507@libertyrms.info> References: <20031008144855.GB11507@libertyrms.info> Content-Type: text/plain Message-Id: <1065631316.3423.2.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 12:41:56 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/218 X-Sequence-Number: 3966 On Wed, 2003-10-08 at 10:48, Andrew Sullivan wrote: > My worry about this test is that it gives us precious little > knowledge about concurrent connection slowness, which is where I find > the most significant problems. As Jeff points out, the second set of results is for 20 concurrent connections. Note that the advantage sunsoft cc has over gcc decreases as the number of connections increases (which makes sense, as the 20x workload is likely to be more I/O bound). -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 13:48:28 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6F4BFD1B897 for ; Wed, 8 Oct 2003 16:48:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96735-10 for ; Wed, 8 Oct 2003 13:47:35 -0300 (ADT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 35AF2D1B506 for ; Wed, 8 Oct 2003 13:47:34 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.5) with ESMTP-TLS id 415948; Wed, 08 Oct 2003 09:46:46 -0700 Message-ID: <3F843F73.6030302@joeconway.com> Date: Wed, 08 Oct 2003 09:46:43 -0700 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: Greg Spiegelberg Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> In-Reply-To: <3F843AFD.3020700@cranel.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: 200310/219 X-Sequence-Number: 3967 Greg Spiegelberg wrote: > The reason for my initial question was this. We save changes only. > In other words, if system S has row T1 for day D1 and if on day D2 > we have another row T1 (excluding our time column) we don't want > to save it. It still isn't entirely clear to me what you are trying to do, but perhaps some sort of calculated checksum or hash would work to determine if the data has changed? Joe From pgsql-performance-owner@postgresql.org Wed Oct 8 14:06:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 115B9D1B4E1 for ; Wed, 8 Oct 2003 17:06:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00359-02 for ; Wed, 8 Oct 2003 14:05:26 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id C6F38D1B4FC for ; Wed, 8 Oct 2003 14:05:24 -0300 (ADT) Received: (qmail 64371 invoked from network); 8 Oct 2003 17:05:28 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 17:05:28 -0000 Date: Wed, 8 Oct 2003 13:05:28 -0400 (EDT) From: Jeff To: Shridhar Daithankar Cc: "pgsql-advocacy@postgresql.org" Subject: Re: Presentation In-Reply-To: <3F843274.30500@persistent.co.in> 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: 200310/220 X-Sequence-Number: 3968 On Wed, 8 Oct 2003, Shridhar Daithankar wrote: > * Same slide. IIRC postgresql always compresses bytea/varchar. Not too much sure > about which but there is something that is compressed by default..:-) > * Tablespaces has a patch floating somewhere. IIRC Gavin Sherry is the one who > is most ahead of it. For all goodness, they will feature in 7.5 and design is For the sake of things, I didn't include any features a patch provides. I did include things that may appear in contrib/. > * Mysql transaction breaks down if tables from different table types are involved. > * Mysql transactions do not feature constant time commit/rollback like > postgresql. The time to rollback depends upon size of transaction > * Mysql does not split large files in segments the way postgresql do. Try > storing 60GB of data in single mysql table. I didn't add these ones. The user can figure this one out. Perhaps when we/me expands this into multiple documents we can expand on this. > * Slide on caching. Postgresql can use 7000MB of caching. Important part is it > does not lock that memory in it's own process space. OS can move around buffer > cache but not memory space of an application. I'm guilty of this myself - when I first started pg I was looking for a way to make it use a zillion megs of memory like we have informix do - Perhaps I'll reword that segment.. the point was to show PG relies on the OS to do a lot of caching and that it doesn't do it itself. > * Using trigger for maintening a row count would generate as much dead rows as > you wanted to avoid in first place..:-) We all know this.. but it is a way to get a fast select count(*) from table > All of them are really minor. It's a very well done presentation but 45 slides > could be bit too much at a time. I suggest splitting the presentation in 3. > Intro and comparison, features, administration, programming and tuning. Wow.. > they are 5..:-) > Yeah. What I'd really love to do is de-powerpointify it and make it a nice set of "real" web pages. > Can you rip out informix migration? It could be a good guide by itself. > I agree. It would be good to rip out. I think we have the oracle guide somewhere.. I've put this updated on up on hte postgres.jefftrout.com site along with openoffice version. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 14:13:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AC230D1B506 for ; Wed, 8 Oct 2003 17:13:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00359-03 for ; Wed, 8 Oct 2003 14:12:22 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7D55FD1B4F0 for ; Wed, 8 Oct 2003 14:12:21 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741468; Wed, 08 Oct 2003 10:12:56 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Greg Spiegelberg , PgSQL Performance ML Subject: Re: Compare rows Date: Wed, 8 Oct 2003 10:10:26 -0700 User-Agent: KMail/1.4.3 References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> In-Reply-To: <3F843AFD.3020700@cranel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310081010.26576.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/221 X-Sequence-Number: 3969 Greg, > The data represents metrics at a point in time on a system for > network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, > speed, and whatever else can be gathered. > > We arrived at this one 642 column table after testing the whole > process from data gathering, methods of temporarily storing then > loading to the database. Initially, 37+ tables were in use but > the one big-un has saved us over 3.4 minutes. Hmmm ... if few of those columns are NULL, then you are probably right ... this is probably the most normalized design. If, however, many of columns are NULL the majority of the time, then the design you should be using is a vertial child table, of the form ( value_type | value ). Such a vertical child table would also make your comparison between instances *much* easier, as it could be executed via a simple 4-table-outer-join and 3 where clauses. So even if you don't have a lot of NULLs, you probably want to consider this. > The reason for my initial question was this. We save changes only. > In other words, if system S has row T1 for day D1 and if on day D2 > we have another row T1 (excluding our time column) we don't want > to save it. If re-designing the table per the above is not a possibility, then I'd suggest that you locate 3-5 columns that: 1) are not NULL for any row; 2) combined, serve to identify a tiny subset of rows, i.e. 3% or less of the table. Then put a multi-column index on those columns, and do your comparison. Hopefully the planner should pick up on the availablity of the index and scan only the rows retrieved by the index. However, there is the distinct possibility that the presence of 637 WHERE criteria will confuse the planner, causing it to resort to a full table seq scan; in that case, you will want to use a subselect to force the issue. Or, as Joe Conway suggested, you could figure out some kind of value hash that uniquely identifies your rows. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 14:14:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 778B7D1B4F0 for ; Wed, 8 Oct 2003 17:14:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 06519-03 for ; Wed, 8 Oct 2003 14:13:30 -0300 (ADT) Received: from chimta03.algx.net (mta8.algx.net [67.92.168.237]) by svr1.postgresql.org (Postfix) with ESMTP id 07735D1B4EF for ; Wed, 8 Oct 2003 14:13:29 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx03.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMG007D57UE11@chimmx03.algx.net> for pgsql-performance@postgresql.org; Wed, 08 Oct 2003 12:13:28 -0500 (CDT) Date: Wed, 08 Oct 2003 13:13:26 -0400 From: Jason Hihn Subject: Re: Compare rows In-reply-to: <3F843AFD.3020700@cranel.com> To: Greg Spiegelberg , PgSQL Performance ML Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/222 X-Sequence-Number: 3970 Comment interjected below. > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Greg > Spiegelberg > Sent: Wednesday, October 08, 2003 12:28 PM > To: PgSQL Performance ML > Subject: Re: [PERFORM] Compare rows > > > Josh Berkus wrote: > > Greg, > > > > > >>Anyone have any suggestions on how to efficiently compare > >>rows in the same table? This table has 637 columns to be > >>compared and 642 total columns. > > > > > > 637 columns? Are you sure that's normalized? It's hard for > me to conceive > > of a circumstance where that many columns would be necessary. > > > > If this isn't a catastrophic normalization problem (which it > sounds like), > > then you will probably still need to work through procedureal > normalization > > code, as SQL simply doesn't offer any way around naming all the > columns by > > hand. Perhaps you could describe the problem in more detail? > > > > The data represents metrics at a point in time on a system for > network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, > speed, and whatever else can be gathered. > > We arrived at this one 642 column table after testing the whole > process from data gathering, methods of temporarily storing then > loading to the database. Initially, 37+ tables were in use but > the one big-un has saved us over 3.4 minutes. > > The reason for my initial question was this. We save changes only. > In other words, if system S has row T1 for day D1 and if on day D2 > we have another row T1 (excluding our time column) we don't want > to save it. Um, isn't this a purpose of a key? And I am confused. Do you want to UPDATE the changed columns? or skip it all together? You have: (System, Day, T1 | T2 |...Tn ) But should use: Master: (System, Day, Table={T1, T2, .. Tn)) [Keys: sytem, day, table] T1 { System, Day, {other fields}} [foreign keys [system, day] This should allow you to find your dupes very fast (indexes!) and save a lot of space (few/no null columns), and now you don't have to worry about comparing fields, and moving huge result sets around. > That said, if the 3.4 minutes gets burned during our comparison which > saves changes only we may look at reverting to separate tables. There > are only 1,700 to 3,000 rows on average per load. > > Oh, PostgreSQL 7.3.3, PHP 4.3.1, RedHat 7.3, kernel 2.4.20-18.7smp, > 2x1.4GHz PIII, 2GB memory, and 1Gbs SAN w/ Hitachi 9910 LUN's. > > Greg > > -- > Greg Spiegelberg > Sr. Product Development Engineer > Cranel, Incorporated. > Phone: 614.318.4314 > Fax: 614.431.8388 > Email: gspiegelberg@Cranel.com > Cranel. Technology. Integrity. Focus. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > From pgsql-performance-owner@postgresql.org Wed Oct 8 14:29:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 08786D1B53B for ; Wed, 8 Oct 2003 17:29:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08203-03 for ; Wed, 8 Oct 2003 14:28:59 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id BCDC5D1B4E1 for ; Wed, 8 Oct 2003 14:28:56 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h98HSr811803; Wed, 8 Oct 2003 13:28:53 -0400 (EDT) From: Bruce Momjian Message-Id: <200310081728.h98HSr811803@candle.pha.pa.us> Subject: Re: PostgreSQL vs. MySQL In-Reply-To: <20030704182853.GK4707@libertyrms.info> To: Andrew Sullivan Date: Wed, 8 Oct 2003 13:28:53 -0400 (EDT) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/223 X-Sequence-Number: 3971 Andrew Sullivan wrote: > On Fri, Jul 04, 2003 at 08:07:18PM +0200, Arjen van der Meijden wrote: > > > Andrew Sullivan wrote: > > > results under production conditions, and not bother to read > > > even the basic "quickstart"-type stuff that is kicking > > > around. > > Then please point out where it sais, in the documentation, that the > > value for the shared_memory of 64 is too low and that 4000 is a nice > > value to start with? > > I think I did indeed speak too soon, as the criticism is a fair one: > nowhere in the installation instructions or the "getting started" > docs does it say that you really ought to do some tuning once you > have the system installed. Can I suggest for the time being that > something along these lines should go in 14.6.3, "Tuning the > installation": > > ---snip--- > By default, PostgreSQL is configured to run on minimal hardware. As > a result, some tuning of your installation will be necessary before > using it for anything other than extremely small databases. At the > very least, it will probably be necessary to increase your shared > buffers setting. See Chapter 16 for details on what tuning options > are available to you. > ---snip--- > > > I'm sorry to put this in a such a confronting manner, but you simply > > can't expect people to search for information that they don't know the > > existence of. > > No need to apologise; I think you're right. Agreed. Text added to install docs: By default, PostgreSQL is configured to run on minimal hardware. This allows it to start up with almost any hardware configuration. However, the default configuration is not designed for optimum performance. To achieve optimum performance, several server variables must be adjusted, the two most common being shared_buffers and sort_mem mentioned in ]]>. Other parameters in ]]> also affect performance. -- 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 Oct 8 14:44:21 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD29D1B506 for ; Wed, 8 Oct 2003 17:44:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05377-09 for ; Wed, 8 Oct 2003 14:43:33 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 98EABD1B4F9 for ; Wed, 8 Oct 2003 14:43:32 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id BA5521E3C; Wed, 8 Oct 2003 13:43:32 -0400 (EDT) Subject: Re: Sun performance - Major discovery! From: Neil Conway To: Jeff Cc: PostgreSQL Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1065635011.3424.25.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 13:43:31 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/224 X-Sequence-Number: 3972 On Wed, 2003-10-08 at 11:46, Jeff wrote: > Yeah - like I expected it was able to generate much better code for > _bt_checkkeys which was the #1 function in gcc on both sun & linux. > > and as you can see, suncc was just able to generate much nicer code. What CFLAGS does configure pick for gcc? From src/backend/template/solaris, I'd guess it's not enabling any optimization. Is that the case? If so, some gcc numbers with -O and -O2 would be useful. -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 14:52:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5DD0ED1B4EF for ; Wed, 8 Oct 2003 17:52:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07583-10 for ; Wed, 8 Oct 2003 14:51:51 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 36CB3D1B545 for ; Wed, 8 Oct 2003 14:51:50 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741632; Wed, 08 Oct 2003 10:52:25 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Bruce Momjian , Andrew Sullivan Subject: Re: PostgreSQL vs. MySQL Date: Wed, 8 Oct 2003 10:49:55 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <200310081728.h98HSr811803@candle.pha.pa.us> In-Reply-To: <200310081728.h98HSr811803@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310081049.55816.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/225 X-Sequence-Number: 3973 Bruce, > Agreed. Text added to install docs: > > > By default, PostgreSQL is configured to run on minimal > hardware. This allows it to start up with almost any hardware > configuration. However, the default configuration is not designed for > optimum performance. To achieve optimum performance, several server > variables must be adjusted, the two most common being > shared_buffers and sort_mem > mentioned in > linkend="runtime-config-resource-memory">]]>. Other parameters in > linkend="runtime-config-resource">]]> also affect performance. > What would you think of adding a condensed version of my and Shridhar's guide to the install docs? I think I can offer a 3-paragraph version which would cover the major points of setting PostgreSQL.conf. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 14:59:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8EB2AD1B4FC for ; Wed, 8 Oct 2003 17:59:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 09431-04 for ; Wed, 8 Oct 2003 14:59:03 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 423F2D1B549 for ; Wed, 8 Oct 2003 14:59:01 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h98Hwvr15088; Wed, 8 Oct 2003 13:58:57 -0400 (EDT) From: Bruce Momjian Message-Id: <200310081758.h98Hwvr15088@candle.pha.pa.us> Subject: Re: PostgreSQL vs. MySQL In-Reply-To: <200310081049.55816.josh@agliodbs.com> To: Josh Berkus Date: Wed, 8 Oct 2003 13:58:57 -0400 (EDT) Cc: Andrew Sullivan , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/226 X-Sequence-Number: 3974 Josh Berkus wrote: > Bruce, > > > Agreed. Text added to install docs: > > > > > > By default, PostgreSQL is configured to run on minimal > > hardware. This allows it to start up with almost any hardware > > configuration. However, the default configuration is not designed for > > optimum performance. To achieve optimum performance, several server > > variables must be adjusted, the two most common being > > shared_buffers and sort_mem > > mentioned in > > > linkend="runtime-config-resource-memory">]]>. Other parameters in > > > linkend="runtime-config-resource">]]> also affect performance. > > > > What would you think of adding a condensed version of my and Shridhar's guide > to the install docs? I think I can offer a 3-paragraph version which would > cover the major points of setting PostgreSQL.conf. Yes, I think that is a good idea --- now, does it go in the install docs, or in the docs next to each GUC item? -- 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 Oct 8 15:06:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 89C94D1B549 for ; Wed, 8 Oct 2003 18:06:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08573-08 for ; Wed, 8 Oct 2003 15:05:37 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 0A598D1B4EF for ; Wed, 8 Oct 2003 15:05:36 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Wed, 8 Oct 2003 14:07:47 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFHA5; Wed, 8 Oct 2003 14:08:30 -0400 Message-ID: <3F8451EE.2050006@cranel.com> Date: Wed, 08 Oct 2003 14:05:34 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843D59.3060204@persistent.co.in> In-Reply-To: <3F843D59.3060204@persistent.co.in> 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: 200310/227 X-Sequence-Number: 3975 See below. Shridhar Daithankar wrote: > Greg Spiegelberg wrote: > >> The data represents metrics at a point in time on a system for >> network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, >> speed, and whatever else can be gathered. >> >> We arrived at this one 642 column table after testing the whole >> process from data gathering, methods of temporarily storing then >> loading to the database. Initially, 37+ tables were in use but >> the one big-un has saved us over 3.4 minutes. > > > I am sure you changed the desing because those 3.4 minutes were > significant to you. > > > But I suggest you go back to 37 table design and see where bottleneck > is. Probably you can tune a join across 37 tables much better than > optimizing a difference between two 637 column rows. The bottleneck is across the board. On the data collection side I'd have to manage 37 different methods and output formats whereas now I have 1 standard associative array that gets reset in memory for each "row" stored. On the data validation side, I have one routine to check the incoming data for errors, missing columns, data types and so on. Quick & easy. On the data import it's easier and more efficient to do one COPY for a standard format from one program instead of multiple programs or COPY's. We were using 37 PHP scripts to handle the import and the time it took to load, execute, exit, reload each script was killing us. Now, 1 PHP and 1 COPY. > Besides such a large number of columns will cost heavily in terms of > defragmentation across pages. The wasted space and IO therof could be > significant issue for large number of rows. No arguement here. > 642 column is a bad design. Theoretically and from implementation of > postgresql point of view. You did it because of speed problem. Now if we > can resolve those speed problems, perhaps you could go back to other > design. > > Is it feasible for you right now or you are too much committed to the > big table? Pretty commited though I do try to be open. Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 15:08:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 78D04D1B550 for ; Wed, 8 Oct 2003 18:08:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08757-08 for ; Wed, 8 Oct 2003 15:07:43 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id DFBD7D1B56E for ; Wed, 8 Oct 2003 15:07:40 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3741697; Wed, 08 Oct 2003 11:08:17 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Bruce Momjian Subject: Re: PostgreSQL vs. MySQL Date: Wed, 8 Oct 2003 11:05:47 -0700 User-Agent: KMail/1.4.3 Cc: Andrew Sullivan , pgsql-performance@postgresql.org References: <200310081758.h98Hwvr15088@candle.pha.pa.us> In-Reply-To: <200310081758.h98Hwvr15088@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310081105.47527.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/228 X-Sequence-Number: 3976 Bruce, > Yes, I think that is a good idea --- now, does it go in the install > docs, or in the docs next to each GUC item? Hmmm ... both, I think. The Install Docs should have: "Here are the top # things you will want to adjust in your PostgreSQL.conf: 1) Shared_buffers 2) Sort_mem 3) effective_cache_size 4) random_page_cost 5) Fsync etc." Then next to each of these items in the Docs, I add 1-2 sentences about how to set that item. Hmmm ... do we have similar instructions for setting connection options and pg_hba.conf? We should have a P telling people they need to do this. Barring an objection, I'll get to work on this. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 15:12:06 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E324ED1B506 for ; Wed, 8 Oct 2003 18:12:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 18033-01 for ; Wed, 8 Oct 2003 15:11:20 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 54864D1B4E1 for ; Wed, 8 Oct 2003 15:11:18 -0300 (ADT) Received: (qmail 64812 invoked from network); 8 Oct 2003 18:11:23 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 18:11:23 -0000 Date: Wed, 8 Oct 2003 14:11:23 -0400 (EDT) From: Jeff To: Neil Conway Cc: PostgreSQL Performance Subject: Re: Sun performance - Major discovery! In-Reply-To: <1065635011.3424.25.camel@tokyo> 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: 200310/229 X-Sequence-Number: 3977 On Wed, 8 Oct 2003, Neil Conway wrote: > > What CFLAGS does configure pick for gcc? From > src/backend/template/solaris, I'd guess it's not enabling any > optimization. Is that the case? If so, some gcc numbers with -O and -O2 > would be useful. > I can't believe I didn't think of this before! heh. Turns out gcc was getting nothing for flags. I added -O2 to CFLAGS and my 60 seconds went down to 21. A rather mild improvment huh? I did a few more tests and suncc still beats it out - but not by too much now (Not enought to justify buying a license just for compiling pg) I'll go run the regression test suite with my gcc -O2 pg and the suncc pg. See if they pass the test. If they do we should consider adding -O2 and -fast to the CFLAGS. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 15:18:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 25A93D1B8AE for ; Wed, 8 Oct 2003 18:18:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 11346-06 for ; Wed, 8 Oct 2003 15:17:53 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id DCAC4D1B912 for ; Wed, 8 Oct 2003 15:16:05 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h98IFw416827; Wed, 8 Oct 2003 14:15:58 -0400 (EDT) From: Bruce Momjian Message-Id: <200310081815.h98IFw416827@candle.pha.pa.us> Subject: Re: PostgreSQL vs. MySQL In-Reply-To: <200310081105.47527.josh@agliodbs.com> To: Josh Berkus Date: Wed, 8 Oct 2003 14:15:58 -0400 (EDT) Cc: Andrew Sullivan , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/230 X-Sequence-Number: 3978 Totally agree. --------------------------------------------------------------------------- Josh Berkus wrote: > Bruce, > > > Yes, I think that is a good idea --- now, does it go in the install > > docs, or in the docs next to each GUC item? > > Hmmm ... both, I think. The Install Docs should have: > > "Here are the top # things you will want to adjust in your PostgreSQL.conf: > 1) Shared_buffers > 2) Sort_mem > 3) effective_cache_size > 4) random_page_cost > 5) Fsync > etc." > > Then next to each of these items in the Docs, I add 1-2 sentences about how to > set that item. > > Hmmm ... do we have similar instructions for setting connection options and > pg_hba.conf? We should have a P telling people they need to do this. > > Barring an objection, I'll get to work on this. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > -- 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 Oct 8 15:21:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D5722D1B554 for ; Wed, 8 Oct 2003 18:21:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 18749-04 for ; Wed, 8 Oct 2003 15:20:26 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 24C18D1B583 for ; Wed, 8 Oct 2003 15:18:24 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id CC395ACC3 for ; Wed, 8 Oct 2003 18:18:19 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h98IIJFc011621 for pgsql-performance@postgresql.org; Wed, 8 Oct 2003 11:18:19 -0700 (PDT) (envelope-from dror) Date: Wed, 8 Oct 2003 11:18:19 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031008181819.GJ2979@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87llrvbx0f.fsf@stark.dyndns.tv> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/231 X-Sequence-Number: 3979 Actually what finally sovled the problem is repeating the dtstamp > last_viewed in the sub select select articlenumber, channel, description, title, link, dtstamp from items i1, my_channels where ((i1.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and (dtstamp > last_viewed)) ) and (dtstamp = (select max (dtstamp) from items i2 where channel = '22222' and i1.link = i2.link)); to explain analyze select articlenumber, channel, description, title, link, dtstamp from items i1, my_channels where ((i1.channel = '22222' and my_channels.id = '22222' and owner = 'drormata' and (dtstamp > last_viewed)) ) and (dtstamp = (select max (dtstamp) from items i2 where channel = '22222' and i1.link = i2.link and dtstamp > last_viewed)); Which in the stored procedure looks like this: CREATE or REPLACE FUNCTION item_max_date (int4, varchar, timestamptz) RETURNS timestamptz AS ' select max(dtstamp) from items where channel = $1 and link = $2 and dtstamp > $3; ' LANGUAGE 'sql'; Basically I have hundreds or thousands of items but only a few that satisfy "dtstamp > last_viewed". Obviously I want to run the max() only on on a few items. Repeating "dtstamp > last_viewed" did the trick, but it seems like there should be a more elegant/clear way to tell the planner which constraint to apply first. Dror On Wed, Oct 08, 2003 at 10:54:24AM -0400, Greg Stark wrote: > Rod Taylor writes: > > > On Fri, 2003-10-03 at 17:53, Dror Matalon wrote: > > > On Fri, Oct 03, 2003 at 05:44:49PM -0400, Rod Taylor wrote: > > > > > > > > It is too bad the (channel, link) index doesn't have dtstamp at the end > > > > of it, otherwise the below query would be a gain (might be a small one > > > > anyway). > > > > > > > > select dtstamp > > > > from items > > > > where channel = $1 > > > > and link = $2 > > > > ORDER BY dtstamp DESC > > > > LIMIT 1; > > > > It didn't make a difference even with the 3 term index? I guess you > > don't have very many common values for channel / link combination. > > You need to do: > > ORDER BY channel DESC, link DESC, dtstamp DESC > > This is an optimizer nit. It doesn't notice that since it selected on channel > and link already the remaining tuples in the index will be ordered simply by > dtstamp. > > (This is the thing i pointed out previously in > <87el6ckrlu.fsf@stark.dyndns.tv> on Feb 13th 2003 on pgsql-general) > > > -- > greg > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Wed Oct 8 15:29:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B0239D1B4EF for ; Wed, 8 Oct 2003 18:29:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19230-06 for ; Wed, 8 Oct 2003 15:28:48 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id B1091D1B549 for ; Wed, 8 Oct 2003 15:28:46 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id A5F121F4B; Wed, 8 Oct 2003 14:28:46 -0400 (EDT) Subject: Re: PostgreSQL vs. MySQL From: Neil Conway To: Josh Berkus Cc: Bruce Momjian , Andrew Sullivan , PostgreSQL Performance In-Reply-To: <200310081105.47527.josh@agliodbs.com> References: <200310081758.h98Hwvr15088@candle.pha.pa.us> <200310081105.47527.josh@agliodbs.com> Content-Type: text/plain Message-Id: <1065637725.3419.30.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 14:28:45 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/232 X-Sequence-Number: 3980 On Wed, 2003-10-08 at 14:05, Josh Berkus wrote: > Hmmm ... both, I think. The Install Docs should have: > > "Here are the top # things you will want to adjust in your PostgreSQL.conf: > 1) Shared_buffers > 2) Sort_mem > 3) effective_cache_size > 4) random_page_cost > 5) Fsync > etc." > Barring an objection, I'll get to work on this. I think this kind of information belongs in the documentation proper, not in the installation instructions. I think you should put this kind of tuning information in the "Performance Tips" chapter, and include a pointer to it in the installation instructions. -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 15:32:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 139E8D1B55C; Wed, 8 Oct 2003 18:32:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19304-07; Wed, 8 Oct 2003 15:31:42 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 01720D1B541; Wed, 8 Oct 2003 15:31:40 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h98IVT919657; Wed, 8 Oct 2003 14:31:29 -0400 (EDT) From: Bruce Momjian Message-Id: <200310081831.h98IVT919657@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Wed, 8 Oct 2003 14:31:29 -0400 (EDT) Cc: Neil Conway , PostgreSQL Performance , PostgreSQL-development X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/233 X-Sequence-Number: 3981 Jeff wrote: > On Wed, 8 Oct 2003, Neil Conway wrote: > > > > > What CFLAGS does configure pick for gcc? From > > src/backend/template/solaris, I'd guess it's not enabling any > > optimization. Is that the case? If so, some gcc numbers with -O and -O2 > > would be useful. > > > > I can't believe I didn't think of this before! heh. > Turns out gcc was getting nothing for flags. > > I added -O2 to CFLAGS and my 60 seconds went down to 21. A rather mild > improvment huh? > > I did a few more tests and suncc still beats it out - but not by too much > now (Not enought to justify buying a license just for compiling pg) > > I'll go run the regression test suite with my gcc -O2 pg and the suncc pg. > See if they pass the test. > > If they do we should consider adding -O2 and -fast to the CFLAGS. [ CC added for hackers.] Well, this is really embarassing. I can't imagine why we would not set at least -O on all platforms. Looking at the template files, I see these have no optimization set: darwin dgux freebsd (non-alpha) irix5 nextstep osf (gcc) qnx4 solaris sunos4 svr4 ultrix4 I thought we used to have code that did -O for any platforms that set no cflags, but I don't see that around anywhere. I recommend adding -O2, or at leaset -O to all these platforms --- we can then use platform testing to make sure they are working. -- 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 Oct 8 15:38:21 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4AA41D1B52A; Wed, 8 Oct 2003 18:38:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20921-01; Wed, 8 Oct 2003 15:37:34 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 34B9ED1B4E1; Wed, 8 Oct 2003 15:37:33 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 442D01F55; Wed, 8 Oct 2003 14:37:33 -0400 (EDT) Subject: Re: Sun performance - Major discovery! From: Neil Conway To: Bruce Momjian Cc: Jeff , PostgreSQL Performance , PostgreSQL Hackers In-Reply-To: <200310081831.h98IVT919657@candle.pha.pa.us> References: <200310081831.h98IVT919657@candle.pha.pa.us> Content-Type: text/plain Message-Id: <1065638251.3423.37.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 14:37:31 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/234 X-Sequence-Number: 3982 On Wed, 2003-10-08 at 14:31, Bruce Momjian wrote: > Well, this is really embarassing. I can't imagine why we would not set > at least -O on all platforms. ISTM the most legitimate reason for not enabling compilater optimizations on a given compiler/OS/architecture combination is might cause compiler errors / bad code generation. Can we get these optimizations enabled in time for the next 7.4 beta? It might also be good to add an item in the release notes about it. -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 15:40:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C7FF4D1B4E3 for ; Wed, 8 Oct 2003 18:40:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19304-09 for ; Wed, 8 Oct 2003 15:40:02 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 89324D1B4F6 for ; Wed, 8 Oct 2003 15:40:00 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Wed, 8 Oct 2003 14:42:07 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFHJY; Wed, 8 Oct 2003 14:42:50 -0400 Message-ID: <3F8459FA.1030008@cranel.com> Date: Wed, 08 Oct 2003 14:39:54 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843F73.6030302@joeconway.com> In-Reply-To: <3F843F73.6030302@joeconway.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: 200310/235 X-Sequence-Number: 3983 Joe Conway wrote: > Greg Spiegelberg wrote: > >> The reason for my initial question was this. We save changes only. >> In other words, if system S has row T1 for day D1 and if on day D2 >> we have another row T1 (excluding our time column) we don't want >> to save it. > > > It still isn't entirely clear to me what you are trying to do, but > perhaps some sort of calculated checksum or hash would work to determine > if the data has changed? Best example I have is this. You're running Solaris 5.8 with patch 108528-X and you're collecting that data daily. Would you want option 1 or 2 below? Option 1 - Store it all Day | OS | Patch ------+-------------+----------- Oct 1 | Solaris 5.8 | 108528-12 Oct 2 | Solaris 5.8 | 108528-12 Oct 3 | Solaris 5.8 | 108528-13 Oct 4 | Solaris 5.8 | 108528-13 Oct 5 | Solaris 5.8 | 108528-13 and so on... To find what you're running: select * from table order by day desc limit 1; To find when it last changed however takes a join. Option 2 - Store only changes Day | OS | Patch ------+-------------+----------- Oct 1 | Solaris 5.8 | 108528-12 Oct 3 | Solaris 5.8 | 108528-13 To find what you're running: select * from table order by day desc limit 1; To find when it last changed: select * from table order by day desc limit 1 offset 1; I selected Option 2 because I'm dealing with mounds of complicated and varying data formats and didn't want to have to write complex queries for everything. Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 15:46:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DDAA7D1B516 for ; Wed, 8 Oct 2003 18:46:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21557-02 for ; Wed, 8 Oct 2003 15:45:57 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id B636ED1B4EF for ; Wed, 8 Oct 2003 15:45:48 -0300 (ADT) Received: (qmail 65082 invoked from network); 8 Oct 2003 18:45:49 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 18:45:49 -0000 Date: Wed, 8 Oct 2003 14:45:49 -0400 (EDT) From: Jeff To: Neil Conway Cc: Bruce Momjian , PostgreSQL Performance , PostgreSQL Hackers Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: <1065638251.3423.37.camel@tokyo> 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: 200310/236 X-Sequence-Number: 3984 On Wed, 8 Oct 2003, Neil Conway wrote: > ISTM the most legitimate reason for not enabling compilater > optimizations on a given compiler/OS/architecture combination is might > cause compiler errors / bad code generation. > > Can we get these optimizations enabled in time for the next 7.4 beta? It > might also be good to add an item in the release notes about it. > > -Neil > I just ran make check for sun with gcc -O2 and suncc -fast and both passed. We'll need other arguments to suncc to supress some warnings, etc. (-fast generates a warning for every file compiled telling you it will only run on ultrasparc machines) -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 15:47:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8A627D1B506 for ; Wed, 8 Oct 2003 18:47:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21557-03 for ; Wed, 8 Oct 2003 15:46:49 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 9F6B8D1B53E for ; Wed, 8 Oct 2003 15:46:47 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 69EE71F54; Wed, 8 Oct 2003 14:46:46 -0400 (EDT) Subject: Re: Presentation From: Neil Conway To: Jeff Cc: PostgreSQL Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1065638804.3602.3.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 14:46:44 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/237 X-Sequence-Number: 3985 On Wed, 2003-10-08 at 11:02, Jeff wrote: > The boss cleared my de-company info-ified pg presentation. Slide 37: as far as I know, reordering of outer joins is not implemented in 7.4 -Neil From pgsql-hackers-owner@postgresql.org Wed Oct 8 15:51:24 2003 X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C4664D1B506 for ; Wed, 8 Oct 2003 18:51:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22046-03 for ; Wed, 8 Oct 2003 15:50:37 -0300 (ADT) Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) by svr1.postgresql.org (Postfix) with ESMTP id A4C7ED1B4EF for ; Wed, 8 Oct 2003 15:50:35 -0300 (ADT) Received: from dunslane.net (x.ncshp.org [199.90.235.43]) (authenticated (0 bits)) by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id h98Iiux13908 for ; Wed, 8 Oct 2003 13:44:57 -0500 Message-ID: <3F845C70.8060108@dunslane.net> Date: Wed, 08 Oct 2003 14:50:24 -0400 From: Andrew Dunstan 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: Postgresql Hackers Subject: Re: [PERFORM] Sun performance - Major discovery! References: <200310081831.h98IVT919657@candle.pha.pa.us> In-Reply-To: <200310081831.h98IVT919657@candle.pha.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: 200310/440 X-Sequence-Number: 45122 Bruce Momjian wrote: >Jeff wrote: > > >>On Wed, 8 Oct 2003, Neil Conway wrote: >> >> >> >>>What CFLAGS does configure pick for gcc? From >>>src/backend/template/solaris, I'd guess it's not enabling any >>>optimization. Is that the case? If so, some gcc numbers with -O and -O2 >>>would be useful. >>> >>> >>> >>I can't believe I didn't think of this before! heh. >>Turns out gcc was getting nothing for flags. >> >>I added -O2 to CFLAGS and my 60 seconds went down to 21. A rather mild >>improvment huh? >> >>I did a few more tests and suncc still beats it out - but not by too much >>now (Not enought to justify buying a license just for compiling pg) >> >>I'll go run the regression test suite with my gcc -O2 pg and the suncc pg. >>See if they pass the test. >> >>If they do we should consider adding -O2 and -fast to the CFLAGS. >> >> > >[ CC added for hackers.] > >Well, this is really embarassing. I can't imagine why we would not set >at least -O on all platforms. Looking at the template files, I see >these have no optimization set: > > darwin > dgux > freebsd (non-alpha) > irix5 > nextstep > osf (gcc) > qnx4 > solaris > sunos4 > svr4 > ultrix4 > >I thought we used to have code that did -O for any platforms that set no >cflags, but I don't see that around anywhere. I recommend adding -O2, >or at leaset -O to all these platforms --- we can then use platform >testing to make sure they are working. > > > Actually, I would not be surprised to see gains on Solaris/SPARC from -O3 with gcc, which enables inlining and register-renaming, although this does make debugging pretty much impossible. worth testing at least (but I no longer have access to a Solaris machine). cheers andrew From pgsql-performance-owner@postgresql.org Wed Oct 8 15:56:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 27AFAD1B54D for ; Wed, 8 Oct 2003 18:56:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20716-07 for ; Wed, 8 Oct 2003 15:55:28 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 2D81CD1B4F6 for ; Wed, 8 Oct 2003 15:55:27 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id BABB75FEC for ; Wed, 8 Oct 2003 18:55:27 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h98ItR3F011683 for pgsql-performance@postgresql.org; Wed, 8 Oct 2003 11:55:27 -0700 (PDT) (envelope-from dror) Date: Wed, 8 Oct 2003 11:55:27 -0700 From: Dror Matalon To: PgSQL Performance ML Subject: Re: Compare rows Message-ID: <20031008185527.GK2979@rlx11.zapatec.com> References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843F73.6030302@joeconway.com> <3F8459FA.1030008@cranel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F8459FA.1030008@cranel.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/238 X-Sequence-Number: 3986 It's still not quite clear what you're trying to do. Many people's gut reaction is that you're doing something strange with so many columns in a table. Using your example, a different approach might be to do this instead: Day | Name | Value ------+-------------+----------- Oct 1 | OS | Solaris 5.8 Oct 1 | Patch | 108528-12 Oct 3 | Patch | 108528-13 You end up with lots more rows, fewer columns, but it might be harder to query the table. On the other hand, queries should run quite fast, since it's a much more "normal" table. But without knowing more, and seeing what the other columns look like, it's hard to tell. Dror On Wed, Oct 08, 2003 at 02:39:54PM -0400, Greg Spiegelberg wrote: > Joe Conway wrote: > >Greg Spiegelberg wrote: > > > >>The reason for my initial question was this. We save changes only. > >>In other words, if system S has row T1 for day D1 and if on day D2 > >>we have another row T1 (excluding our time column) we don't want > >>to save it. > > > > > >It still isn't entirely clear to me what you are trying to do, but > >perhaps some sort of calculated checksum or hash would work to determine > >if the data has changed? > > Best example I have is this. > > You're running Solaris 5.8 with patch 108528-X and you're collecting > that data daily. Would you want option 1 or 2 below? > > Option 1 - Store it all > Day | OS | Patch > ------+-------------+----------- > Oct 1 | Solaris 5.8 | 108528-12 > Oct 2 | Solaris 5.8 | 108528-12 > Oct 3 | Solaris 5.8 | 108528-13 > Oct 4 | Solaris 5.8 | 108528-13 > Oct 5 | Solaris 5.8 | 108528-13 > and so on... > > To find what you're running: > select * from table order by day desc limit 1; > > To find when it last changed however takes a join. > > > Option 2 - Store only changes > Day | OS | Patch > ------+-------------+----------- > Oct 1 | Solaris 5.8 | 108528-12 > Oct 3 | Solaris 5.8 | 108528-13 > > To find what you're running: > select * from table order by day desc limit 1; > > To find when it last changed: > select * from table order by day desc limit 1 offset 1; > > I selected Option 2 because I'm dealing with mounds of complicated and > varying data formats and didn't want to have to write complex queries > for everything. > > Greg > > -- > Greg Spiegelberg > Sr. Product Development Engineer > Cranel, Incorporated. > Phone: 614.318.4314 > Fax: 614.431.8388 > Email: gspiegelberg@Cranel.com > Cranel. Technology. Integrity. Focus. > > > > ---------------------------(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.zapatec.com From pgsql-performance-owner@postgresql.org Wed Oct 8 16:08:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C5A48D1B4E9 for ; Wed, 8 Oct 2003 19:08:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21169-09 for ; Wed, 8 Oct 2003 16:07:39 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id A856BD1B4F0 for ; Wed, 8 Oct 2003 16:07:37 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Wed, 8 Oct 2003 15:09:43 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFH6G; Wed, 8 Oct 2003 15:10:26 -0400 Message-ID: <3F846072.3090700@cranel.com> Date: Wed, 08 Oct 2003 15:07:30 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dror Matalon Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843F73.6030302@joeconway.com> <3F8459FA.1030008@cranel.com> <20031008185527.GK2979@rlx11.zapatec.com> In-Reply-To: <20031008185527.GK2979@rlx11.zapatec.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: 200310/239 X-Sequence-Number: 3987 Dror, I gave this some serious thought at first. I only deal with int8, numeric(24,12) and varchar(32) columns which I could reduce to 3 different tables. Problem was going from 1700-3000 rows to around 300,000-1,000,000 rows per system per day that is sending data to our database. BTW, the int8 and numeric(24,12) are for future expansion. I hate limits. Greg Dror Matalon wrote: > It's still not quite clear what you're trying to do. Many people's gut > reaction is that you're doing something strange with so many columns in > a table. > > Using your example, a different approach might be to do this instead: > > Day | Name | Value > ------+-------------+----------- > Oct 1 | OS | Solaris 5.8 > Oct 1 | Patch | 108528-12 > Oct 3 | Patch | 108528-13 > > > You end up with lots more rows, fewer columns, but it might be > harder to query the table. On the other hand, queries should run quite > fast, since it's a much more "normal" table. > > But without knowing more, and seeing what the other columns look like, > it's hard to tell. > > Dror -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 16:11:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B822AD1B4E9 for ; Wed, 8 Oct 2003 19:11:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20446-08 for ; Wed, 8 Oct 2003 16:11:06 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 61895D1B4F0 for ; Wed, 8 Oct 2003 16:11:04 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Wed, 8 Oct 2003 15:13:06 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFH73; Wed, 8 Oct 2003 15:13:50 -0400 Message-ID: <3F84613D.8040207@cranel.com> Date: Wed, 08 Oct 2003 15:10:53 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <200310081010.26576.josh@agliodbs.com> In-Reply-To: <200310081010.26576.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: 200310/240 X-Sequence-Number: 3988 Josh Berkus wrote: > Greg, > > >>The data represents metrics at a point in time on a system for >>network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, >>speed, and whatever else can be gathered. >> >>We arrived at this one 642 column table after testing the whole >>process from data gathering, methods of temporarily storing then >>loading to the database. Initially, 37+ tables were in use but >>the one big-un has saved us over 3.4 minutes. > > > Hmmm ... if few of those columns are NULL, then you are probably right ... > this is probably the most normalized design. If, however, many of columns > are NULL the majority of the time, then the design you should be using is a > vertial child table, of the form ( value_type | value ). > > Such a vertical child table would also make your comparison between instances > *much* easier, as it could be executed via a simple 4-table-outer-join and 3 > where clauses. So even if you don't have a lot of NULLs, you probably want > to consider this. You lost me on that one. What's a "vertical child table"? Statistically, about 6% of the rows use more than 200 of the columns, 27% of the rows use 80-199 or more columns, 45% of the rows use 40-79 columns and the remaining 22% of the rows use 39 or less of the columns. That is a lot of NULLS. Never gave that much thought. To ensure query efficiency, hide the NULLs and simulate the multiple tables I have a boatload of indexes, ensure that every query makees use of an index, and have created 37 views. It's worked pretty well so far >>The reason for my initial question was this. We save changes only. >>In other words, if system S has row T1 for day D1 and if on day D2 >>we have another row T1 (excluding our time column) we don't want >>to save it. > > > If re-designing the table per the above is not a possibility, then I'd suggest > that you locate 3-5 columns that: > 1) are not NULL for any row; > 2) combined, serve to identify a tiny subset of rows, i.e. 3% or less of the > table. There are always, always, always 7 columns that contain data. > Then put a multi-column index on those columns, and do your comparison. > Hopefully the planner should pick up on the availablity of the index and scan > only the rows retrieved by the index. However, there is the distinct > possibility that the presence of 637 WHERE criteria will confuse the planner, > causing it to resort to a full table seq scan; in that case, you will want to > use a subselect to force the issue. That's what I'm trying to avoid is a big WHERE (c1,c2,...,c637) <> (d1,d2,...,d637) clause. Ugly. > Or, as Joe Conway suggested, you could figure out some kind of value hash that > uniquely identifies your rows. I've given that some though and though appealing I don't think I'd care to spend the CPU cycles to do it. Best way I can figure to accomplish it would be to generate an MD5 on each row without the timestamp and store it in another column, create an index on the MD5 column, generate MD5 on each line I want to insert. Makes for a simple WHERE... Okay. I'll give it a whirl. What's one more column, right? Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Wed Oct 8 16:23:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F20C1D1B52A for ; Wed, 8 Oct 2003 19:23:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 30920-01 for ; Wed, 8 Oct 2003 16:22:27 -0300 (ADT) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by svr1.postgresql.org (Postfix) with ESMTP id 0026ED1B4E3 for ; Wed, 8 Oct 2003 16:22:25 -0300 (ADT) Received: (from mail@localhost) by martin.sysdetect.com (8.11.4/8.11.3) id h98JMBQ26683; Wed, 8 Oct 2003 19:22:11 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdY29543; Wed Oct 8 19:22:09 2003 Received: from startide.sysdetect.com (startide.sysdetect.com [172.16.1.34]) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h98JM9b13606; Wed, 8 Oct 2003 15:22:09 -0400 Received: from startide.sysdetect.com (localhost [127.0.0.1]) by startide.sysdetect.com (8.12.8/8.12.8) with ESMTP id h98JM9Uk029757; Wed, 8 Oct 2003 15:22:09 -0400 Received: from startide.sysdetect.com (seth@localhost) by startide.sysdetect.com (8.12.8/8.12.8/Submit) with ESMTP id h98JM9LW029751; Wed, 8 Oct 2003 15:22:09 -0400 Message-Id: <200310081922.h98JM9LW029751@startide.sysdetect.com> To: Jeff Cc: Neil Conway , PostgreSQL Performance From: pgsql-performance@sysd.com Subject: Re: Sun performance - Major discovery! In-reply-to: References: <1065635011.3424.25.camel@tokyo> Comments: In reply to a message from "Jeff " dated "Wed, 08 Oct 2003 14:11:23 -0400." Date: Wed, 08 Oct 2003 15:22:08 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/241 X-Sequence-Number: 3989 In message , Jeff writes: I'll go run the regression test suite with my gcc -O2 pg and the suncc pg. See if they pass the test. My default set of gcc optimization flags is: -O3 -funroll-loops -frerun-cse-after-loop -frerun-loop-opt -falign-functions -mcpu=i686 -march=i686 Obviously the last two flags product CPU specific code, so would have to differ...autoconf is always possible, but so is just lopping them off. I have found these flags to produce faster code that a simple -O2, but I understand the exact combination which is best for you is code-dependent. Of course, if you are getting really excited, you can use -fbranch-probabilities, but as you will see if you investigate that requires some profiling information, so is not very easy to actually practically use. -Seth Robertson From pgsql-performance-owner@postgresql.org Wed Oct 8 16:25:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4F128D1B545 for ; Wed, 8 Oct 2003 19:25:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21617-10 for ; Wed, 8 Oct 2003 16:24:57 -0300 (ADT) Received: from chimta03.algx.net (mta8.algx.net [67.92.168.237]) by svr1.postgresql.org (Postfix) with ESMTP id 2204CD1B4FD for ; Wed, 8 Oct 2003 16:24:56 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx03.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMG002V8DXKMZ@chimmx03.algx.net> for pgsql-performance@postgresql.org; Wed, 08 Oct 2003 14:24:56 -0500 (CDT) Date: Wed, 08 Oct 2003 15:24:56 -0400 From: Jason Hihn Subject: Re: Compare rows In-reply-to: <3F84613D.8040207@cranel.com> To: Greg Spiegelberg , PgSQL Performance ML Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/242 X-Sequence-Number: 3990 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Greg > Spiegelberg > Sent: Wednesday, October 08, 2003 3:11 PM > To: PgSQL Performance ML > Subject: Re: [PERFORM] Compare rows > > > Josh Berkus wrote: > > Greg, > > > > > >>The data represents metrics at a point in time on a system for > >>network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, > >>speed, and whatever else can be gathered. > >> > >>We arrived at this one 642 column table after testing the whole > >>process from data gathering, methods of temporarily storing then > >>loading to the database. Initially, 37+ tables were in use but > >>the one big-un has saved us over 3.4 minutes. > > > > > > Hmmm ... if few of those columns are NULL, then you are > probably right ... > > this is probably the most normalized design. If, however, > many of columns > > are NULL the majority of the time, then the design you should > be using is a > > vertial child table, of the form ( value_type | value ). > > > > Such a vertical child table would also make your comparison > between instances > > *much* easier, as it could be executed via a simple > 4-table-outer-join and 3 > > where clauses. So even if you don't have a lot of NULLs, you > probably want > > to consider this. > > You lost me on that one. What's a "vertical child table"? Parent table Fkey | Option | Value ------------------+--------+------- | OS | Solaris | DISK1 | 30g ^^^^^^^^ ^^^-- values fields are values in a column rather than 'fields' > Statistically, about 6% of the rows use more than 200 of the columns, > 27% of the rows use 80-199 or more columns, 45% of the rows use 40-79 > columns and the remaining 22% of the rows use 39 or less of the columns. > That is a lot of NULLS. Never gave that much thought. > > To ensure query efficiency, hide the NULLs and simulate the multiple > tables I have a boatload of indexes, ensure that every query makees use > of an index, and have created 37 views. It's worked pretty well so > far > > > >>The reason for my initial question was this. We save changes only. > >>In other words, if system S has row T1 for day D1 and if on day D2 > >>we have another row T1 (excluding our time column) we don't want > >>to save it. > > > > > > If re-designing the table per the above is not a possibility, > then I'd suggest > > that you locate 3-5 columns that: > > 1) are not NULL for any row; > > 2) combined, serve to identify a tiny subset of rows, i.e. 3% > or less of the > > table. > > There are always, always, always 7 columns that contain data. > > > > Then put a multi-column index on those columns, and do your > comparison. > > Hopefully the planner should pick up on the availablity of the > index and scan > > only the rows retrieved by the index. However, there is the distinct > > possibility that the presence of 637 WHERE criteria will > confuse the planner, > > causing it to resort to a full table seq scan; in that case, > you will want to > > use a subselect to force the issue. > > That's what I'm trying to avoid is a big WHERE (c1,c2,...,c637) <> > (d1,d2,...,d637) clause. Ugly. > > > > Or, as Joe Conway suggested, you could figure out some kind of > value hash that > > uniquely identifies your rows. > > I've given that some though and though appealing I don't think I'd care > to spend the CPU cycles to do it. Best way I can figure to accomplish > it would be to generate an MD5 on each row without the timestamp and > store it in another column, create an index on the MD5 column, generate > MD5 on each line I want to insert. Makes for a simple WHERE... > > Okay. I'll give it a whirl. What's one more column, right? > > Greg > > -- > Greg Spiegelberg > Sr. Product Development Engineer > Cranel, Incorporated. > Phone: 614.318.4314 > Fax: 614.431.8388 > Email: gspiegelberg@Cranel.com > Cranel. Technology. Integrity. Focus. > > > > ---------------------------(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 Wed Oct 8 16:39:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 16BB9D1B4E9 for ; Wed, 8 Oct 2003 19:39:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31525-06 for ; Wed, 8 Oct 2003 16:38:36 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 93790D1B50A for ; Wed, 8 Oct 2003 16:38:34 -0300 (ADT) Received: (qmail 65683 invoked from network); 8 Oct 2003 19:38:37 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 8 Oct 2003 19:38:37 -0000 Date: Wed, 8 Oct 2003 15:38:37 -0400 (EDT) From: Jeff To: Neil Conway Cc: PostgreSQL Performance Subject: Re: Presentation In-Reply-To: <1065638804.3602.3.camel@tokyo> 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: 200310/244 X-Sequence-Number: 3992 On Wed, 8 Oct 2003, Neil Conway wrote: > On Wed, 2003-10-08 at 11:02, Jeff wrote: > > The boss cleared my de-company info-ified pg presentation. > > Slide 37: as far as I know, reordering of outer joins is not implemented > in 7.4 > Huh. I could have sworn Tom did something like that. Perhaps I am thinking of something else. You had to enable some magic GUC. Maybe he did a test and it never made it in. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 8 16:40:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1745BD1B4EA for ; Wed, 8 Oct 2003 19:40:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31478-05 for ; Wed, 8 Oct 2003 16:39:48 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 2CD21D1B4EF for ; Wed, 8 Oct 2003 16:39:46 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 8E354ACC3 for ; Wed, 8 Oct 2003 19:39:41 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h98Jdbsg011788 for pgsql-performance@postgresql.org; Wed, 8 Oct 2003 12:39:37 -0700 (PDT) (envelope-from dror) Date: Wed, 8 Oct 2003 12:39:37 -0700 From: Dror Matalon To: PgSQL Performance ML Subject: Re: Compare rows Message-ID: <20031008193937.GN2979@rlx11.zapatec.com> References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843F73.6030302@joeconway.com> <3F8459FA.1030008@cranel.com> <20031008185527.GK2979@rlx11.zapatec.com> <3F846072.3090700@cranel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F846072.3090700@cranel.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/245 X-Sequence-Number: 3993 Greg, On Wed, Oct 08, 2003 at 03:07:30PM -0400, Greg Spiegelberg wrote: > Dror, > > I gave this some serious thought at first. I only deal with > int8, numeric(24,12) and varchar(32) columns which I could > reduce to 3 different tables. Problem was going from 1700-3000 I'm not sure how the data types come into play here. I was for the most part following your examples. > rows to around 300,000-1,000,000 rows per system per day that > is sending data to our database. > Depending on the distribution of your data you can end up with more, less or roughly the same amount of data in the end. It all depends on how many of the 600+ columns change every time you insert a row. If only a few of them do, then you'll clearly end up with less total data, since you'll be writing several rows that are very short instead of one huge row that contains all the information. In other words, you're tracking changes better. It also sounds like you feel that having a few thousand rows in a very "wide" table is better than having 300,000 - 1,00,000 rows in a "narrow" table. My gut feeling is that it's the other way around, but there are plenty of people on this list who can provide a more informed answer. Using the above eample, assuming that both tables roughly have the same number of pages in them, would postgres deal better with a table with 3-4 columns with 300,000 - 1,000,000 rows or with a table with several hundred columns with only 3000 or so rows? Regards, Dror > BTW, the int8 and numeric(24,12) are for future expansion. > I hate limits. > > Greg > > > Dror Matalon wrote: > >It's still not quite clear what you're trying to do. Many people's gut > >reaction is that you're doing something strange with so many columns in > >a table. > > > >Using your example, a different approach might be to do this instead: > > > > Day | Name | Value > > ------+-------------+----------- > > Oct 1 | OS | Solaris 5.8 > > Oct 1 | Patch | 108528-12 > > Oct 3 | Patch | 108528-13 > > > > > >You end up with lots more rows, fewer columns, but it might be > >harder to query the table. On the other hand, queries should run quite > >fast, since it's a much more "normal" table. > > > >But without knowing more, and seeing what the other columns look like, > >it's hard to tell. > > > >Dror > > > -- > Greg Spiegelberg > Sr. Product Development Engineer > Cranel, Incorporated. > Phone: 614.318.4314 > Fax: 614.431.8388 > Email: gspiegelberg@Cranel.com > Cranel. Technology. Integrity. Focus. > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Wed Oct 8 16:36:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 73E7CD1B4E3 for ; Wed, 8 Oct 2003 19:36:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31478-04 for ; Wed, 8 Oct 2003 16:35:36 -0300 (ADT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by svr1.postgresql.org (Postfix) with ESMTP id C343FD1B4EA for ; Wed, 8 Oct 2003 16:35:30 -0300 (ADT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id PAA16717; Wed, 8 Oct 2003 15:35:24 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma016713; Wed, 8 Oct 03 15:35:23 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id PAA30120; Wed, 8 Oct 2003 15:21:11 -0400 Message-ID: <3F8469CC.7379F8D7@nsd.ca> Date: Wed, 08 Oct 2003 15:47:24 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.8 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Greg Spiegelberg Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310080901.45093.josh@agliodbs.com> <3F843AFD.3020700@cranel.com> <3F843F73.6030302@joeconway.com> <3F8459FA.1030008@cranel.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/243 X-Sequence-Number: 3991 Here is what i think you can use: One master table with out duplicates and one anciliary table with duplicate for the day. Insert the result of the select from the anciliary table into the master table, truncate the anciliary table. select distinct on ( {all the fields except day}) * from table order by {all the fields except day}, day; As in: select distinct on ( OS, Patch) * from table order by OS, Patch, Day; JLL BTW, PG developper, since the distinct on list MUST be included in the order by clause why not make it implicitly part of the order by clause? Greg Spiegelberg wrote: > > Joe Conway wrote: > > Greg Spiegelberg wrote: > > > >> The reason for my initial question was this. We save changes only. > >> In other words, if system S has row T1 for day D1 and if on day D2 > >> we have another row T1 (excluding our time column) we don't want > >> to save it. > > > > > > It still isn't entirely clear to me what you are trying to do, but > > perhaps some sort of calculated checksum or hash would work to determine > > if the data has changed? > > Best example I have is this. > > You're running Solaris 5.8 with patch 108528-X and you're collecting > that data daily. Would you want option 1 or 2 below? > > Option 1 - Store it all > Day | OS | Patch > ------+-------------+----------- > Oct 1 | Solaris 5.8 | 108528-12 > Oct 2 | Solaris 5.8 | 108528-12 > Oct 3 | Solaris 5.8 | 108528-13 > Oct 4 | Solaris 5.8 | 108528-13 > Oct 5 | Solaris 5.8 | 108528-13 > and so on... > > To find what you're running: > select * from table order by day desc limit 1; > > To find when it last changed however takes a join. > > Option 2 - Store only changes > Day | OS | Patch > ------+-------------+----------- > Oct 1 | Solaris 5.8 | 108528-12 > Oct 3 | Solaris 5.8 | 108528-13 > > To find what you're running: > select * from table order by day desc limit 1; > > To find when it last changed: > select * from table order by day desc limit 1 offset 1; > > I selected Option 2 because I'm dealing with mounds of complicated and > varying data formats and didn't want to have to write complex queries > for everything. > > Greg > > -- > Greg Spiegelberg > Sr. Product Development Engineer > Cranel, Incorporated. > Phone: 614.318.4314 > Fax: 614.431.8388 > Email: gspiegelberg@Cranel.com > Cranel. Technology. Integrity. Focus. > > ---------------------------(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 Oct 8 16:58:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6D4FAD1B4EF for ; Wed, 8 Oct 2003 19:58:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31760-10 for ; Wed, 8 Oct 2003 16:58:04 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 90B38D1B4F6 for ; Wed, 8 Oct 2003 16:58:02 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 5E6963E4F for ; Wed, 8 Oct 2003 15:58:04 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 11240-04 for ; Wed, 8 Oct 2003 15:58:03 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id BCF8A3E29 for ; Wed, 8 Oct 2003 15:58:03 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h98Jw3GX047266 for pgsql-performance@postgresql.org; Wed, 8 Oct 2003 15:58:03 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: PostgreSQL vs. MySQL Date: Wed, 08 Oct 2003 15:58:03 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 31 Message-ID: References: <200310081758.h98Hwvr15088@candle.pha.pa.us> <200310081105.47527.josh@agliodbs.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065643083 62005 216.194.193.105 (8 Oct 2003 19:58:03 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Wed, 8 Oct 2003 19:58:03 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:x1HKMaRamIUKEqGvtQLajaYkiT8= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/246 X-Sequence-Number: 3994 >>>>> "JB" == Josh Berkus writes: JB> Hmmm ... both, I think. The Install Docs should have: JB> "Here are the top # things you will want to adjust in your PostgreSQL.conf: JB> 1) Shared_buffers JB> 2) Sort_mem JB> 3) effective_cache_size JB> 4) random_page_cost JB> 5) Fsync JB> etc." Add: max_fsm_relations (perhaps it is ok with current default) max_fsm_pages I don't think you really want to diddle with fsync in the name of speed at the cost of safety. and possibly: checkpoint_segments (if you do a lot of writes to the DB for extended durations of time) With 7.4 it warns you in the logs if you should increase this. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Wed Oct 8 18:49:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C0869D1B558 for ; Wed, 8 Oct 2003 21:49:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55461-01 for ; Wed, 8 Oct 2003 18:48:28 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id B1DEED1B4E3 for ; Wed, 8 Oct 2003 18:48:25 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 2724D1F52; Wed, 8 Oct 2003 17:48:27 -0400 (EDT) Subject: Re: Presentation From: Neil Conway To: Jeff Cc: PostgreSQL Performance In-Reply-To: References: Content-Type: text/plain Message-Id: <1065649706.359.4.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 08 Oct 2003 17:48:26 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/247 X-Sequence-Number: 3995 On Wed, 2003-10-08 at 15:38, Jeff wrote: > Huh. I could have sworn Tom did something like that. > Perhaps I am thinking of something else. > You had to enable some magic GUC. Perhaps you're thinking of the new GUC var join_collapse_limit, which is related, but doesn't effect the reordering of outer joins. -Neil From pgsql-performance-owner@postgresql.org Wed Oct 8 19:23:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A9DDED1B4E2 for ; Wed, 8 Oct 2003 22:23:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 56083-07 for ; Wed, 8 Oct 2003 19:22:43 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 60847D1B556 for ; Wed, 8 Oct 2003 19:22:40 -0300 (ADT) 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 h98MMXhn005443; Wed, 8 Oct 2003 18:22:34 -0400 (EDT) To: Andriy Tkachuk Cc: pgsql-performance@postgresql.org Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql In-reply-to: <20031008152741.P17672-100000@pool.imt.com.ua> References: <20031008152741.P17672-100000@pool.imt.com.ua> Comments: In-reply-to Andriy Tkachuk message dated "Wed, 08 Oct 2003 16:16:52 +0300" Date: Wed, 08 Oct 2003 18:22:32 -0400 Message-ID: <5442.1065651752@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/248 X-Sequence-Number: 3996 Andriy Tkachuk writes: > At second. calc_total() is immutable function: > but it seems that it's not cached in one session: It's not supposed to be. The reason the "runtime" is small in your example is that the planner executes the function call while preparing the plan, and this isn't counted in EXPLAIN's runtime measurement. There's no claim anywhere that the results of such an evaluation would be saved for other plans. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 8 20:15:12 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0A579D1B50F for ; Wed, 8 Oct 2003 23:15:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67234-02 for ; Wed, 8 Oct 2003 20:14:25 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id A99E2D1B4EE for ; Wed, 8 Oct 2003 20:14:21 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3743025; Wed, 08 Oct 2003 16:14:31 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Greg Spiegelberg , PgSQL Performance ML Subject: Re: Compare rows Date: Wed, 8 Oct 2003 16:11:59 -0700 User-Agent: KMail/1.4.3 References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> In-Reply-To: <3F84613D.8040207@cranel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310081611.59179.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/249 X-Sequence-Number: 3997 Greg, > You lost me on that one. What's a "vertical child table"? Currently, you store data like this: id address uptime speed memory tty 3 67.92 0.3 11.2 37 6 7 69.5 1.1 NULL 15 NULL 9 65.5 0.1 NULL 94 2 The most efficient way for you to store data would be like this: main table id address 3 67.92 7 69.5 9 65.5 child table id value_type value 3 uptime 0.3 3 speed 11.2 3 memory 37 3 tty 6 7 uptime 1.1 7 memory 15 9 uptime 0.1 9 memory 94 9 tty 2 As you can see, the NULLs are not stored, making this system much more=20 efficient on storage space. Tommorrow I'll (hopefully) write up how to query this for comparisons. It= =20 would help if you gave a little more details about what specific comparison= =20 you're doing, e.g. between tables or table to value, comparing just the las= t=20 value or all rows, etc. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 8 20:29:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 57ED7D1B516 for ; Wed, 8 Oct 2003 23:29:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66954-07 for ; Wed, 8 Oct 2003 20:28:43 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id DDBF2D1B50F for ; Wed, 8 Oct 2003 20:28:39 -0300 (ADT) 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 h98NSghn005816; Wed, 8 Oct 2003 19:28:42 -0400 (EDT) To: Jeff Cc: Neil Conway , PostgreSQL Performance Subject: Re: Presentation In-reply-to: References: Comments: In-reply-to Jeff message dated "Wed, 08 Oct 2003 15:38:37 -0400" Date: Wed, 08 Oct 2003 19:28:42 -0400 Message-ID: <5815.1065655722@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/250 X-Sequence-Number: 3998 Jeff writes: > On Wed, 8 Oct 2003, Neil Conway wrote: >> Slide 37: as far as I know, reordering of outer joins is not implemented >> in 7.4 > Huh. I could have sworn Tom did something like that. Not yet. 7.4 can reorder *inner* joins that happen to be written with JOIN syntax. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 8 21:07:45 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 96D8CD1B564 for ; Thu, 9 Oct 2003 00:07:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83648-01 for ; Wed, 8 Oct 2003 21:07:00 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 94802D1B53E for ; Wed, 8 Oct 2003 21:06:56 -0300 (ADT) 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 h9906xhn005962; Wed, 8 Oct 2003 20:07:00 -0400 (EDT) To: Neil Conway Cc: Bruce Momjian , Jeff , PostgreSQL Performance , PostgreSQL Hackers Subject: Re: Sun performance - Major discovery! In-reply-to: <1065638251.3423.37.camel@tokyo> References: <200310081831.h98IVT919657@candle.pha.pa.us> <1065638251.3423.37.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Wed, 08 Oct 2003 14:37:31 -0400" Date: Wed, 08 Oct 2003 20:06:59 -0400 Message-ID: <5961.1065658019@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/251 X-Sequence-Number: 3999 Neil Conway writes: > On Wed, 2003-10-08 at 14:31, Bruce Momjian wrote: >> Well, this is really embarassing. I can't imagine why we would not set >> at least -O on all platforms. I believe that autoconf will automatically select -O2 (when CFLAGS isn't already set) *if* it's chosen gcc. It won't select anything for vendor ccs. > Can we get these optimizations enabled in time for the next 7.4 beta? I think it's too late in the beta cycle to add optimization flags except for platforms we can get specific success results for. (Solaris is probably okay for instance.) The risk of breaking things seems too high. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 13:46:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F363D1B57F for ; Thu, 9 Oct 2003 00:25:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77573-09 for ; Wed, 8 Oct 2003 21:24:41 -0300 (ADT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 60EF6D1B558 for ; Wed, 8 Oct 2003 21:24:21 -0300 (ADT) Received: (qmail 14271 invoked by uid 65534); 9 Oct 2003 00:24:24 -0000 Received: from dsl-082-082-165-222.arcor-ip.net (EHLO dsl-082-082-165-222.arcor-ip.net) (82.82.165.222) by mail.gmx.net (mp023) with SMTP; 09 Oct 2003 02:24:24 +0200 X-Authenticated: #495269 Date: Thu, 9 Oct 2003 02:24:24 +0200 (CEST) From: Peter Eisentraut X-X-Sender: peter@peter.localdomain To: Bruce Momjian Cc: Jeff , Neil Conway , PostgreSQL Performance , PostgreSQL-development Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: <200310081831.h98IVT919657@candle.pha.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: 200310/452 X-Sequence-Number: 4200 Bruce Momjian writes: > Well, this is really embarassing. I can't imagine why we would not set > at least -O on all platforms. Looking at the template files, I see > these have no optimization set: > freebsd (non-alpha) I'm wondering what that had in mind: http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/template/freebsd.diff?r1=1.10&r2=1.11 -- Peter Eisentraut peter_e@gmx.net From pgsql-performance-owner@postgresql.org Wed Oct 8 22:45:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 986F8D1B4EA; Thu, 9 Oct 2003 01:45:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 94913-05; Wed, 8 Oct 2003 22:44:39 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id BD659D1B4E3; Wed, 8 Oct 2003 22:44:34 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h991iQq24994; Wed, 8 Oct 2003 21:44:26 -0400 (EDT) From: Bruce Momjian Message-Id: <200310090144.h991iQq24994@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: <5961.1065658019@sss.pgh.pa.us> To: Tom Lane Date: Wed, 8 Oct 2003 21:44:26 -0400 (EDT) Cc: Neil Conway , Jeff , PostgreSQL Performance , PostgreSQL Hackers X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/252 X-Sequence-Number: 4000 Tom Lane wrote: > Neil Conway writes: > > On Wed, 2003-10-08 at 14:31, Bruce Momjian wrote: > >> Well, this is really embarassing. I can't imagine why we would not set > >> at least -O on all platforms. > > I believe that autoconf will automatically select -O2 (when CFLAGS isn't > already set) *if* it's chosen gcc. It won't select anything for vendor > ccs. I think the problem is that template/solaris overrides that with: CFLAGS= > > Can we get these optimizations enabled in time for the next 7.4 beta? > > I think it's too late in the beta cycle to add optimization flags except > for platforms we can get specific success results for. (Solaris is > probably okay for instance.) The risk of breaking things seems too > high. Agreed. Do we set them all to -O2, then remove it from the ones we don't get successful reports on? -- 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 Oct 8 22:49:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D72AED1B54E; Thu, 9 Oct 2003 01:49:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 94103-09; Wed, 8 Oct 2003 22:48:26 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id DCC7CD1B527; Wed, 8 Oct 2003 22:48:21 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h991mEc25313; Wed, 8 Oct 2003 21:48:14 -0400 (EDT) From: Bruce Momjian Message-Id: <200310090148.h991mEc25313@candle.pha.pa.us> Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: To: Peter Eisentraut Date: Wed, 8 Oct 2003 21:48:14 -0400 (EDT) Cc: Jeff , Neil Conway , PostgreSQL Performance , PostgreSQL-development X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/253 X-Sequence-Number: 4001 Peter Eisentraut wrote: > Bruce Momjian writes: > > > Well, this is really embarassing. I can't imagine why we would not set > > at least -O on all platforms. Looking at the template files, I see > > these have no optimization set: > > > freebsd (non-alpha) > > I'm wondering what that had in mind: > > http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/template/freebsd.diff?r1=1.10&r2=1.11 I was wondering that myself. I think the idea was that we already do -O2 in configure if it is gcc, so why do it in the template files. What is killing us is the CFLAGS= lines in the configuration files. -- 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 Oct 8 23:05:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9ACBCD1B4E9; Thu, 9 Oct 2003 02:05:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97266-03; Wed, 8 Oct 2003 23:04:31 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9CBF7D1B4E5; Wed, 8 Oct 2003 23:04:26 -0300 (ADT) 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 h9924FhI040857; Thu, 9 Oct 2003 10:04:15 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3F84C2CF.5000000@familyhealth.com.au> Date: Thu, 09 Oct 2003 10:07:11 +0800 From: Christopher Kings-Lynne 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: Peter Eisentraut Cc: Bruce Momjian , Jeff , Neil Conway , PostgreSQL Performance , PostgreSQL-development Subject: Re: [HACKERS] Sun performance - Major discovery! 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: 200310/254 X-Sequence-Number: 4002 >>Well, this is really embarassing. I can't imagine why we would not set >>at least -O on all platforms. Looking at the template files, I see >>these have no optimization set: > > >> freebsd (non-alpha) > > > I'm wondering what that had in mind: > > http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/template/freebsd.diff?r1=1.10&r2=1.11 When I used to build pgsql on freebsd/alpha, I would get heaps of GCC warnings saying 'optimisations for the alpha are broken'. I can't remember if that meant anything more than just -O or not though. Chris From pgsql-performance-owner@postgresql.org Wed Oct 8 23:21:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 22EF4D1B4EA for ; Thu, 9 Oct 2003 02:21:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97971-04 for ; Wed, 8 Oct 2003 23:20:49 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 4B9F5D1B4E5 for ; Wed, 8 Oct 2003 23:20:45 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h992KjQh064818 for ; Thu, 9 Oct 2003 02:20:45 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h992CI4X063933 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 02:12:18 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Compare rows Date: Wed, 08 Oct 2003 22:07:46 -0400 Organization: cbbrowne Computing Inc Lines: 49 Message-ID: References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> <200310081611.59179.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:Y8GqMk3RazDLQoI7X5cNifUzmBU= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/255 X-Sequence-Number: 4003 In an attempt to throw the authorities off his trail, josh@agliodbs.com (Josh Berkus) transmitted: > child table > id value_type value > 3 uptime 0.3 > 3 speed 11.2 > 3 memory 37 > 3 tty 6 > 7 uptime 1.1 > 7 memory 15 > 9 uptime 0.1 > 9 memory 94 > 9 tty 2 > > As you can see, the NULLs are not stored, making this system much more > efficient on storage space. Wow, that takes me back to a paper I have been looking for for _years_. Some time in the late '80s, probably '88 or '89, there was a paper presented in Communications of the ACM that proposed using this sort of "hypernormalized" schema as a way of having _really_ narrow schemas that would be exceedingly expressive. They illustrated an example of an address table that could hold full addresses with a schema with only about half a dozen columns, the idea being that you'd have several rows linked together. The methodology was _heavy_ on metadata, though not so much so that there were no columns left over for "real" data. The entertaining claim was that they felt they could model the complexities of the operations of any sort of company using not more than 50 tables. It seemed somewhat interesting, at the time; it truly resonated as Really Interesting when I saw SAP R/3, with its bloat of 1500-odd tables. (I seem to remember the authors being Boston-based, and they indicated that they had implemented this "on VMS," which would more than likely imply RDB; somehow I doubt that'll be the set of detail that makes someone remember it...) The need to do a lot of joins would likely hurt performance somewhat, as well as the way that it greatly increases the number of rows. Although you could always split it into several tables, one for each "value_type", and UNION them into a view... -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). http://cbbrowne.com/info/unix.html You shouldn't anthropomorphize computers; they don't like it. From pgsql-performance-owner@postgresql.org Thu Oct 9 00:21:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 22EB5D1B51E; Thu, 9 Oct 2003 03:20:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 18288-01; Thu, 9 Oct 2003 00:20:03 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3C3F7D1B519; Thu, 9 Oct 2003 00:20:00 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h993JpM10523; Wed, 8 Oct 2003 23:19:51 -0400 (EDT) From: Bruce Momjian Message-Id: <200310090319.h993JpM10523@candle.pha.pa.us> Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: <5961.1065658019@sss.pgh.pa.us> To: Tom Lane Date: Wed, 8 Oct 2003 23:19:51 -0400 (EDT) Cc: Neil Conway , Jeff , PostgreSQL Performance , PostgreSQL Hackers X-Mailer: ELM [version 2.4ME+ PL106 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM1065669591-21241-1_ Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/256 X-Sequence-Number: 4004 --ELM1065669591-21241-1_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Tom Lane wrote: > Neil Conway writes: > > On Wed, 2003-10-08 at 14:31, Bruce Momjian wrote: > >> Well, this is really embarassing. I can't imagine why we would not set > >> at least -O on all platforms. > > I believe that autoconf will automatically select -O2 (when CFLAGS isn't > already set) *if* it's chosen gcc. It won't select anything for vendor > ccs. > > > Can we get these optimizations enabled in time for the next 7.4 beta? > > I think it's too late in the beta cycle to add optimization flags except > for platforms we can get specific success results for. (Solaris is > probably okay for instance.) The risk of breaking things seems too > high. OK, patch attached and applied. It centralizes the optimization defaults into configure.in, rather than having CFLAGS= in the template files. It used -O2 for gcc (generated automatically by autoconf), and -O for non-gcc, unless the template overrides 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 --ELM1065669591-21241-1_ Content-Transfer-Encoding: 7bit Content-Type: text/plain Content-Disposition: inline; filename="/bjm/diff" Index: configure =================================================================== RCS file: /cvsroot/pgsql-server/configure,v retrieving revision 1.302 diff -c -c -r1.302 configure *** configure 3 Oct 2003 03:08:14 -0000 1.302 --- configure 9 Oct 2003 03:16:44 -0000 *************** *** 2393,2398 **** --- 2393,2402 ---- if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value fi + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc + if test x"$CFLAGS" = x""; then + CFLAGS="-O" + fi if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then CFLAGS="$CFLAGS -g" fi Index: configure.in =================================================================== RCS file: /cvsroot/pgsql-server/configure.in,v retrieving revision 1.293 diff -c -c -r1.293 configure.in *** configure.in 3 Oct 2003 03:08:14 -0000 1.293 --- configure.in 9 Oct 2003 03:16:46 -0000 *************** *** 238,243 **** --- 238,247 ---- if test "$ac_env_CFLAGS_set" = set; then CFLAGS=$ac_env_CFLAGS_value fi + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc + if test x"$CFLAGS" = x""; then + CFLAGS="-O" + fi if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then CFLAGS="$CFLAGS -g" fi Index: src/template/beos =================================================================== RCS file: /cvsroot/pgsql-server/src/template/beos,v retrieving revision 1.6 diff -c -c -r1.6 beos *** src/template/beos 21 Oct 2000 22:36:13 -0000 1.6 --- src/template/beos 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS='-O2' --- 0 ---- Index: src/template/bsdi =================================================================== RCS file: /cvsroot/pgsql-server/src/template/bsdi,v retrieving revision 1.16 diff -c -c -r1.16 bsdi *** src/template/bsdi 27 Sep 2003 16:24:44 -0000 1.16 --- src/template/bsdi 9 Oct 2003 03:16:51 -0000 *************** *** 5,13 **** esac case $host_os in ! bsdi2.0 | bsdi2.1 | bsdi3*) ! CC=gcc2 ! ;; esac THREAD_SUPPORT=yes --- 5,11 ---- esac case $host_os in ! bsdi2.0 | bsdi2.1 | bsdi3*) CC=gcc2;; esac THREAD_SUPPORT=yes Index: src/template/cygwin =================================================================== RCS file: /cvsroot/pgsql-server/src/template/cygwin,v retrieving revision 1.2 diff -c -c -r1.2 cygwin *** src/template/cygwin 9 Oct 2003 02:37:09 -0000 1.2 --- src/template/cygwin 9 Oct 2003 03:16:51 -0000 *************** *** 1,2 **** - CFLAGS='-O2' SRCH_LIB='/usr/local/lib' --- 1 ---- Index: src/template/dgux =================================================================== RCS file: /cvsroot/pgsql-server/src/template/dgux,v retrieving revision 1.10 diff -c -c -r1.10 dgux *** src/template/dgux 21 Oct 2000 22:36:13 -0000 1.10 --- src/template/dgux 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS= --- 0 ---- Index: src/template/freebsd =================================================================== RCS file: /cvsroot/pgsql-server/src/template/freebsd,v retrieving revision 1.23 diff -c -c -r1.23 freebsd *** src/template/freebsd 27 Sep 2003 16:24:44 -0000 1.23 --- src/template/freebsd 9 Oct 2003 03:16:51 -0000 *************** *** 1,17 **** - CFLAGS='-pipe' - case $host_cpu in ! alpha*) CFLAGS="$CFLAGS -O" ;; esac THREAD_SUPPORT=yes NEED_REENTRANT_FUNCS=yes THREAD_CPPFLAGS="-D_THREAD_SAFE" case $host_os in ! freebsd2*|freebsd3*|freebsd4*) ! THREAD_LIBS="-pthread" ! ;; ! *) ! THREAD_LIBS="-lc_r" ! ;; esac --- 1,11 ---- case $host_cpu in ! alpha*) CFLAGS="-O";; esac THREAD_SUPPORT=yes NEED_REENTRANT_FUNCS=yes THREAD_CPPFLAGS="-D_THREAD_SAFE" case $host_os in ! freebsd2*|freebsd3*|freebsd4*) THREAD_LIBS="-pthread";; ! *) THREAD_LIBS="-lc_r";; esac Index: src/template/hpux =================================================================== RCS file: /cvsroot/pgsql-server/src/template/hpux,v retrieving revision 1.7 diff -c -c -r1.7 hpux *** src/template/hpux 2 Apr 2003 00:49:28 -0000 1.7 --- src/template/hpux 9 Oct 2003 03:16:51 -0000 *************** *** 1,8 **** ! if test "$GCC" = yes ; then ! CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED" ! CFLAGS="-O2" ! else CC="$CC -Ae" - CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED" CFLAGS="+O2" fi --- 1,6 ---- ! CPPFLAGS="-D_XOPEN_SOURCE_EXTENDED" ! ! if test "$GCC" != yes ; then CC="$CC -Ae" CFLAGS="+O2" fi Index: src/template/irix5 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/irix5,v retrieving revision 1.9 diff -c -c -r1.9 irix5 *** src/template/irix5 21 Oct 2000 22:36:13 -0000 1.9 --- src/template/irix5 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS= --- 0 ---- Index: src/template/linux =================================================================== RCS file: /cvsroot/pgsql-server/src/template/linux,v retrieving revision 1.18 diff -c -c -r1.18 linux *** src/template/linux 27 Sep 2003 22:23:35 -0000 1.18 --- src/template/linux 9 Oct 2003 03:16:51 -0000 *************** *** 1,4 **** - CFLAGS=-O2 # Force _GNU_SOURCE on; plperl is broken with Perl 5.8.0 otherwise CPPFLAGS="-D_GNU_SOURCE" --- 1,3 ---- *************** *** 6,9 **** NEED_REENTRANT_FUNCS=yes # Debian kernel 2.2 2003-09-27 THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS" THREAD_LIBS="-lpthread" - --- 5,7 ---- Index: src/template/netbsd =================================================================== RCS file: /cvsroot/pgsql-server/src/template/netbsd,v retrieving revision 1.13 diff -c -c -r1.13 netbsd *** src/template/netbsd 27 Sep 2003 16:24:44 -0000 1.13 --- src/template/netbsd 9 Oct 2003 03:16:51 -0000 *************** *** 1,4 **** - CFLAGS='-O2 -pipe' - THREAD_SUPPORT=yes NEED_REENTRANT_FUNCS=yes # 1.6 2003-09-14 --- 1,2 ---- Index: src/template/nextstep =================================================================== RCS file: /cvsroot/pgsql-server/src/template/nextstep,v retrieving revision 1.7 diff -c -c -r1.7 nextstep *** src/template/nextstep 15 Jul 2000 15:54:52 -0000 1.7 --- src/template/nextstep 9 Oct 2003 03:16:51 -0000 *************** *** 1,4 **** AROPT=rc - CFLAGS= SHARED_LIB= DLSUFFIX=.o --- 1,3 ---- Index: src/template/openbsd =================================================================== RCS file: /cvsroot/pgsql-server/src/template/openbsd,v retrieving revision 1.8 diff -c -c -r1.8 openbsd *** src/template/openbsd 21 Oct 2000 22:36:14 -0000 1.8 --- src/template/openbsd 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS='-O2 -pipe' --- 0 ---- Index: src/template/osf =================================================================== RCS file: /cvsroot/pgsql-server/src/template/osf,v retrieving revision 1.10 diff -c -c -r1.10 osf *** src/template/osf 27 Sep 2003 16:24:45 -0000 1.10 --- src/template/osf 9 Oct 2003 03:16:51 -0000 *************** *** 1,6 **** ! if test "$GCC" = yes ; then ! CFLAGS= ! else CC="$CC -std" CFLAGS='-O4 -Olimit 2000' fi --- 1,4 ---- ! if test "$GCC" != yes ; then CC="$CC -std" CFLAGS='-O4 -Olimit 2000' fi Index: src/template/qnx4 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/qnx4,v retrieving revision 1.4 diff -c -c -r1.4 qnx4 *** src/template/qnx4 24 May 2001 22:33:18 -0000 1.4 --- src/template/qnx4 9 Oct 2003 03:16:51 -0000 *************** *** 1,2 **** ! CFLAGS=-I/usr/local/include ! LIBS=-lunix --- 1,2 ---- ! CFLAGS="-O2 -I/usr/local/include" ! LIBS="-lunix" Index: src/template/sco =================================================================== RCS file: /cvsroot/pgsql-server/src/template/sco,v retrieving revision 1.10 diff -c -c -r1.10 sco *** src/template/sco 11 Dec 2002 22:27:26 -0000 1.10 --- src/template/sco 9 Oct 2003 03:16:51 -0000 *************** *** 1,7 **** - if test "$GCC" = yes; then - CFLAGS=-O2 - else - CFLAGS=-O - fi CC="$CC -b elf" --- 1,2 ---- Index: src/template/solaris =================================================================== RCS file: /cvsroot/pgsql-server/src/template/solaris,v retrieving revision 1.5 diff -c -c -r1.5 solaris *** src/template/solaris 27 Sep 2003 16:24:45 -0000 1.5 --- src/template/solaris 9 Oct 2003 03:16:51 -0000 *************** *** 1,8 **** ! if test "$GCC" = yes ; then ! CFLAGS= ! else CC="$CC -Xa" # relaxed ISO C mode ! CFLAGS=-v # -v is like gcc -Wall fi THREAD_SUPPORT=yes --- 1,6 ---- ! if test "$GCC" != yes ; then CC="$CC -Xa" # relaxed ISO C mode ! CFLAGS="-O -v" # -v is like gcc -Wall fi THREAD_SUPPORT=yes Index: src/template/sunos4 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/sunos4,v retrieving revision 1.2 diff -c -c -r1.2 sunos4 *** src/template/sunos4 21 Oct 2000 22:36:14 -0000 1.2 --- src/template/sunos4 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS= --- 0 ---- Index: src/template/svr4 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/svr4,v retrieving revision 1.10 diff -c -c -r1.10 svr4 *** src/template/svr4 21 Oct 2000 22:36:14 -0000 1.10 --- src/template/svr4 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS= --- 0 ---- Index: src/template/ultrix4 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/ultrix4,v retrieving revision 1.10 diff -c -c -r1.10 ultrix4 *** src/template/ultrix4 21 Oct 2000 22:36:14 -0000 1.10 --- src/template/ultrix4 9 Oct 2003 03:16:51 -0000 *************** *** 1 **** - CFLAGS= --- 0 ---- Index: src/template/univel =================================================================== RCS file: /cvsroot/pgsql-server/src/template/univel,v retrieving revision 1.13 diff -c -c -r1.13 univel *** src/template/univel 21 Oct 2000 22:36:14 -0000 1.13 --- src/template/univel 9 Oct 2003 03:16:51 -0000 *************** *** 1,2 **** CFLAGS='-v -O -K i486,host,inline,loop_unroll -Dsvr4' ! LIBS=-lc89 --- 1,2 ---- CFLAGS='-v -O -K i486,host,inline,loop_unroll -Dsvr4' ! LIBS="-lc89" Index: src/template/unixware =================================================================== RCS file: /cvsroot/pgsql-server/src/template/unixware,v retrieving revision 1.24 diff -c -c -r1.24 unixware *** src/template/unixware 27 Sep 2003 16:24:45 -0000 1.24 --- src/template/unixware 9 Oct 2003 03:16:51 -0000 *************** *** 1,5 **** if test "$GCC" = yes; then - CFLAGS=-O2 THREAD_CPPFLAGS="-pthread" else # the -Kno_host is temporary for a bug in the compiler. See -hackers --- 1,4 ---- Index: src/template/win =================================================================== RCS file: /cvsroot/pgsql-server/src/template/win,v retrieving revision 1.5 diff -c -c -r1.5 win *** src/template/win 8 Oct 2003 18:23:08 -0000 1.5 --- src/template/win 9 Oct 2003 03:16:51 -0000 *************** *** 1,3 **** - if test "$GCC" = yes; then - CFLAGS="-O2" - fi --- 0 ---- Index: src/template/win32 =================================================================== RCS file: /cvsroot/pgsql-server/src/template/win32,v retrieving revision 1.1 diff -c -c -r1.1 win32 *** src/template/win32 15 May 2003 16:35:30 -0000 1.1 --- src/template/win32 9 Oct 2003 03:16:51 -0000 *************** *** 1,3 **** - if test "$GCC" = yes; then - CFLAGS="-O2" - fi --- 0 ---- --ELM1065669591-21241-1_-- From pgsql-performance-owner@postgresql.org Thu Oct 9 02:11:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DBC4DD1B4F9 for ; Thu, 9 Oct 2003 05:11:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29698-09 for ; Thu, 9 Oct 2003 02:10:55 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id AFEAED1B4E5 for ; Thu, 9 Oct 2003 02:10:54 -0300 (ADT) 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 h995Ashn007535; Thu, 9 Oct 2003 01:10:54 -0400 (EDT) To: Bruce Momjian Cc: Neil Conway , Jeff , PostgreSQL Performance , PostgreSQL Hackers Subject: Re: [HACKERS] Sun performance - Major discovery! In-reply-to: <200310090319.h993JpM10523@candle.pha.pa.us> References: <200310090319.h993JpM10523@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Wed, 08 Oct 2003 23:19:51 -0400" Date: Thu, 09 Oct 2003 01:10:54 -0400 Message-ID: <7534.1065676254@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/257 X-Sequence-Number: 4005 From pgsql-performance-owner@postgresql.org Thu Oct 9 02:39:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C1552D1B4E3 for ; Thu, 9 Oct 2003 05:39:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40813-01 for ; Thu, 9 Oct 2003 02:38:57 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 89259D1B4E2 for ; Thu, 9 Oct 2003 02:38:56 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3744201; Wed, 08 Oct 2003 22:39:33 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: Compare rows Date: Wed, 8 Oct 2003 22:36:59 -0700 User-Agent: KMail/1.4.3 References: <3F841A28.8060504@cranel.com> <200310081611.59179.josh@agliodbs.com> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310082236.59305.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/258 X-Sequence-Number: 4006 Chris, > Some time in the late '80s, probably '88 or '89, there was a paper > presented in Communications of the ACM that proposed using this sort > of "hypernormalized" schema as a way of having _really_ narrow schemas > that would be exceedingly expressive. They illustrated an example of > The entertaining claim was that they felt they could model the > complexities of the operations of any sort of company using not more > than 50 tables. It seemed somewhat interesting, at the time; it truly > resonated as Really Interesting when I saw SAP R/3, with its bloat of > 1500-odd tables. One can always take things too far. Trying to make everying 100% dynamic so that you can cram your whole database into 4 tables is going too far; so is the kind of bloat that produces systems like SAP, which is more based on legacy than design (I analyzed a large commercial billing system once and was startled to discover that 1/4 of its 400 tables and almost half of the 40,000 collective columns were not used and present only for backward compatibility). The usefulness of the "vertical values child table" which I suggest is largely dependant on the number of values not represented. In Greg's case, fully 75% of the fields in his huge table are NULL; this is incredibly inefficient, the more so when you consider his task of calling each field by name in each query. The "vertical values child table" is also ideal for User Defined Fields or any other form of user-configurable add-on data which will be NULL more often than not. This is an old SQL concept, though; I'm sure it has an official name somewhere. > The need to do a lot of joins would likely hurt performance somewhat, > as well as the way that it greatly increases the number of rows. > Although you could always split it into several tables, one for each > "value_type", and UNION them into a view... It increases the number of rows, yes, but *decreases* the storage size of data by eliminating thousands ... or millions ... of NULL fields. How would splitting the vertical values into dozens of seperate tables help things? Personally, I'd rather have a table with 3 columns and 8 million rows than a table with 642 columns and 100,000 rows. Much easier to deal with. And we are also assuming that Greg seldom needs to see all of the fields at once. I'm pretty sure of this; if he did, he'd have run into the "wide row" bug in 7.3 and would be complaining about it. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 9 04:26:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 33E51D1B553 for ; Thu, 9 Oct 2003 07:26:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 58908-03 for ; Thu, 9 Oct 2003 04:25:49 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id 977FBD1B564 for ; Thu, 9 Oct 2003 04:25:44 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h997PZ4r029986; Thu, 9 Oct 2003 10:25:36 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h997PX1d029983; Thu, 9 Oct 2003 10:25:34 +0300 (EEST) (envelope-from ant@imt.com.ua) Date: Thu, 9 Oct 2003 10:25:33 +0300 (EEST) From: Andriy Tkachuk To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql In-Reply-To: <5442.1065651752@sss.pgh.pa.us> Message-ID: <20031009101121.S29282-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/259 X-Sequence-Number: 4007 On Wed, 8 Oct 2003, Tom Lane wrote: > Andriy Tkachuk writes: > > At second. calc_total() is immutable function: > > but it seems that it's not cached in one session: > > It's not supposed to be. but it's written id doc: IMMUTABLE indicates that the function always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its parameter list. If this option is given, any call of the function with all-constant arguments can be immediately replaced with the function value. I meant that the result of calc_total() is not "immediately replaced with the function value" as it's written in doc, but it takes as long time as the first function call in the session (with the same arguments). Maybe i misunderstand something? Thank you, Andriy Tkachuk. http://www.imt.com.ua From pgsql-performance-owner@postgresql.org Thu Oct 9 05:29:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 61762D1B553 for ; Thu, 9 Oct 2003 08:29:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 61309-07 for ; Thu, 9 Oct 2003 05:29:06 -0300 (ADT) Received: from deun2kex01.REALGARANT.DE (mail.realgarant.de [195.143.134.176]) by svr1.postgresql.org (Postfix) with ESMTP id D4D34D1B528 for ; Thu, 9 Oct 2003 05:29:03 -0300 (ADT) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: go for a script! / ex: PostgreSQL vs. MySQL X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Date: Thu, 9 Oct 2003 10:29:52 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] PostgreSQL vs. MySQL Thread-Index: AcON1t6NoxzXE/5XQiued7isQ4zjnQAZalwg From: "Oliver Scheit" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/260 X-Sequence-Number: 4008 Hi guys, I followed the discussion and here are my 0.2$: I think instead of thinking about where to put the information about tuning, someone should provide a "pgsql-autotune". Maybe even a shell script would do the trick. It's not so hard to find out, how much memory is installed, and IMHO SHARED_BUFFERS, SORT_MEM and EFFECTIVE_CACHE_SIZE depend heavily on this. a "cat /proc/sys/kernel/shmmax" would give some valuable information on linux boxes, there is probably other stuff for different OSes. random_page_cost could be set after probing the harddisks, maybe even do a hdparm -tT if they seem to be ATA, not SCSI. Now, let's pretend the script finds out there is 1 GB RAM, it could ask something like "Do you want to optimize the settings for postgres (other applications may suffer from having not enough RAM) or do you want to use moderate settings?" Something like this, you get the idea. This would give new users a much more usable start than the current default settings and would still leave all the options to do fine-tuning later. I guess my point is simply this: instead of saying: "okay we use default settings that will run on _old_ hardware too" we should go for a little script that creates a "still save but much better" config file. There's just no point in setting SHARED_BUFFERS to something like 16 (what's the current default?) if the PC has >=3D 1 GB of RAM. Setting it to 8192 would still be save, but 512 times better... ;-) (IIRC 8192 would take 64 MB of RAM, which should be save if you leave the default MAX_CONNECTIONS.) As said before: just my $0.2 My opinion on this case is Open Source. Feel free to modify and add. :-) regards, Oli From pgsql-performance-owner@postgresql.org Thu Oct 9 06:54:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E7D04D1B50A for ; Thu, 9 Oct 2003 09:54:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81398-01 for ; Thu, 9 Oct 2003 06:53:39 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 53622D1B4F0 for ; Thu, 9 Oct 2003 06:53:36 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A7XUJ-0006N6-00 for ; Thu, 09 Oct 2003 05:53:39 -0400 Received: by dba2 (Postfix, from userid 1019) id CF576CCC2; Thu, 9 Oct 2003 05:53:38 -0400 (EDT) Date: Thu, 9 Oct 2003 05:53:38 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: PostgreSQL vs. MySQL Message-ID: <20031009095338.GF13500@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030704182853.GK4707@libertyrms.info> <200310081728.h98HSr811803@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310081728.h98HSr811803@candle.pha.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/261 X-Sequence-Number: 4009 On Wed, Oct 08, 2003 at 01:28:53PM -0400, Bruce Momjian wrote: > > Agreed. Text added to install docs: [&c.] I think this is just right. It tells a user where to find the info needed, doesn't reproduce it all over the place, and still points out that this is something you'd better do. Combined with the new probe-to-set-shared-buffers bit at install time, I think the reports of 400 billion times worse performance than MySQL will probably diminish. 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 Oct 9 07:13:47 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1F23BD1B4E1 for ; Thu, 9 Oct 2003 10:13:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 88159-02 for ; Thu, 9 Oct 2003 07:12:58 -0300 (ADT) 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 AB831D1B506 for ; Thu, 9 Oct 2003 07:12:55 -0300 (ADT) Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] helo=bacon.tmsl.demon.co.uk) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 1A7Xmz-000P42-0X for pgsql-performance@postgresql.org; Thu, 09 Oct 2003 11:12:57 +0100 Date: Thu, 9 Oct 2003 11:12:55 +0100 From: Paul Thomas To: "pgsql-performance @ postgresql . org" Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031009111255.A17336@bacon> References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=ISO-8859-1 In-Reply-To: ; from oliver.scheit@REALGARANT.DE on Thu, Oct 09, 2003 at 09:29:52 +0100 X-Mailer: Balsa 1.2.3 Lines: 41 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/262 X-Sequence-Number: 4010 On 09/10/2003 09:29 Oliver Scheit wrote: > Hi guys, > > I followed the discussion and here are my 0.2$: > > I think instead of thinking about where to put the > information about tuning, someone should provide a > "pgsql-autotune". Maybe even a shell script would do the > trick. > > It's not so hard to find out, how much memory is installed, > and IMHO SHARED_BUFFERS, SORT_MEM and EFFECTIVE_CACHE_SIZE > depend heavily on this. a "cat /proc/sys/kernel/shmmax" > would give some valuable information on linux boxes, > there is probably other stuff for different OSes. > > random_page_cost could be set after probing the harddisks, > maybe even do a hdparm -tT if they seem to be ATA, not SCSI. > > Now, let's pretend the script finds out there is 1 GB RAM, > it could ask something like "Do you want to optimize the > settings for postgres (other applications may suffer from > having not enough RAM) or do you want to use moderate > settings?" > > Something like this, you get the idea. ISR reading that 7.4 will use a default of shared_beffers = 1000 if the machine can support it (most can). This alone should make a big difference in out-of-the-box performance. -- Paul Thomas +------------------------------+---------------------------------------------+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +------------------------------+---------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Oct 9 08:13:45 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D56A7D1B51B for ; Thu, 9 Oct 2003 11:13:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 97093-01 for ; Thu, 9 Oct 2003 08:12:59 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id A05FDD1B50A for ; Thu, 9 Oct 2003 08:12:54 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h99BI00b028055 for ; Thu, 9 Oct 2003 16:48:00 +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 h99BHxNs028027 for ; Thu, 9 Oct 2003 16:47:59 +0530 Message-ID: <3F8542B5.6070209@persistent.co.in> Date: Thu, 09 Oct 2003 16:42:53 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Performance Subject: Linux filesystem shootout 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: 200310/263 X-Sequence-Number: 4011 http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html Shridhar From pgsql-performance-owner@postgresql.org Thu Oct 9 08:51:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6FA24D1B56A for ; Thu, 9 Oct 2003 11:51:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00339-02 for ; Thu, 9 Oct 2003 08:50:54 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 84BC5D1B52E for ; Thu, 9 Oct 2003 08:50:51 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h99BopQh052086 for ; Thu, 9 Oct 2003 11:50:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h99BiGXc050951 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 11:44:16 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Compare rows Date: Thu, 09 Oct 2003 07:41:28 -0400 Organization: cbbrowne Computing Inc Lines: 32 Message-ID: References: <3F841A28.8060504@cranel.com> <200310081611.59179.josh@agliodbs.com> <200310082236.59305.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:za8sSPx7iWy7lQcTUIlgPHc980I= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/264 X-Sequence-Number: 4012 The world rejoiced as josh@agliodbs.com (Josh Berkus) wrote: > Chris, >> Some time in the late '80s, probably '88 or '89, there was a paper >> presented in Communications of the ACM that proposed using this sort >> of "hypernormalized" schema as a way of having _really_ narrow schemas >> that would be exceedingly expressive. They illustrated an example of > >> The entertaining claim was that they felt they could model the >> complexities of the operations of any sort of company using not >> more than 50 tables. It seemed somewhat interesting, at the time; >> it truly resonated as Really Interesting when I saw SAP R/3, with >> its bloat of 1500-odd tables. > > One can always take things too far. Trying to make everying 100% > dynamic so that you can cram your whole database into 4 tables is > going too far; so is the kind of bloat that produces systems like > SAP, which is more based on legacy than design (I analyzed a large > commercial billing system once and was startled to discover that 1/4 > of its 400 tables and almost half of the 40,000 collective columns > were not used and present only for backward compatibility). With R/3, the problem is that there are hundreds (now thousands) of developers trying to coexist on the same code base, with the result tables containing nearly-the-same fields are strewn all over. It's _possible_ that the design I saw amounted to nothing more than a clever hack for implementing LDAP atop a relational database, but they seemed to have something slightly more to say than that. -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','ntlug.org'). http://www3.sympatico.ca/cbbrowne/emacs.html Why does the word "lisp" have an "s" in it? From pgsql-performance-owner@postgresql.org Thu Oct 9 09:12:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 52309D1B4F4 for ; Thu, 9 Oct 2003 12:12:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08366-05 for ; Thu, 9 Oct 2003 09:11:25 -0300 (ADT) Received: from elbereth.noviforum.si (unknown [193.189.169.66]) by svr1.postgresql.org (Postfix) with ESMTP id 82C93D1B4E2 for ; Thu, 9 Oct 2003 09:11:21 -0300 (ADT) Received: from elbereth.noviforum.si (IDENT:1000@localhost [127.0.0.1]) by elbereth.noviforum.si (8.12.8/8.12.8) with ESMTP id h99CBObZ007177 for ; Thu, 9 Oct 2003 14:11:24 +0200 Received: (from gregab@localhost) by elbereth.noviforum.si (8.12.8/8.12.8/Submit) id h99CBOGh007176 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 14:11:24 +0200 Date: Thu, 9 Oct 2003 14:11:24 +0200 From: Grega Bremec To: Performance Subject: Re: Linux filesystem shootout Message-ID: <20031009121124.GA7038@elbereth.noviforum.si> References: <3F8542B5.6070209@persistent.co.in> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IS0zKkzwUGydFO0o" Content-Disposition: inline In-Reply-To: <3F8542B5.6070209@persistent.co.in> User-Agent: Mutt/1.4i Organization: Noviforum, Ltd., Software & Media X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/265 X-Sequence-Number: 4013 --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable ...and on Thu, Oct 09, 2003 at 04:42:53PM +0530, Shridhar Daithankar used t= he keyboard: > > http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html >=20 > Shridhar My $0.1: I just stumbled across an interesting filesystem comparison table today, comparing ext2/ext3/reiser/reiser4/jfs/xfs on a single UP P2/450 machine with an old UDMA2 Seagate. Now however archaic this box may have been, I think that the tests still bear some objectivity, as it's a comparison test and not some "how much can we squeeze out of xyz" type of bragging. The tests were done using bonnie++ and IOZone and are essentially just a couple of tables listing the average results achieved by each of those tests. Also, ext3, reiser and reiser4 were tested in a couple of different configurations (reiser4 extents, reiser notail, ext3 journal, ordered and writeback mode). Oh, i shouldn't forget - the address is http://fsbench.netnation.com/ :) Cheers, --=20 Grega Bremec Sistemska administracija in podpora grega.bremec-at-noviforum.si http://najdi.si/ http://www.noviforum.si/ --IS0zKkzwUGydFO0o Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/hVBsDo/EMYD4+osRAnZZAKC7+4KkaQWUlnhlo1ObWVbA8MTbvQCfXaqD Z4zsuM0rFPSkZuvbBU/r300= =PMPa -----END PGP SIGNATURE----- --IS0zKkzwUGydFO0o-- From pgsql-performance-owner@postgresql.org Thu Oct 9 09:14:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DE9D5D1B52E for ; Thu, 9 Oct 2003 12:14:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 09438-01 for ; Thu, 9 Oct 2003 09:13:17 -0300 (ADT) Received: from elbereth.noviforum.si (unknown [193.189.169.66]) by svr1.postgresql.org (Postfix) with ESMTP id 8ADD6D1B4E1 for ; Thu, 9 Oct 2003 09:13:13 -0300 (ADT) Received: from elbereth.noviforum.si (IDENT:1000@localhost [127.0.0.1]) by elbereth.noviforum.si (8.12.8/8.12.8) with ESMTP id h99CDGbZ007210 for ; Thu, 9 Oct 2003 14:13:17 +0200 Received: (from gregab@localhost) by elbereth.noviforum.si (8.12.8/8.12.8/Submit) id h99CDGuM007209 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 14:13:16 +0200 Date: Thu, 9 Oct 2003 14:13:16 +0200 From: Grega Bremec To: Performance Subject: Re: Linux filesystem shootout Message-ID: <20031009121316.GB7038@elbereth.noviforum.si> References: <3F8542B5.6070209@persistent.co.in> <20031009121124.GA7038@elbereth.noviforum.si> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dTy3Mrz/UPE2dbVg" Content-Disposition: inline In-Reply-To: <20031009121124.GA7038@elbereth.noviforum.si> User-Agent: Mutt/1.4i Organization: Noviforum, Ltd., Software & Media X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/266 X-Sequence-Number: 4014 --dTy3Mrz/UPE2dbVg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I should at least read the URLs before re-posting info. My bad, I'm utterly sorry about this... :-( Cheers, --=20 Grega Bremec Sistemska administracija in podpora grega.bremec-at-noviforum.si http://najdi.si/ http://www.noviforum.si/ --dTy3Mrz/UPE2dbVg Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/hVDcDo/EMYD4+osRAihEAKCjBUg/ATRye+2R6d4hyi7139bdQgCaA0hm bSGk97BdN75N//hpGPRjC0A= =ovlz -----END PGP SIGNATURE----- --dTy3Mrz/UPE2dbVg-- From pgsql-performance-owner@postgresql.org Thu Oct 9 09:16:28 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 39400D1B528 for ; Thu, 9 Oct 2003 12:16:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 09342-03 for ; Thu, 9 Oct 2003 09:15:40 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id A30AAD1B575 for ; Thu, 9 Oct 2003 09:15:31 -0300 (ADT) Received: (qmail 69073 invoked from network); 9 Oct 2003 12:15:32 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 12:15:32 -0000 Date: Thu, 9 Oct 2003 08:15:32 -0400 (EDT) From: Jeff To: Neil Conway Cc: pgsql-performance@postgresql.org Subject: Re: Sun performance - Major discovery! In-Reply-To: <1065665888.354.96.camel@tokyo> 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: 200310/267 X-Sequence-Number: 4015 On Wed, 8 Oct 2003, Neil Conway wrote: > Hey Jeff, > > On Wed, 2003-10-08 at 11:46, Jeff wrote: > > Yeah - like I expected it was able to generate much better code for > > _bt_checkkeys which was the #1 function in gcc on both sun & linux. > > If you get a minute, would it be possible to compare the performance of > your benchmark under linux/gcc and solaris/gcc when PostgreSQL is > compiled with "-O3"? > Sun: gcc: none: 60 seconds -O: 21 seconds -O2: 20 seconds -O3: 19 seconds suncc: none: 52 seconds -fast: 20 secondsish. -fast is actually a macro that expands to the "best settings" for the platform that is doing the compilation. Linux: -O2: 35 -O3: 40 Odd.. I wonder why it took longer. Perhaps gcc built some bad code? I thought the results were odd there so I ran the test many times.. same results! Swapped the binaries back (so -O2 was running) and boom. back to 35. Sun gcc -O2 and suncc -fast both pass make check. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-admin-owner@postgresql.org Thu Oct 9 09:47:24 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E3674D1B4E1; Thu, 9 Oct 2003 12:47:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 09427-09; Thu, 9 Oct 2003 09:46:26 -0300 (ADT) Received: from davlin.co.in (ns.vasnet.net.in [202.4.160.11]) by svr1.postgresql.org (Postfix) with ESMTP id AAE53D1B4F6; Thu, 9 Oct 2003 09:46:21 -0300 (ADT) Received: from staging (unknown [202.4.160.15]) by davlin.co.in (Postfix) with ESMTP id CD4C514B78; Thu, 9 Oct 2003 17:46:16 +0530 (IST) Message-ID: <7835496.1065704019098.JavaMail.tomcat@mail.davlin.co.in> From: shyamperi@davlin.co.in To: pgsql-admin@postgresql.org Subject: Serious Problem with the windows and postgres configuration Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_8_6385630.1065704018957" Date: Thu, 9 Oct 2003 17:46:16 +0530 (IST) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/101 X-Sequence-Number: 10662 ------=_Part_8_6385630.1065704018957 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit DISCLAIMER: This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. ------=_Part_8_6385630.1065704018957 Content-type: text/html Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=Untitled1 18:15p Dear all, There is a problem I am facing while connecting to postgresqk database serv= er, which is intalled on the remote machine. When I check the log's=20 at database end PG_recv buf is reaching the EOF, and at my program level, j= ava socket exception. I need some help regarding this... as this is not allowing my programs to e= xecute.. Thanking You ----- Warm Regards Sh=FFam Peri II Floor, Punja Building, M.G.Road, Ballalbagh, Mangalore-575003=20 Ph : 91-824-2451001/5 Fax : 91-824-2451050=20

DISCLAIMER: This message contains privileged and confidential information a= nd is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. ------=_Part_8_6385630.1065704018957-- From pgsql-performance-owner@postgresql.org Thu Oct 9 09:51:10 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7D3EED1B506 for ; Thu, 9 Oct 2003 12:51:08 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13180-01 for ; Thu, 9 Oct 2003 09:50:21 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id C94E0D1B52A for ; Thu, 9 Oct 2003 09:50:17 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Thu, 9 Oct 2003 08:52:20 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFM9H; Thu, 9 Oct 2003 08:53:04 -0400 Message-ID: <3F85597F.2090504@cranel.com> Date: Thu, 09 Oct 2003 08:50:07 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> <200310081611.59179.josh@agliodbs.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: 200310/269 X-Sequence-Number: 4017 Christopher Browne wrote: > > Wow, that takes me back to a paper I have been looking for for > _years_. > > Some time in the late '80s, probably '88 or '89, there was a paper > presented in Communications of the ACM that proposed using this sort > of "hypernormalized" schema as a way of having _really_ narrow schemas > that would be exceedingly expressive. They illustrated an example of > an address table that could hold full addresses with a schema with > only about half a dozen columns, the idea being that you'd have > several rows linked together. I'd be interested in the title / author when you remember. I'm kinda sick. I like reading on most computer theory, designs, algorithms, database implementations, etc. Usually how I get into trouble too with 642 column tables though. :) -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Thu Oct 9 10:41:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E7120D1B528 for ; Thu, 9 Oct 2003 13:41:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25482-04 for ; Thu, 9 Oct 2003 10:40:20 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 913B1D1B52E for ; Thu, 9 Oct 2003 10:40:15 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99DeBm22361; Thu, 9 Oct 2003 09:40:11 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091340.h99DeBm22361@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Thu, 9 Oct 2003 09:40:11 -0400 (EDT) Cc: Neil Conway , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/270 X-Sequence-Number: 4018 So you want -fast added as default for non-gcc Solaris? You mentioned there is a warning generated that we have to deal with? --------------------------------------------------------------------------- Jeff wrote: > On Wed, 8 Oct 2003, Neil Conway wrote: > > > Hey Jeff, > > > > On Wed, 2003-10-08 at 11:46, Jeff wrote: > > > Yeah - like I expected it was able to generate much better code for > > > _bt_checkkeys which was the #1 function in gcc on both sun & linux. > > > > If you get a minute, would it be possible to compare the performance of > > your benchmark under linux/gcc and solaris/gcc when PostgreSQL is > > compiled with "-O3"? > > > Sun: > gcc: > none: 60 seconds > -O: 21 seconds > -O2: 20 seconds > -O3: 19 seconds > > suncc: > none: 52 seconds > -fast: 20 secondsish. > > -fast is actually a macro that expands to the "best settings" for the > platform that is doing the compilation. > > > Linux: > -O2: 35 > -O3: 40 > Odd.. I wonder why it took longer. Perhaps gcc built some bad code? > I thought the results were odd there so I ran the test many times.. same > results! Swapped the binaries back (so -O2 was running) and boom. back to > 35. > > Sun gcc -O2 and suncc -fast both pass make check. > > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > > > ---------------------------(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 > -- 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 Oct 9 11:27:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A2BACD1B511; Thu, 9 Oct 2003 14:27:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37222-02; Thu, 9 Oct 2003 11:27:04 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 66926D1B4E5; Thu, 9 Oct 2003 11:27:00 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A7bkv-0003E5-00; Thu, 09 Oct 2003 10:27:05 -0400 Received: by dba2 (Postfix, from userid 1019) id 0F6F8CD6B; Thu, 9 Oct 2003 10:27:05 -0400 (EDT) Date: Thu, 9 Oct 2003 10:27:05 -0400 From: Andrew Sullivan To: PostgreSQL Performance , PostgreSQL-development Subject: Re: [HACKERS] Sun performance - Major discovery! Message-ID: <20031009142704.GD14048@libertyrms.info> Mail-Followup-To: Andrew Sullivan , PostgreSQL Performance , PostgreSQL-development References: <200310081831.h98IVT919657@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310081831.h98IVT919657@candle.pha.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/271 X-Sequence-Number: 4019 On Wed, Oct 08, 2003 at 02:31:29PM -0400, Bruce Momjian wrote: > Well, this is really embarassing. I can't imagine why we would not set > at least -O on all platforms. Looking at the template files, I see > these have no optimization set: I think gcc _used_ to generate bad code on SPARC if you set any optimisation. We tested it on Sol7 with gcc 2.95 more than a year ago, and tried various settings. -O2 worked, but other items were really bad. Some of them would pass regression but cause strange behaviour, random coredumps, &c. A little digging demonstrated that anything beyond -O2 just didn't work for gcc at the time. 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 Oct 9 11:56:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 149D8D1B8BD for ; Thu, 9 Oct 2003 14:56:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41570-04 for ; Thu, 9 Oct 2003 11:55:38 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id EDE38D1B908 for ; Thu, 9 Oct 2003 11:51:26 -0300 (ADT) Received: (qmail 69777 invoked from network); 9 Oct 2003 14:51:29 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 14:51:29 -0000 Date: Thu, 9 Oct 2003 10:51:29 -0400 (EDT) From: Jeff To: Bruce Momjian Cc: Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <200310091340.h99DeBm22361@candle.pha.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: 200310/272 X-Sequence-Number: 4020 On Thu, 9 Oct 2003, Bruce Momjian wrote: > > So you want -fast added as default for non-gcc Solaris? You mentioned > there is a warning generated that we have to deal with? > Yeah, suncc generates a warning for _every_ file that says: Warning: -xarch=native has been explicitly specified, or implicitly specified by a macro option, -xarch=native on this architecture implies -xarch=v8plusa which generates code that does not run on pre-UltraSPARC processors And then I get various warnings here and there... lots of "statement not reached" as in ecpg's type.c module The offending code is a big switch statement like: case ECPGt_bool: return ("ECPGt_bool"); break; And then any functiont aht uses PG_RETURN_NULL generates " warning: end-of-loop code not reached" and a bunch of "constant promoted to unsigned long long" And some places such as in fe-exec.c have code like this: buflen = strlen(strtext); /* will shrink, also we discover if where strtext is an unsigned char * which generates warning: argument #1 is incompatible with prototype: and then various other type mismatches here and there. I skimmed through the manpage.. it doesn't look like we can supress these.. Not sure we want it to look like we have bad code if someone uses cc. perhaps issue a ./configure notice or something? gcc compiles things fine. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 11:57:49 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1050CD1BACF for ; Thu, 9 Oct 2003 14:57:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41845-04 for ; Thu, 9 Oct 2003 11:57:04 -0300 (ADT) Received: from MX2.estpak.ee (mta1.mail.neti.ee [194.126.101.123]) by svr1.postgresql.org (Postfix) with ESMTP id 95752D1B56A for ; Thu, 9 Oct 2003 11:52:46 -0300 (ADT) Received: from future.ee (213-219-88-160-dsl.lsn.estpak.ee [213.219.88.160]) by MX2.estpak.ee (Postfix) with ESMTP id 884D9736F5; Thu, 9 Oct 2003 17:50:37 +0300 (EEST) Message-ID: <3F85763C.3080307@future.ee> Date: Thu, 09 Oct 2003 17:52:44 +0300 From: Kaarel 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: Grega Bremec Cc: Performance Subject: Re: Linux filesystem shootout References: <3F8542B5.6070209@persistent.co.in> <20031009121124.GA7038@elbereth.noviforum.si> In-Reply-To: <20031009121124.GA7038@elbereth.noviforum.si> Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/273 X-Sequence-Number: 4021
http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html

Shridhar
    
I feel incompetent when it comes to file systems. Yet everybody would like to have the best file system if given the choice...so do I :) Here I am looking at those tables seeing JFS having more green cells than others. The more green the better right? So based on these tests JFS ought to be the one?

Kaarel
From pgsql-performance-owner@postgresql.org Thu Oct 9 12:11:18 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ECA91D1B95E for ; Thu, 9 Oct 2003 15:11:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 46319-06 for ; Thu, 9 Oct 2003 12:10:27 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 98BAED1B981 for ; Thu, 9 Oct 2003 12:07:05 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h99FC44B020489 for ; Thu, 9 Oct 2003 20:42:04 +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 h99FBxwc020446; Thu, 9 Oct 2003 20:41:59 +0530 Message-ID: <3F85798B.1010106@persistent.co.in> Date: Thu, 09 Oct 2003 20:36:51 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kaarel Cc: Grega Bremec , Performance Subject: Re: Linux filesystem shootout References: <3F8542B5.6070209@persistent.co.in> <20031009121124.GA7038@elbereth.noviforum.si> <3F85763C.3080307@future.ee> In-Reply-To: <3F85763C.3080307@future.ee> 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: 200310/274 X-Sequence-Number: 4022 Kaarel wrote: >>>http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html >>> >>>Shridhar >>> >>> > I feel incompetent when it comes to file systems. Yet everybody would like to > have the best file system if given the choice...so do I :) Here I am looking at > those tables seeing JFS having more green cells than others. The more green the > better right? So based on these tests JFS ought to be the one? Yes and no. Yes for the results. No for the tests that weren't run. Database load is quite different. Its mixture of read and write load with a dynamics varying from one extreme to other, between these two. All it says that if you want to choose a good file system for postgresql, look at JFS first..:-) Besides all the tests were done on files file bigger than 1GB. If single file size is restricted to 1GB, it might produce a different result set. And postgresql does not exceed 1GB limit per file. So still, quite a few unknowns there.. Best thing could be repeat those benchmarks on $PGDATA with your live data inside it. It could mimmic the load pretty well.. Shridhar From pgsql-performance-owner@postgresql.org Thu Oct 9 12:29:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8D3C0D1B554 for ; Thu, 9 Oct 2003 15:29:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52041-09 for ; Thu, 9 Oct 2003 12:28:58 -0300 (ADT) Received: from mta3.adelphia.net (mta3.adelphia.net [68.168.78.181]) by svr1.postgresql.org (Postfix) with ESMTP id 75E8DD1CA97 for ; Thu, 9 Oct 2003 12:19:46 -0300 (ADT) Received: from potentialtech.com ([68.68.113.33]) by mta3.adelphia.net (InterMail vM.5.01.05.32 201-253-122-126-132-20030307) with ESMTP id <20031009151943.TJCN1358.mta3.adelphia.net@potentialtech.com>; Thu, 9 Oct 2003 11:19:43 -0400 Message-ID: <3F857C8E.1030804@potentialtech.com> Date: Thu, 09 Oct 2003 11:19:42 -0400 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: Kaarel Cc: Performance Subject: Re: Linux filesystem shootout References: <3F8542B5.6070209@persistent.co.in> <20031009121124.GA7038@elbereth.noviforum.si> <3F85763C.3080307@future.ee> In-Reply-To: <3F85763C.3080307@future.ee> 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: 200310/275 X-Sequence-Number: 4023 Kaarel wrote: > >>>http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html >>> >>>Shridhar >>> > I feel incompetent when it comes to file systems. Yet everybody would > like to have the best file system if given the choice...so do I :) Here > I am looking at those tables seeing JFS having more green cells than > others. The more green the better right? So based on these tests JFS > ought to be the one? Those tests seem to align with the ones I did recently: http://www.potentialtech.com/wmoran/postgresql.php#results There were less filesystems involved, and the data is less comprehensive, but probably a little easier to understand (i.e. -> fastest filesystem at the top of the graph, slowest at the bottom). I've been telling people that JFS is fastest. This is definately oversimplified, since the "shoot out" shows that it's not _always_ fastest, but for people who just want to make a good initial choice, and won't do their own testing to find out what's fastest in their configuration (for whatever reason), I think JFS is the safest bet. Since it's a journalling filesystem as well, it should have good recoverability in the even of catastrophy, but I haven't tested that. -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Thu Oct 9 12:34:28 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7C2E7D1B912 for ; Thu, 9 Oct 2003 15:34:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54356-03 for ; Thu, 9 Oct 2003 12:33:34 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 28EEBD1B936 for ; Thu, 9 Oct 2003 12:26:35 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id ; Thu, 9 Oct 2003 11:28:32 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHF32J; Thu, 9 Oct 2003 11:29:17 -0400 Message-ID: <3F857E1C.1040209@cranel.com> Date: Thu, 09 Oct 2003 11:26:20 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: josh@agliodbs.com Cc: PgSQL Performance ML Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> <200310081611.59179.josh@agliodbs.com> In-Reply-To: <200310081611.59179.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: 200310/276 X-Sequence-Number: 4024 Josh Berkus wrote: > Greg, > > >>You lost me on that one. What's a "vertical child table"? > > > Currently, you store data like this: > > id address uptime speed memory tty > 3 67.92 0.3 11.2 37 6 > 7 69.5 1.1 NULL 15 NULL > 9 65.5 0.1 NULL 94 2 > > The most efficient way for you to store data would be like this: > > main table > id address > 3 67.92 > 7 69.5 > 9 65.5 > > child table > id value_type value > 3 uptime 0.3 > 3 speed 11.2 > 3 memory 37 > 3 tty 6 > 7 uptime 1.1 > 7 memory 15 > 9 uptime 0.1 > 9 memory 94 > 9 tty 2 > > As you can see, the NULLs are not stored, making this system much more > efficient on storage space. > > Tommorrow I'll (hopefully) write up how to query this for comparisons. It > would help if you gave a little more details about what specific comparison > you're doing, e.g. between tables or table to value, comparing just the last > value or all rows, etc. > Got it. I can see how it would be more efficient in storing. At this point it would require a lot of query and code rewrites to handle it. Fortunately, we're looking for alternatives for the next revision and we're leaving ourselves open for a rewrite much to the boss's chagrin. I will be spinning up a test server soon and may attempt a quick implementation. I may make value_type a foreign key on a table that includes a full and/or brief description of the key. Problem I'll have then will be categorizing all those keys into disk, cpu, memory, user, and all the other data categories since it's in one big table rather than specialized tables. Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Thu Oct 9 12:36:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E40ADD1B4E3 for ; Thu, 9 Oct 2003 15:35:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52946-10 for ; Thu, 9 Oct 2003 12:35:03 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id AAFC6D1B99F for ; Thu, 9 Oct 2003 12:28:15 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99FS2u04665; Thu, 9 Oct 2003 11:28:02 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091528.h99FS2u04665@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Thu, 9 Oct 2003 11:28:01 -0400 (EDT) Cc: Neil Conway , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/277 X-Sequence-Number: 4025 What is the performance win for the -fast flag again? --------------------------------------------------------------------------- Jeff wrote: > On Thu, 9 Oct 2003, Bruce Momjian wrote: > > > > > So you want -fast added as default for non-gcc Solaris? You mentioned > > there is a warning generated that we have to deal with? > > > > Yeah, suncc generates a warning for _every_ file that says: > Warning: -xarch=native has been explicitly specified, or implicitly > specified by a macro option, -xarch=native on this architecture implies > -xarch=v8plusa which generates code that does not run on pre-UltraSPARC > processors > > And then I get various warnings here and there... > > lots of "statement not reached" as in ecpg's type.c module > The offending code is a big switch statement like: > case ECPGt_bool: > return ("ECPGt_bool"); > break; > > And then any functiont aht uses PG_RETURN_NULL generates " warning: > end-of-loop code not reached" > > and a bunch of "constant promoted to unsigned long long" > > > And some places such as in fe-exec.c have code like this: > buflen = strlen(strtext); /* will shrink, also we discover > if > > where strtext is an unsigned char * which generates warning: argument #1 > is incompatible with prototype: > > and then various other type mismatches here and there. > > I skimmed through the manpage.. it doesn't look like we can supress > these.. > > > Not sure we want it to look like we have bad code if someone uses cc. > perhaps issue a ./configure notice or something? > > gcc compiles things fine. > > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -- 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 Oct 9 12:47:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D7B92D1B573 for ; Thu, 9 Oct 2003 15:46:55 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 56095-05 for ; Thu, 9 Oct 2003 12:46:10 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 9BAECD1B90B for ; Thu, 9 Oct 2003 12:40:59 -0300 (ADT) 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 h99FdbGQ002025; Thu, 9 Oct 2003 09:39:37 -0600 (MDT) Date: Thu, 9 Oct 2003 09:30:36 -0600 (MDT) From: "scott.marlowe" To: Shridhar Daithankar Cc: Kaarel , Grega Bremec , Performance Subject: Re: Linux filesystem shootout In-Reply-To: <3F85798B.1010106@persistent.co.in> 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: 200310/278 X-Sequence-Number: 4026 On Thu, 9 Oct 2003, Shridhar Daithankar wrote: > Kaarel wrote: > >>>http://www.ussg.iu.edu/hypermail/linux/kernel/0310.1/0208.html > >>> > >>>Shridhar > >>> > >>> > > I feel incompetent when it comes to file systems. Yet everybody would like to > > have the best file system if given the choice...so do I :) Here I am looking at > > those tables seeing JFS having more green cells than others. The more green the > > better right? So based on these tests JFS ought to be the one? > > Yes and no. Yes for the results. No for the tests that weren't run. > > Database load is quite different. Its mixture of read and write load with a > dynamics varying from one extreme to other, between these two. > > All it says that if you want to choose a good file system for postgresql, look > at JFS first..:-) > > Besides all the tests were done on files file bigger than 1GB. If single file > size is restricted to 1GB, it might produce a different result set. And > postgresql does not exceed 1GB limit per file. > > So still, quite a few unknowns there.. Absolutely. For instance, one file system may be faster on a RAID card with battery backed cache, while another may be faster on an IDE drive with write cache disabled, while another may be faster on software RAID1, while another might be faster on software RAID5. If you haven't tested different file systems on your setup, you don't really know which will be faster until you do. From pgsql-performance-owner@postgresql.org Thu Oct 9 12:50:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BC022D1B570 for ; Thu, 9 Oct 2003 15:50:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55686-09 for ; Thu, 9 Oct 2003 12:49:19 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 2D387D1B556 for ; Thu, 9 Oct 2003 12:45:21 -0300 (ADT) Received: (qmail 70173 invoked from network); 9 Oct 2003 15:45:24 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 15:45:24 -0000 Date: Thu, 9 Oct 2003 11:45:24 -0400 (EDT) From: Jeff To: Bruce Momjian Cc: Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <200310091528.h99FS2u04665@candle.pha.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: 200310/279 X-Sequence-Number: 4027 On Thu, 9 Oct 2003, Bruce Momjian wrote: > > What is the performance win for the -fast flag again? > > --------------------------------------------------------------------------- > 52 seconds to 19-20 seconds -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 12:53:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9CD09D1B528 for ; Thu, 9 Oct 2003 15:53:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 57988-01 for ; Thu, 9 Oct 2003 12:53:02 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 63236D1B4F9 for ; Thu, 9 Oct 2003 12:51:38 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99FpUa07732; Thu, 9 Oct 2003 11:51:30 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091551.h99FpUa07732@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Thu, 9 Oct 2003 11:51:30 -0400 (EDT) Cc: Neil Conway , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/280 X-Sequence-Number: 4028 Jeff wrote: > On Thu, 9 Oct 2003, Bruce Momjian wrote: > > > > > What is the performance win for the -fast flag again? > > > > --------------------------------------------------------------------------- > > > 52 seconds to 19-20 seconds Wow, that's dramatic. Do you want to propose some flags for non-gcc Solaris? Is -fast the only one? Is there one that suppresses those warnings or are they OK? -- 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 Oct 9 13:08:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2F530D1B4E9 for ; Thu, 9 Oct 2003 16:08:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 57804-08 for ; Thu, 9 Oct 2003 13:07:17 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id B2DD8D1B50B for ; Thu, 9 Oct 2003 13:07:16 -0300 (ADT) Received: (qmail 70349 invoked from network); 9 Oct 2003 16:07:20 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 16:07:20 -0000 Date: Thu, 9 Oct 2003 12:07:20 -0400 (EDT) From: Jeff To: Bruce Momjian Cc: Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <200310091551.h99FpUa07732@candle.pha.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: 200310/281 X-Sequence-Number: 4029 On Thu, 9 Oct 2003, Bruce Momjian wrote: > > 52 seconds to 19-20 seconds > > Wow, that's dramatic. Do you want to propose some flags for non-gcc > Solaris? Is -fast the only one? Is there one that suppresses those > warnings or are they OK? > Well. As I said, I didn't see an obvious way to hide those warnings. I'd love to make those warnings go away. That is why I suggested perhaps printing a message to ensure the user knows that warnings may be printed when using sunsoft. -fast should be all you need - it picks the "best settings" to use for the platform that is doing the compile. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 14 13:45:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 045E3D1B52A for ; Thu, 9 Oct 2003 16:27:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66232-06 for ; Thu, 9 Oct 2003 13:26:26 -0300 (ADT) Received: from is.rice.edu (is.rice.edu [128.42.42.24]) by svr1.postgresql.org (Postfix) with ESMTP id 81A82D1B4EA for ; Thu, 9 Oct 2003 13:25:28 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by localhost.is.rice.edu (Postfix) with ESMTP id D62544193E; Thu, 9 Oct 2003 11:25:27 -0500 (CDT) Received: from is.rice.edu ([127.0.0.1]) by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14525-08; Thu, 9 Oct 2003 11:25:25 -0500 (CDT) Received: by is.rice.edu (Postfix, from userid 18612) id 9E1FE418CB; Thu, 9 Oct 2003 11:25:25 -0500 (CDT) Date: Thu, 9 Oct 2003 11:25:25 -0500 From: Kenneth Marshall To: Jeff Cc: Bruce Momjian , Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! Message-ID: <20031009162525.GB10888@it.is.rice.edu> References: <200310091551.h99FpUa07732@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/450 X-Sequence-Number: 4198 Jeff, My first concern with the -fast option is that it makes an executable that is specific for the platform on which the compilation is run unless other flags are given. My second concern is the effect it has on IEEE floating point behavior w.r.t. rounding, error handling, .... And my third concern is that if you use -fast, all other code must be compiled and linked with the -fast option for correct operation, this includes any functional languages such as perl, python, R,... That is a pretty big requirement for a default compilation flag. Ken Marshall On Thu, Oct 09, 2003 at 12:07:20PM -0400, Jeff wrote: > On Thu, 9 Oct 2003, Bruce Momjian wrote: > > > > 52 seconds to 19-20 seconds > > > > Wow, that's dramatic. Do you want to propose some flags for non-gcc > > Solaris? Is -fast the only one? Is there one that suppresses those > > warnings or are they OK? > > > > Well. As I said, I didn't see an obvious way to hide those warnings. > I'd love to make those warnings go away. That is why I suggested perhaps > printing a message to ensure the user knows that warnings may be printed > when using sunsoft. > > -fast should be all you need - it picks the "best settings" to use for the > platform that is doing the compile. > > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Thu Oct 9 15:43:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6D15CD1B554 for ; Thu, 9 Oct 2003 18:43:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 93178-09 for ; Thu, 9 Oct 2003 15:42:12 -0300 (ADT) Received: from smtp.noos.fr (nan-smtp-13.noos.net [212.198.2.121]) by svr1.postgresql.org (Postfix) with ESMTP id CD8A1D1B577 for ; Thu, 9 Oct 2003 15:42:10 -0300 (ADT) Received: (qmail 22477 invoked by uid 0); 9 Oct 2003 18:42:00 -0000 Received: from unknown (HELO bigfoot.com) ([::ffff:212.198.37.110]) (envelope-sender ) by ::ffff:212.198.2.121 (qmail-ldap-1.03) with SMTP for ; 9 Oct 2003 18:42:00 -0000 Message-ID: <3F858FCE.3040907@bigfoot.com> Date: Thu, 09 Oct 2003 18:41:50 +0200 From: Gaetano Mendola 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@postgresql.org" Cc: Andriy Tkachuk Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql References: <5442.1065651752@sss.pgh.pa.us> <20031009101121.S29282-100000@pool.imt.com.ua> In-Reply-To: <20031009101121.S29282-100000@pool.imt.com.ua> 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: 200310/298 X-Sequence-Number: 4046 Andriy Tkachuk wrote: > On Wed, 8 Oct 2003, Tom Lane wrote: > > >>Andriy Tkachuk writes: >> >>>At second. calc_total() is immutable function: >>>but it seems that it's not cached in one session: >> >>It's not supposed to be. > > > but it's written id doc: > > IMMUTABLE indicates that the function always returns the same > result when given the same argument values; that is, it does not > do database lookups or otherwise use information not directly > present in its parameter list. If this option is given, any call > of the function with all-constant arguments can be immediately > replaced with the function value. The doc say "can be" not must and will be. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Thu Oct 9 13:59:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F1698D1B516 for ; Thu, 9 Oct 2003 16:59:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71072-01 for ; Thu, 9 Oct 2003 13:58:55 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 51EC5D1B4EA for ; Thu, 9 Oct 2003 13:58:22 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3746012; Thu, 09 Oct 2003 09:58:48 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Oliver Scheit" , Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Thu, 9 Oct 2003 09:56:11 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310090956.11356.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/282 X-Sequence-Number: 4030 Oliver, > I think instead of thinking about where to put the > information about tuning, someone should provide a > "pgsql-autotune". Maybe even a shell script would do the > trick. Well, you see, there's the issue. "I think someone." Lots of people have spoken in favor of an "auto-conf" script; nobody so far has stepped forward to get it done for 7.4, and I doubt we have time now. I'll probably create a Perl script in a month or so, but not before that .... -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 9 14:05:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 34BB4D1B4E9 for ; Thu, 9 Oct 2003 17:05:09 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77251-02 for ; Thu, 9 Oct 2003 14:04:20 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id C0DD6D1B52A for ; Thu, 9 Oct 2003 14:04:18 -0300 (ADT) Received: (qmail 70649 invoked from network); 9 Oct 2003 17:04:23 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 17:04:23 -0000 Date: Thu, 9 Oct 2003 13:04:23 -0400 (EDT) From: Jeff To: Kenneth Marshall Cc: Bruce Momjian , Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <20031009162525.GB10888@it.is.rice.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: 200310/283 X-Sequence-Number: 4031 On Thu, 9 Oct 2003, Kenneth Marshall wrote: > Jeff, > > My first concern with the -fast option is that it makes an executable > that is specific for the platform on which the compilation is run > unless other flags are given. My second concern is the effect it has > on IEEE floating point behavior w.r.t. rounding, error handling, .... > And my third concern is that if you use -fast, all other code must > be compiled and linked with the -fast option for correct operation, > this includes any functional languages such as perl, python, R,... > That is a pretty big requirement for a default compilation flag. > > Ken Marshall > So you think we should leave PG alone and let it run horrifically slowly? Do you have a better idea of how to do this? And do you have evidence apps compiled with -fast linked to non -fast (or gcc compiled) have problems? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 14:09:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A0406D1B4E9 for ; Thu, 9 Oct 2003 17:09:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 70918-07 for ; Thu, 9 Oct 2003 14:08:50 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 67B8FD1B531 for ; Thu, 9 Oct 2003 14:08:48 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99H8fY07153; Thu, 9 Oct 2003 13:08:41 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091708.h99H8fY07153@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Thu, 9 Oct 2003 13:08:41 -0400 (EDT) Cc: Kenneth Marshall , Neil Conway , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/284 X-Sequence-Number: 4032 Jeff wrote: > On Thu, 9 Oct 2003, Kenneth Marshall wrote: > > > Jeff, > > > > My first concern with the -fast option is that it makes an executable > > that is specific for the platform on which the compilation is run > > unless other flags are given. My second concern is the effect it has > > on IEEE floating point behavior w.r.t. rounding, error handling, .... > > And my third concern is that if you use -fast, all other code must > > be compiled and linked with the -fast option for correct operation, > > this includes any functional languages such as perl, python, R,... > > That is a pretty big requirement for a default compilation flag. > > > > Ken Marshall > > > > So you think we should leave PG alone and let it run horrifically slowly? > Do you have a better idea of how to do this? > > And do you have evidence apps compiled with -fast linked to non -fast > (or gcc compiled) have problems? I have updated the Solaris FAQ: 5) How can I compile for optimum performance? Try using the "-fast" compile flag. The binaries might not be portable to other Solaris systems, and you might need to compile everything that links to PostgreSQL with "-fast", but PostgreSQL will run significantly faster, 50% faster on some tests. -- 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 Oct 9 14:17:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5AFA4D1B4FD for ; Thu, 9 Oct 2003 17:16:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77144-08 for ; Thu, 9 Oct 2003 14:16:12 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 1A509D1B52A for ; Thu, 9 Oct 2003 14:16:11 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A7eOZ-0006gP-00 for ; Thu, 09 Oct 2003 13:16:11 -0400 Received: by dba2 (Postfix, from userid 1019) id 606C4CD6B; Thu, 9 Oct 2003 13:16:11 -0400 (EDT) Date: Thu, 9 Oct 2003 13:16:11 -0400 From: Andrew Sullivan To: "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! Message-ID: <20031009171611.GJ14394@libertyrms.info> Mail-Followup-To: Andrew Sullivan , "pgsql-performance@postgresql.org" References: <20031009162525.GB10888@it.is.rice.edu> 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: 200310/285 X-Sequence-Number: 4033 On Thu, Oct 09, 2003 at 01:04:23PM -0400, Jeff wrote: > > So you think we should leave PG alone and let it run horrifically slowly? > Do you have a better idea of how to do this? Given the point in the release cycle, mightn't the FAQ_Solaris or some other place be better for this for now? I agree with the concern. I'd rather have slow'n'stable than fast-but-broken. 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 Oct 9 14:20:08 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EA967D1B4E9 for ; Thu, 9 Oct 2003 17:20:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77301-08 for ; Thu, 9 Oct 2003 14:19:15 -0300 (ADT) 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 7A1E4D1B545 for ; Thu, 9 Oct 2003 14:19:13 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h99HGk6N002573; Thu, 9 Oct 2003 20:16:46 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h99HGNYk002571; Thu, 9 Oct 2003 20:16:23 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Compare rows From: Hannu Krosing To: Josh Berkus Cc: Christopher Browne , pgsql-performance@postgresql.org In-Reply-To: <200310082236.59305.josh@agliodbs.com> References: <3F841A28.8060504@cranel.com> <200310081611.59179.josh@agliodbs.com> <200310082236.59305.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1065719782.2529.7.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 09 Oct 2003 20:16:22 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/287 X-Sequence-Number: 4035 Josh Berkus kirjutas N, 09.10.2003 kell 08:36: > Chris, > > The need to do a lot of joins would likely hurt performance somewhat, > > as well as the way that it greatly increases the number of rows. > > Although you could always split it into several tables, one for each > > "value_type", and UNION them into a view... > > It increases the number of rows, yes, but *decreases* the storage size of data > by eliminating thousands ... or millions ... of NULL fields. I'm not sure I buy that. Null fields take exactly 1 *bit* to store (or more exactly, if you have any null fields in tuple then one 32bit int for each 32 fields is used for NULL bitmap), whereas the same fields in "vertical" table takes 4 bytes for primary key and 1-4 bytes for category key + tuple header per value + neccessary indexes. So if you have more than one non-null field per tuple you will certainly lose in storage. > How would splitting the vertical values into dozens of seperate tables help things? If you put each category in a separate table you save 1-4 bytes for category per value, but still store primary key and tuple header *per value*. Jou may stii get better performance for single-column comparisons as fewer pages must be touched. > Personally, I'd rather have a table with 3 columns and 8 million rows than a > table with 642 columns and 100,000 rows. Much easier to deal with. Same here ;) ------------------ Hannu From pgsql-performance-owner@postgresql.org Thu Oct 9 14:18:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DAFABD1B516 for ; Thu, 9 Oct 2003 17:18:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71216-10 for ; Thu, 9 Oct 2003 14:17:22 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 5A318D1B50B for ; Thu, 9 Oct 2003 14:17:21 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 3E8505FDC for ; Thu, 9 Oct 2003 17:17:16 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h99HHFNM015073 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 10:17:15 -0700 (PDT) (envelope-from dror) Date: Thu, 9 Oct 2003 10:17:15 -0700 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031009171715.GR2979@rlx11.zapatec.com> References: <200310090956.11356.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310090956.11356.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/286 X-Sequence-Number: 4034 Yeah, I had similar thought to Oliver's and suspected that this would be the answer. Also, while it's not too hard to do this for a single platform, it gets complecated once you start looking at different ones. Josh, let me know when you're ready to do this. I'll try to help, although my perl's kind of rusty. Also, can you even assume perl for a postgres install? Does Solaris, for instance come with perl? Dror On Thu, Oct 09, 2003 at 09:56:11AM -0700, Josh Berkus wrote: > Oliver, > > > I think instead of thinking about where to put the > > information about tuning, someone should provide a > > "pgsql-autotune". Maybe even a shell script would do the > > trick. > > Well, you see, there's the issue. "I think someone." Lots of people have > spoken in favor of an "auto-conf" script; nobody so far has stepped forward > to get it done for 7.4, and I doubt we have time now. > > I'll probably create a Perl script in a month or so, but not before that .... > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Oct 9 14:22:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 534AFD1B554 for ; Thu, 9 Oct 2003 17:22:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 78530-04 for ; Thu, 9 Oct 2003 14:22:03 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 6CB17D1B53E for ; Thu, 9 Oct 2003 14:22:01 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id ; Thu, 9 Oct 2003 10:20:13 -0700 Received: from GRIFFITHS2 ([192.168.12.225]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TTY6YRZA; Thu, 9 Oct 2003 10:20:02 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> Subject: Re: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 10:30:07 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_03B7_01C38E50.4F83A020" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/288 X-Sequence-Number: 4036 This is a multi-part message in MIME format. ------=_NextPart_000_03B7_01C38E50.4F83A020 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This is a timely thread for myself, as I'm in the middle of testing both databases as an Oracle replacement. =20 As of this moment, I know more about MySQL (tuning, setup, features) than I do about Postgres. Not because I like MySQL more, but because =20 1) the MySQL docs are better (sorry - I found them easier to read, and more comprehensive; I had an easier time finding the answers I needed) 2) there are more web pages devoted to MySQL (probably because it has a bit more market share) 3) there are more books on MySQL at the bookstore (I haven't had a chance to pick up Bruce's book yet; it might be all the book I'd ever need) 4) we looked at MySQL first (we needed replication, and eRServer had not been open-sourced when we started looking) =20 With regards to #1, I'd like to specifically mention tuning - the docs at http://www.postgresql.org/docs/7.3/static/runtime-config.html give a basic explanation of the different options, but much more is needed for tuning. I'm running into a problem with an update statement (that uses a select in a sub-query) in Postgres - it's taking hours to run (the equiv, using a multi-table update statement in MySQL instead of a sub-query, takes all of 2 seconds). I'll be posting it later once I do more reading to make sure I've done as much as I can to solve it myself. =20 I really agree with this post: =20 "I guess my point is simply this: instead of saying: "okay we use default settings that will run on _old_ hardware too" we should go for a little script that creates a "still save but much better" config file. There's just no point in setting SHARED_BUFFERS to something like 16 (what's the current default?) if the PC has >=3D 1 GB of RAM. Setting it to 8192 would still be save, but 512 times better... ;-) (IIRC 8192 would take 64 MB of RAM, which should be save if you leave the default MAX_CONNECTIONS.)" It provides examples, and some real numbers to help someone new to the database take an initial crack at tuning. Remember, you're trying to compete with the big-guys (Oracle, etc), so providing info that an Oracle DBA needs is pretty critical. I'm currently at a complete loss for tuning Postgres (it seems to do things very differently than both Oracle and MySQL). =20 =20 I also have to admit a bit of irritation reading this thread; there is a fair number of incorrect statements on this thread that, while not wrong, definately aren't right: =20 "Speed depends on the nature of use and the complexity of queries. If you are doing updates of related tables, ACID is of vital importance and MySQL doesn't provide it." MySQL has ACID in InnoDB. I've found that MySQL is actually very fast on complex queries w/InnoDB (six tables, 1 million rows, two of the joins are outer-joins. In fact, I can get InnoDB to be almost as fast as MyISAM. Complex updates are also very very fast. We have not tried flooding either database with dozens of complex statements from multiple clients; that's coming soon, and from what I've read, MySQL won't do too well. =20 "using InnoDB tables (the only way to have foreign keys, transactions, and row level locking for MySQL) makes MySQL slower and adds complexity to tuning the database" Adding this: "innodb_flush_method=3DO_DSYNC" to the my.cnf made InnoDB as fast as MyISAM in our tests. It doesn't turn off disk flushing; it's just a flush method that might work better with different kernels and drives; it's one of those "play with this and see if it helps" parameters; there are lots of those in Postgres, it seems. There are 10 variables for tuning InnoDB (and you don't have to tune for MyISAM, so it's actually a six-of-one, half-dozen-of-the-other). Setup between the two seems to be about the same. =20 "PostgreSQL supports constraints. MySQL doesn't; programmers need to take care of that from the client side" Again, InnoDB supports constraints. =20 "Transactions: We've been here before. Suffice to say, MySQL+InnoDB is almost there. Plain ol' MySQL doesn't have it, which tells you something about their philosophy towards database design." InnoDB supports transactions very nicely, has the equivalent of WAL, and one thing I really like: a tablespace (comprised of data files that can be spread around multiple hard drives), and in a month or so, InnoDB will support multiple tablespaces. =20 =20 To be fair, here are a few MySQL "bad-things" that weren't mentioned: =20 1) InnoDB can't do a hot-backup with the basic backup tools. To hot-backup an InnoDB database, you need to pay $450 US per database per year ($1150 per database perpetual) for a proprietary hot-backup tool 2) InnoDB can't do full-text searching. 3) I see alot more corrupt-database bugs on the MySQL lists (most are MyISAM, but a few InnoDB bugs pop up from time to time) - way more than I see on the Postgres lists. 4) There are some really cranky people on the MySQL lists; the Postgres lists seem to be much more effective (esp. with people like Tom Lane). Maybe it's because they get alot of dumb questions, as people unfamiliar with databases turn to MySQL first? =20 Maybe the Postgres community needs an anti-FUD individual or two; people that know both databases, and can provide the proper information for answering questions like this. A section in the docs would help as well. Yes, I know many of the people advocating Postgres do not want to compare themselves to MySQL (but rather to Oracle, Sybase, DB2, etc) , but the volume of responses on a thread like this indicates that the comparison is going to happen regardless. Better to nip it in the bud quickly than let it go on over 3-4 days. =20 One last observation: someone looking at both databases, reading those posts, might get a bad impression of Postgres based on the inconsistency and incorrectness of some of the statements made about MySQL. If a salesperson provides misinformation about a competitors product and you find out about it, that salesperson has most likely lost a customer. =20 Anyway, I hope I haven't offended anyone - I'm not trying to troll or flame, but rather just give some constructive criticism from someone outside both the MySQL and Postgres camps. =20 David =20 ------=_NextPart_000_03B7_01C38E50.4F83A020 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
This is a timely thread for myself, as I'm= in the=20 middle of testing both databases as an Oracle replacement.
 
As of this moment, I know more about MySQL= (tuning,=20 setup, features) than I do about Postgres. Not because I like MySQL more, b= ut=20 because
 
1) the MySQL docs are better (sorry -= I found=20 them easier to read, and more comprehensive; I had an easier time finding t= he=20 answers I needed)
2) there are more web pages devoted t= o MySQL=20 (probably because it has a bit more market share)
3) there are more books on MySQL at t= he=20 bookstore (I haven't had a chance to pick up Bruce's book yet; it might be = all=20 the book I'd ever need)
4) we looked at MySQL first (we neede= d=20 replication, and eRServer had not been open-sourced when we started=20 looking)
 
With regards to #1, I'd like to specifical= ly=20 mention tuning - the docs at http= ://www.postgresql.org/docs/7.3/static/runtime-config.html give=20 a basic explanation of the different options, but much more is needed for= =20 tuning. I'm running into a problem with an update statement (that uses a se= lect=20 in a sub-query) in Postgres - it's taking  hours to run (the equiv, us= ing a=20 multi-table update statement in MySQL instead of a sub-query, takes all of = 2=20 seconds). I'll be posting it later once I do more reading to make sure I've= done=20 as much as I can to solve it myself.
 
I really agree with this post:
 
"I guess my point is simply this: instead = of=20 saying: "okay we use default settings that will run on _old_ hardware too" = we=20 should go for a little script that creates a "still save but much better" c= onfig=20 file. There's just no point in setting SHARED_BUFFERS to something like 16= =20 (what's the current default?) if the PC has >=3D 1 GB of RAM. Setting it= to=20 8192 would still be save, but 512 times better...  ;-) (IIRC 8192 woul= d=20 take 64 MB of RAM, which should be save if you leave the default=20 MAX_CONNECTIONS.)" It provides examples, and some real numbers to help some= one=20 new to the database take an initial crack at tuning. Remember, you're tryin= g to=20 compete with the big-guys (Oracle, etc), so providing info that an Oracle D= BA=20 needs is pretty critical. I'm currently at a complete loss for tuning Postg= res=20 (it seems to do things very differently than both Oracle and=20 MySQL).
 
 
I also have to admit a bit of irritation r= eading=20 this thread; there is a fair number of incorrect statements on this thread = that,=20 while not wrong, definately aren't right:
 
"Speed depends on the nature of use and th= e=20 complexity of queries.  If you are doing updates of related tables, AC= ID is=20 of vital importance and MySQL doesn't provide it."
MySQL has ACID in InnoDB. I've found that = MySQL is=20 actually very fast on complex queries w/InnoDB (six tables, 1 million rows,= two=20 of the joins are outer-joins. In fact, I can get InnoDB to be almost as fas= t as=20 MyISAM. Complex updates are also very very fast. We have not tried flooding= =20 either database with dozens of complex statements from multiple clients; th= at's=20 coming soon, and from what I've read, MySQL won't do too well.
 
"using InnoDB tables (the only way to have= foreign=20 keys, transactions, and row level locking for MySQL) makes MySQL slowe= r=20 and adds complexity to tuning the database"
Adding this: "innodb_flush_method=3DO_DSYN= C" to the=20 my.cnf made InnoDB as fast as MyISAM in our tests. It doesn't turn off disk= =20 flushing; it's just a flush method that might work better with different ke= rnels=20 and drives; it's one of those "play with this and see if it helps" paramete= rs;=20 there are lots of those in Postgres, it seems. There are 10 variables for t= uning=20 InnoDB (and you don't have to tune for MyISAM, so it's actually a six-of-on= e,=20 half-dozen-of-the-other). Setup between the two seems to be about the=20 same.
 
"PostgreSQL supports constraints. MySQL do= esn't;=20 programmers need to take care of that from the client side"
Again, InnoDB supports constraints.=
 
"Transactions: We've been here before. Suf= fice to=20 say, MySQL+InnoDB is almost there. Plain ol' MySQL doesn't have it, which t= ells=20 you something about their philosophy towards database design."
InnoDB supports transactions very nicely, = has the=20 equivalent of WAL, and one thing I really like: a tablespace (comprised of = data=20 files that can be spread around multiple hard drives), and in a month or so= ,=20 InnoDB will support multiple tablespaces.
 
 
To be fair, here are a few MySQL "bad-thin= gs" that=20 weren't mentioned:
 
1) InnoDB can't do a hot-backup with the b= asic=20 backup tools. To hot-backup an InnoDB database, you need to pay $450 US per= =20 database per year ($1150 per database perpetual) for a proprietary hot-back= up=20 tool
2) InnoDB can't do full-text=20 searching.
3) I see alot more corrupt-database bugs o= n the=20 MySQL lists (most are MyISAM, but a few InnoDB bugs pop up from time to tim= e) -=20 way more than I see on the Postgres lists.
4) There are some really cranky people on = the MySQL=20 lists; the Postgres lists seem to be much more effective (esp. with people = like=20 Tom Lane). Maybe it's because they get alot of dumb questions, as people=20 unfamiliar with databases turn to MySQL first?
 
Maybe the Postgres community needs an anti= -FUD=20 individual or two; people that know both databases, and can provide the pro= per=20 information for answering questions like this. A section in the docs would = help=20 as well. Yes, I know many of the people advocating Postgres do not want to= =20 compare themselves to MySQL (but rather to Oracle, Sybase, DB2, etc) , but = the=20 volume of responses on a thread like this indicates that the comparison is = going=20 to happen regardless. Better to nip it in the bud quickly than let it go on= over=20 3-4 days.
 
One last observation: someone looking at b= oth=20 databases, reading those posts, might get a bad impression of Postgres base= d on=20 the inconsistency and incorrectness of some of the statements made about My= SQL.=20 If a salesperson provides misinformation about a competitors product and yo= u=20 find out about it, that salesperson has most likely lost a=20 customer.
 
Anyway, I hope I haven't offended anyone -= I'm not=20 trying to troll or flame, but rather just give some constructive criticism = from=20 someone outside both the MySQL and Postgres camps.
 
David
 
------=_NextPart_000_03B7_01C38E50.4F83A020-- From pgsql-performance-owner@postgresql.org Thu Oct 9 14:58:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E67B3D1B4E9 for ; Thu, 9 Oct 2003 17:58:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81192-10 for ; Thu, 9 Oct 2003 14:58:08 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 12243D1B4EF for ; Thu, 9 Oct 2003 14:58:05 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99Hvw611440; Thu, 9 Oct 2003 13:57:58 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091757.h99Hvw611440@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: <20031009171611.GJ14394@libertyrms.info> To: Andrew Sullivan Date: Thu, 9 Oct 2003 13:57:58 -0400 (EDT) Cc: "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/289 X-Sequence-Number: 4037 Andrew Sullivan wrote: > On Thu, Oct 09, 2003 at 01:04:23PM -0400, Jeff wrote: > > > > So you think we should leave PG alone and let it run horrifically slowly? > > Do you have a better idea of how to do this? > > Given the point in the release cycle, mightn't the FAQ_Solaris or > some other place be better for this for now? I agree with the > concern. I'd rather have slow'n'stable than fast-but-broken. FAQ added. -- 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-advocacy-owner@postgresql.org Thu Oct 9 15:01:57 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 16CCCD1B567; Thu, 9 Oct 2003 18:01:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82414-07; Thu, 9 Oct 2003 15:01:05 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 28B2DD1B4E9; Thu, 9 Oct 2003 15:01:04 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3746273; Thu, 09 Oct 2003 11:01:40 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: David Griffiths , pgsql-performance@postgresql.org Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 10:59:03 -0700 User-Agent: KMail/1.4.3 References: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> In-Reply-To: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> Cc: pgsql-advocacy@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310091059.03308.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/58 X-Sequence-Number: 2346 David, Thanks for being considerate, thourough, and honest about your opinions. Particulary that you didn't simple depart in a huff. > 1) the MySQL docs are better (sorry - I found them easier to read, and > more comprehensive; I had an easier time finding the answers I needed) I can believe that. MySQL AB has paid documentation writers; we don't. > 2) there are more web pages devoted to MySQL (probably because it has a > bit more market share) Particularly among web developers. > 3) there are more books on MySQL at the bookstore (I haven't had a > chance to pick up Bruce's book yet; it might be all the book I'd ever > need) Bruce's book is out of date -- released in 1998. I recommend Korry Douglas' book instead, just because of its up-to-date nature (printed late 2002 or early 2003). > 4) we looked at MySQL first (we needed replication, and eRServer had not > been open-sourced when we started looking) I can't do anything about that, now can I? > With regards to #1, I'd like to specifically mention tuning - the docs > at http://www.postgresql.org/docs/7.3/static/runtime-config.html > give a Have you checked these pages? They've been posted on this list numerous times: http://techdocs.postgresql.org http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html Also, the runtime docs are being improved in 7.4: http://developer.postgresql.org/docs/postgres/runtime-config.html ... and I'm still working on more general "how to" text. > "I guess my point is simply this: instead of saying: "okay we use > default settings that will run on _old_ hardware too" we should go for a > little script that creates a "still save but much better" config file. > There's just no point in setting SHARED_BUFFERS to something like 16 > (what's the current default?) if the PC has >= 1 GB of RAM. Setting it > to 8192 would still be save, but 512 times better... ;-) (IIRC 8192 > would take 64 MB of RAM, which should be save if you leave the default > MAX_CONNECTIONS.)" You'll be interested to know that SHARED_BUFFERS are actually addressed in the initdb script in 7.4. However, may OSes have low limits on per-process memory that requires the admin to modify the sysconf before postgresql.conf can be adjusted properly. This makes writing a multi-platform tuning script a significant effort, and to date nobody who is complaining about it the loudest has volunteered to do the work. To reiterate my point above, PostgreSQL is a 100% volunteer Open Source project. MySQL is a commercial company which distributes its products via Open Source licensing. That makes some things easier for them than for us (and vice-versa, of course). > I also have to admit a bit of irritation reading this thread; there is a > fair number of incorrect statements on this thread that, while not > wrong, definately aren't right: We've been working on this on the advocacy list .... that is, giving an accurate listing of PostgreSQL features not posessed by MySQL (same for Oracle and DB2 as well, MySQL is just easier to start becuase we don't have to worry about being sued). I'd appreciate it if you'd take an interest in that document and revise anything which is innaccurate or perjorative. Also, keep in mind that many members of the PostgreSQL community have "an axe to grind" about MySQL. This is not only because of MySQL's eclipsing us in the popular press as "THE open source database"; it is also because prominent individuals at MySQL AB, particularly Monty and David Axmark, have in the past signaled their intent to rub out all other OSS databases, starting with PostgreSQL. While this says little about the MySQL community, it does make members of our communty very touchy when the "M" word comes up. I quote the rest of your debunking for the benefit of the readers on the Advocacy list, with a couple of comments: > "Speed depends on the nature of use and the complexity of queries. If > you are doing updates of related tables, ACID is of vital importance and > MySQL doesn't provide it." > MySQL has ACID in InnoDB. I've found that MySQL is actually very fast on > complex queries w/InnoDB (six tables, 1 million rows, two of the joins > are outer-joins. In fact, I can get InnoDB to be almost as fast as > MyISAM. Complex updates are also very very fast. We have not tried > flooding either database with dozens of complex statements from multiple > clients; that's coming soon, and from what I've read, MySQL won't do too > well. > > "using InnoDB tables (the only way to have foreign keys, transactions, > and row level locking for MySQL) makes MySQL slower and adds complexity > to tuning the database" > Adding this: "innodb_flush_method=O_DSYNC" to the my.cnf made InnoDB as > fast as MyISAM in our tests. It doesn't turn off disk flushing; it's > just a flush method that might work better with different kernels and > drives; it's one of those "play with this and see if it helps" > parameters; there are lots of those in Postgres, it seems. There are 10 > variables for tuning InnoDB (and you don't have to tune for MyISAM, so > it's actually a six-of-one, half-dozen-of-the-other). Setup between the > two seems to be about the same. > > "PostgreSQL supports constraints. MySQL doesn't; programmers need to > take care of that from the client side" > Again, InnoDB supports constraints. Really? This is news. We did some tests on constraints on InnoDB, and found that while they parsed, they were not actually enforced. Was our test in error? > "Transactions: We've been here before. Suffice to say, MySQL+InnoDB is > almost there. Plain ol' MySQL doesn't have it, which tells you something > about their philosophy towards database design." > InnoDB supports transactions very nicely, has the equivalent of WAL, and > one thing I really like: a tablespace (comprised of data files that can > be spread around multiple hard drives), and in a month or so, InnoDB > will support multiple tablespaces. We'll have multiple tablespaces soon as well. They didn't quite make it for 7.4, but will be in 7.5. > To be fair, here are a few MySQL "bad-things" that weren't mentioned: > > 1) InnoDB can't do a hot-backup with the basic backup tools. To > hot-backup an InnoDB database, you need to pay $450 US per database per > year ($1150 per database perpetual) for a proprietary hot-backup tool > 2) InnoDB can't do full-text searching. > 3) I see alot more corrupt-database bugs on the MySQL lists (most are > MyISAM, but a few InnoDB bugs pop up from time to time) - way more than > I see on the Postgres lists. This is consistent with MySQL's emphasis on speed and ease-of-use over reliability; we have the opposite emphasis (see below). > 4) There are some really cranky people on the MySQL lists; the Postgres > lists seem to be much more effective (esp. with people like Tom Lane). > Maybe it's because they get alot of dumb questions, as people unfamiliar > with databases turn to MySQL first? Possibly. Also I think it's because of the poor organization of their mailing lists; ours are clearly divided into particular topics and experienced members politiely encourage toplicality. Further, the participation by major contributors on our lists is, from what I've heard, higher; this means that complaintants have faith that their complaints will reach the eyes of those actually responsible for the code. > Maybe the Postgres community needs an anti-FUD individual or two; people > that know both databases, and can provide the proper information for > answering questions like this. A section in the docs would help as well. > Yes, I know many of the people advocating Postgres do not want to > compare themselves to MySQL (but rather to Oracle, Sybase, DB2, etc) , > but the volume of responses on a thread like this indicates that the > comparison is going to happen regardless. Better to nip it in the bud > quickly than let it go on over 3-4 days. Would you care to volunteer? We'd be glad to have you. > One last observation: someone looking at both databases, reading those > posts, might get a bad impression of Postgres based on the inconsistency > and incorrectness of some of the statements made about MySQL. If a > salesperson provides misinformation about a competitors product and you > find out about it, that salesperson has most likely lost a customer. Maybe. Not that I'm saying that inaccurate propaganda is a good thing, but that it seems so pervasive in the industry that I think people expect it. We trash MySQL; MySQL publishes 6-year-old PG vs. MySQL benchmarks; Oracle puts down all Open Source databases based on MySQL's limitations; and MS SQL Server publishes benchmarks based on MSSQL on a cluster vs. other DBs on workstations. > Anyway, I hope I haven't offended anyone - I'm not trying to troll or > flame, but rather just give some constructive criticism from someone > outside both the MySQL and Postgres camps. Hmmm .... also, come to think about it, MySQL has done us a favor in some ways by making our project take advocacy and user-friendliness seriously, something we didn't always do. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 9 15:02:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8D2C1D1B553 for ; Thu, 9 Oct 2003 18:02:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 85386-02 for ; Thu, 9 Oct 2003 15:02:07 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id EE54CD1B4F4 for ; Thu, 9 Oct 2003 15:02:05 -0300 (ADT) Received: (qmail 71033 invoked from network); 9 Oct 2003 18:02:10 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 18:02:10 -0000 Date: Thu, 9 Oct 2003 14:02:10 -0400 (EDT) From: Jeff To: David Griffiths Cc: "pgsql-performance@postgresql.org" Subject: Re: PostgreSQL vs MySQL In-Reply-To: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> 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: 200310/291 X-Sequence-Number: 4039 On Thu, 9 Oct 2003, David Griffiths wrote: > 1) the MySQL docs are better (sorry - I found them easier to read, and > more comprehensive; I had an easier time finding the answers I needed) Huh. I had the opposite experience. Each to his own. I think everybody agrees PG needs a better tuning doc (or pointers to it, or something). > "Speed depends on the nature of use and the complexity of queries. If > you are doing updates of related tables, ACID is of vital importance and > MySQL doesn't provide it." I don't know if you looked at my presentation. But in preparation for it I checked out MySQL 4.0.x[most recent stable]. I found that I violates the C in acid in some places. ie you can insert a date of 0000/00/00 and have it sit there and be fine. Perhaps this is the fault of mysql's timestamp type. > MyISAM. Complex updates are also very very fast. We have not tried > flooding either database with dozens of complex statements from multiple > clients; You don't need complex statements to topple mysql over in high concurrency. I was doing fairly simple queries with 20 load generators - it didn't like it. Not at all (mysql: 650 seconds pg: 220) > 3) I see alot more corrupt-database bugs on the MySQL lists (most are > MyISAM, but a few InnoDB bugs pop up from time to time) - way more than > I see on the Postgres lists. I saw this as well. I was seeing things in the changelog as late as september (this year) about fixing bugs that cause horrific corruption. That doesn't make me feel comfy. Remember - in reality InnoDB is still very new. The PG stuff has been tinkered with for years. I like innovation and new things, but in some cases, I prefer the old code that has been looked at for years. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 15:05:56 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B1E3BD1B52E for ; Thu, 9 Oct 2003 18:05:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 89708-01 for ; Thu, 9 Oct 2003 15:05:06 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 7B353D1B573 for ; Thu, 9 Oct 2003 15:04:36 -0300 (ADT) Received: (qmail 71068 invoked from network); 9 Oct 2003 18:04:41 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 18:04:41 -0000 Date: Thu, 9 Oct 2003 14:04:41 -0400 (EDT) From: Jeff To: Bruce Momjian Cc: Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! In-Reply-To: <200310091340.h99DeBm22361@candle.pha.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: 200310/292 X-Sequence-Number: 4040 We're keeping the -O2 for gcc in the template and moving the mention of -fast to the FAQ, correct? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 15:11:43 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DCB3BD1B516 for ; Thu, 9 Oct 2003 18:11:42 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90642-05 for ; Thu, 9 Oct 2003 15:10:57 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3AB39D1B541 for ; Thu, 9 Oct 2003 15:10:54 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99IAiC12934; Thu, 9 Oct 2003 14:10:44 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091810.h99IAiC12934@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: To: Jeff Date: Thu, 9 Oct 2003 14:10:44 -0400 (EDT) Cc: Neil Conway , "pgsql-performance@postgresql.org" X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/293 X-Sequence-Number: 4041 Jeff wrote: > We're keeping the -O2 for gcc in the template and moving the mention of > -fast to the FAQ, correct? gcc gets -O2, non-gcc gets -O, and -fast is in the FAQ, yea. -- 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 Oct 9 15:12:02 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 37834D1B52A for ; Thu, 9 Oct 2003 18:12:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 88325-07 for ; Thu, 9 Oct 2003 15:11:13 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 44619D1B564 for ; Thu, 9 Oct 2003 15:11:12 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 7F18D21072; Thu, 9 Oct 2003 11:11:12 -0700 (PDT) Date: Thu, 9 Oct 2003 11:11:12 -0700 From: Sean Chittenden To: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031009181112.GA71907@perrin.nxad.com> References: <200310090956.11356.josh@agliodbs.com> <20031009171715.GR2979@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031009171715.GR2979@rlx11.zapatec.com> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/294 X-Sequence-Number: 4042 > Yeah, I had similar thought to Oliver's and suspected that this > would be the answer. Also, while it's not too hard to do this for a > single platform, it gets complecated once you start looking at > different ones. > > Josh, let me know when you're ready to do this. I'll try to help, > although my perl's kind of rusty. Also, can you even assume perl for > a postgres install? Does Solaris, for instance come with perl? Um, why not wait until the C version of initdb is committed, then steak out a section that'll allow us to submit patches to have initdb autotune to our hearts content? There's a tad bit of precedence with having shared buffer's automatically set in initdb, why not continue with it? I know under FreeBSD initdb will have some #ifdef's to wrap around the syscall sysctl() to get info about kernel bits. Talking about how to expand handle this gracefully for a gazillion different platforms might be a more useful discussion at this point because I'm sure people from their native OS will be able to contrib the necessary patches to extract info from their OS so that initdb can make useful decisions. Or, lastly, does anyone think that this should be in a different, external program? -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Thu Oct 9 16:26:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA3DDD1B584 for ; Thu, 9 Oct 2003 19:26:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07373-03 for ; Thu, 9 Oct 2003 16:26:08 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id DA15AD1B58D for ; Thu, 9 Oct 2003 16:20:57 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h99JKvQj025547 for ; Thu, 9 Oct 2003 19:20:57 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h99JA05E023992 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 19:10:00 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Sun performance - Major discovery! Date: Thu, 09 Oct 2003 14:12:30 -0400 Organization: Hub.Org Networking Services Lines: 17 Message-ID: <60znga5lgx.fsf@dev6.int.libertyrms.info> References: <200310091708.h99H8fY07153@candle.pha.pa.us> 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:zYe+1TgI8wS+5qB9MUl8rUqWAgA= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/300 X-Sequence-Number: 4048 pgman@candle.pha.pa.us (Bruce Momjian) writes: > 5) How can I compile for optimum performance? > > Try using the "-fast" compile flag. The binaries might not be portable to > other Solaris systems, and you might need to compile everything that links > to PostgreSQL with "-fast", but PostgreSQL will run significantly faster, > 50% faster on some tests. You might also mention something like the following: If you are compiling using GCC, you will quite likely want to add in the "-O2" compile flag. -- let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; Christopher Browne (416) 646 3304 x124 (land) From pgsql-advocacy-owner@postgresql.org Thu Oct 9 15:16:19 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D5A20D1B4FC; Thu, 9 Oct 2003 18:16:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90801-05; Thu, 9 Oct 2003 15:15:30 -0300 (ADT) Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) by svr1.postgresql.org (Postfix) with ESMTP id 9C80ED1B4E9; Thu, 9 Oct 2003 15:15:28 -0300 (ADT) 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 h99IFE5f013904; Thu, 9 Oct 2003 13:15:15 -0500 Reply-To: From: "Nick Fankhauser" To: "Josh Berkus" , Cc: Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 13:14:41 -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 In-Reply-To: <200310091059.03308.josh@agliodbs.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/59 X-Sequence-Number: 2347 > Have you checked these pages? They've been posted on this list numerous > times: > http://techdocs.postgresql.org > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > Josh- It would be great to have a link to those last two excellent resources from the techdocs area- perhaps from the "optimizing" section in http://techdocs.postgresql.org/oresources.php. Who should we suggest this to? (I submitted these using the form in that area, but you may have better connections.) -Nick From pgsql-performance-owner@postgresql.org Thu Oct 9 17:33:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7BC4FD1B528 for ; Thu, 9 Oct 2003 20:33:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23225-03 for ; Thu, 9 Oct 2003 17:32:26 -0300 (ADT) Received: from smtp.noos.fr (nan-smtp-11.noos.net [212.198.2.82]) by svr1.postgresql.org (Postfix) with ESMTP id 2EF04D1B4ED for ; Thu, 9 Oct 2003 17:32:24 -0300 (ADT) Received: (qmail 5276007 invoked by uid 0); 9 Oct 2003 20:32:24 -0000 Received: from unknown (HELO bigfoot.com) ([212.198.37.110]) (envelope-sender ) by 212.198.2.82 (qmail-ldap-1.03) with SMTP for ; 9 Oct 2003 20:32:24 -0000 Message-ID: <3F85A9B5.6030301@bigfoot.com> Date: Thu, 09 Oct 2003 20:32:21 +0200 From: Gaetano Mendola 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@postgresql.org" Cc: Greg Spiegelberg Subject: Re: Compare rows References: <3F841A28.8060504@cranel.com> <200310081010.26576.josh@agliodbs.com> <3F84613D.8040207@cranel.com> <200310081611.59179.josh@agliodbs.com> <3F857E1C.1040209@cranel.com> In-Reply-To: <3F857E1C.1040209@cranel.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: 200310/310 X-Sequence-Number: 4058 Greg Spiegelberg wrote: > Josh Berkus wrote: > >> >> As you can see, the NULLs are not stored, making this system much more >> efficient on storage space. >> >> Tommorrow I'll (hopefully) write up how to query this for >> comparisons. It would help if you gave a little more details about >> what specific comparison you're doing, e.g. between tables or table to >> value, comparing just the last value or all rows, etc. >> > > Got it. I can see how it would be more efficient in storing. At this > point it would require a lot of query and code rewrites to handle it. > Fortunately, we're looking for alternatives for the next revision and > we're leaving ourselves open for a rewrite much to the boss's chagrin. I'm not sure about the save in storage. See the Hannu Krosing arguments. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Thu Oct 9 15:38:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 02259D1B4EF for ; Thu, 9 Oct 2003 18:38:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92254-07 for ; Thu, 9 Oct 2003 15:37:42 -0300 (ADT) Received: from chimta05.algx.net (mta6.algx.net [67.92.168.235]) by svr1.postgresql.org (Postfix) with ESMTP id A0450D1B4F9 for ; Thu, 9 Oct 2003 15:37:40 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx05.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMI00K5F6ETRX@chimmx05.algx.net> for pgsql-performance@postgresql.org; Thu, 09 Oct 2003 13:37:41 -0500 (CDT) Date: Thu, 09 Oct 2003 14:37:41 -0400 From: Jason Hihn Subject: Any 7.4 w32 numbers in yet? To: pgsql-performance@postgresql.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/296 X-Sequence-Number: 4044 I am very interested in the non-Cygwin windows port. Looking over the 7.4 beta release, it looks like the code made it in. I read through the win32 related docs, to find out that they are out-of date instructions (11/2002). I do hope these get updated with the native windows stuff. But I came here to ask more about the performance of pg-w32. Did it take a hit? Is it faster (than Cygwin, than Unix)? Stability? I saw there were some mailings about file-moving race conditions, links and such. Thanks. Jason Hihn Paytime Payroll From pgsql-performance-owner@postgresql.org Thu Oct 9 15:41:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 02BDFD1B576 for ; Thu, 9 Oct 2003 18:41:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 92131-10 for ; Thu, 9 Oct 2003 15:41:11 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 70101D1B4F0 for ; Thu, 9 Oct 2003 15:40:51 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99IeiV15375; Thu, 9 Oct 2003 14:40:44 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091840.h99IeiV15375@candle.pha.pa.us> Subject: Re: Any 7.4 w32 numbers in yet? In-Reply-To: To: Jason Hihn Date: Thu, 9 Oct 2003 14:40:44 -0400 (EDT) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/297 X-Sequence-Number: 4045 Jason Hihn wrote: > I am very interested in the non-Cygwin windows port. Looking over the 7.4 > beta release, it looks like the code made it in. I read through the win32 > related docs, to find out that they are out-of date instructions (11/2002). > I do hope these get updated with the native windows stuff. > > But I came here to ask more about the performance of pg-w32. Did it take a > hit? Is it faster (than Cygwin, than Unix)? Stability? I saw there were some > mailings about file-moving race conditions, links and such. See: http://momjian.postgresql.org/main/writings/pgsql/win32.html We don't have it running yet. It will be running in 7.5. -- 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-advocacy-owner@postgresql.org Thu Oct 9 16:06:31 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DA016D1B8A8; Thu, 9 Oct 2003 19:06:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96924-06; Thu, 9 Oct 2003 16:05:46 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 99870D1B93D; Thu, 9 Oct 2003 16:03:06 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3746562; Thu, 09 Oct 2003 12:03:43 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: , Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 12:01:10 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310091201.10676.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/60 X-Sequence-Number: 2348 Nick, > Josh- It would be great to have a link to those last two excellent resour= ces > from the techdocs area- perhaps from the "optimizing" section in > http://techdocs.postgresql.org/oresources.php. Who should we suggest this > to? (I submitted these using the form in that area, but you may have bett= er > connections.) This is my responsibility; I'll add it to the list. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-advocacy-owner@postgresql.org Thu Oct 9 16:10:02 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 09E07D1B8AC for ; Thu, 9 Oct 2003 19:10:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04188-05 for ; Thu, 9 Oct 2003 16:09:16 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 5D889D1B554 for ; Thu, 9 Oct 2003 16:06:18 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h99I2kqd020305; Thu, 9 Oct 2003 14:02:46 -0400 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 h99J65Z20404; Thu, 9 Oct 2003 15:06:05 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TD8AW35J; Thu, 9 Oct 2003 15:06:03 -0400 Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL From: Robert Treat To: nickf@ontko.com Cc: Josh Berkus , pgsql-advocacy@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 09 Oct 2003 15:06:05 -0400 Message-Id: <1065726365.1944.2398.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/61 X-Sequence-Number: 2349 On Thu, 2003-10-09 at 14:14, Nick Fankhauser wrote: > > Have you checked these pages? They've been posted on this list numerous > > times: > > http://techdocs.postgresql.org > > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > > > > Josh- It would be great to have a link to those last two excellent resources > from the techdocs area- perhaps from the "optimizing" section in > http://techdocs.postgresql.org/oresources.php. Who should we suggest this > to? (I submitted these using the form in that area, but you may have better > connections.) > Unfortunately techdocs is becoming more and more a bastard child since no one can seem to agree on and actually implement a solution to it's current woes. I've (quietly) complained about new articles getting written by the community and posted to sites other than techdocs since I think it makes it harder for folks to find useful information... Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-advocacy-owner@postgresql.org Thu Oct 9 16:34:17 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C2086D1B56A; Thu, 9 Oct 2003 19:34:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08647-02; Thu, 9 Oct 2003 16:33:28 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 59496D1B8A5; Thu, 9 Oct 2003 16:32:56 -0300 (ADT) 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 h99JWRGQ021358; Thu, 9 Oct 2003 13:32:27 -0600 (MDT) Date: Thu, 9 Oct 2003 13:23:25 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: David Griffiths , , Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL In-Reply-To: <200310091059.03308.josh@agliodbs.com> 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: 200310/63 X-Sequence-Number: 2351 On Thu, 9 Oct 2003, Josh Berkus wrote: > David Griffiths wrote: > > With regards to #1, I'd like to specifically mention tuning - the docs > > at http://www.postgresql.org/docs/7.3/static/runtime-config.html > > give a > > Have you checked these pages? They've been posted on this list numerous > times: > http://techdocs.postgresql.org > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > > Also, the runtime docs are being improved in 7.4: > http://developer.postgresql.org/docs/postgres/runtime-config.html > ... and I'm still working on more general "how to" text. any chance of getting the perf.html file from varlena folded into the main documentation tree somewhere? it's a great document, and it would definitely help if the tuning section of the main docs said "For a more thorough examination of postgresql tuning see this:" and pointed to it. From pgsql-performance-owner@postgresql.org Thu Oct 9 16:38:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7CEAED1B949 for ; Thu, 9 Oct 2003 19:38:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 08858-07 for ; Thu, 9 Oct 2003 16:37:41 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 96163D1B8EA for ; Thu, 9 Oct 2003 16:35:49 -0300 (ADT) 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 h99JYnGQ021611; Thu, 9 Oct 2003 13:34:49 -0600 (MDT) Date: Thu, 9 Oct 2003 13:25:47 -0600 (MDT) From: "scott.marlowe" To: Jeff Cc: David Griffiths , "pgsql-performance@postgresql.org" Subject: Re: PostgreSQL vs MySQL In-Reply-To: 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: 200310/304 X-Sequence-Number: 4052 On Thu, 9 Oct 2003, Jeff wrote: > On Thu, 9 Oct 2003, David Griffiths wrote: > > > 1) the MySQL docs are better (sorry - I found them easier to read, and > > more comprehensive; I had an easier time finding the answers I needed) > > Huh. I had the opposite experience. Each to his own. > I think everybody agrees PG needs a better tuning doc (or pointers to it, > or something). I think the issue is that Postgresql documentation is oriented towards DBA types, who already understand databases in general, so they can find what they want, while MySQL docs are oriented towards dbms newbies, who don't know much, if anything, about databases. From pgsql-performance-owner@postgresql.org Thu Oct 9 16:31:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2B31ED1B56A for ; Thu, 9 Oct 2003 19:31:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07961-04 for ; Thu, 9 Oct 2003 16:30:39 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 8E72CD1B56D for ; Thu, 9 Oct 2003 16:27:56 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h99JRuA28389; Thu, 9 Oct 2003 15:27:56 -0400 (EDT) From: Bruce Momjian Message-Id: <200310091927.h99JRuA28389@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: <60znga5lgx.fsf@dev6.int.libertyrms.info> To: Christopher Browne Date: Thu, 9 Oct 2003 15:27:56 -0400 (EDT) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/301 X-Sequence-Number: 4049 Christopher Browne wrote: > pgman@candle.pha.pa.us (Bruce Momjian) writes: > > 5) How can I compile for optimum performance? > > > > Try using the "-fast" compile flag. The binaries might not be portable to > > other Solaris systems, and you might need to compile everything that links > > to PostgreSQL with "-fast", but PostgreSQL will run significantly faster, > > 50% faster on some tests. > > You might also mention something like the following: > > If you are compiling using GCC, you will quite likely want to add in > the "-O2" compile flag. We already do that by default in current CVS for gcc, and -O for non-gcc. -- 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-advocacy-owner@postgresql.org Thu Oct 9 16:33:01 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9FDB1D1B8B4 for ; Thu, 9 Oct 2003 19:32:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07201-08 for ; Thu, 9 Oct 2003 16:32:14 -0300 (ADT) Received: from hosting.commandprompt.com (220.commandprompt.com [207.173.200.220]) by svr1.postgresql.org (Postfix) with ESMTP id 359CCD1B516 for ; Thu, 9 Oct 2003 16:31:15 -0300 (ADT) Received: from commandprompt.com (dsl093-077-251.sea2.dsl.speakeasy.net [66.93.77.251]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id h99JVDA03884; Thu, 9 Oct 2003 12:31:13 -0700 Message-ID: <3F85B740.2020707@commandprompt.com> Date: Thu, 09 Oct 2003 12:30:08 -0700 From: "Joshua D. Drake" Organization: Command Prompt, Inc. 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: Robert Treat Cc: nickf@ontko.com, Josh Berkus , pgsql-advocacy@postgresql.org Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL References: <1065726365.1944.2398.camel@camel> In-Reply-To: <1065726365.1944.2398.camel@camel> 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: 200310/62 X-Sequence-Number: 2350 Hello, One of the other problems with techdocs is that it is way to top level heavy. There is a ton of information that is on the front page that really shouldn't be. IMHO: There shouldn't be a separate box for JDBC... There should be one that is a link to an intefaces page. The interfaces page should have subsequent information about JDBC/Perl/Python/etc... As much as I personally appreciate the Online Books box, it should be one link that say Documentation. That link should open a page that has resources for the books, and other online docs as well as a link to an articles page. etc... Sincerely, Joshua Drake Robert Treat wrote: >On Thu, 2003-10-09 at 14:14, Nick Fankhauser wrote: > > >>>Have you checked these pages? They've been posted on this list numerous >>>times: >>>http://techdocs.postgresql.org >>>http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html >>>http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html >>> >>> >>> >>Josh- It would be great to have a link to those last two excellent resources >>from the techdocs area- perhaps from the "optimizing" section in >>http://techdocs.postgresql.org/oresources.php. Who should we suggest this >>to? (I submitted these using the form in that area, but you may have better >>connections.) >> >> >> > >Unfortunately techdocs is becoming more and more a bastard child since >no one can seem to agree on and actually implement a solution to it's >current woes. I've (quietly) complained about new articles getting >written by the community and posted to sites other than techdocs since I >think it makes it harder for folks to find useful information... > >Robert Treat > > -- Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC Postgresql support, programming shared hosting and dedicated hosting. +1-503-222-2783 - jd@commandprompt.com - http://www.commandprompt.com Editor-N-Chief - PostgreSQl.Org - http://www.postgresql.org From pgsql-performance-owner@postgresql.org Thu Oct 9 16:35:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 34B54D1B8D4 for ; Thu, 9 Oct 2003 19:35:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07918-07 for ; Thu, 9 Oct 2003 16:34:56 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 1A9EBD1B4EA for ; Thu, 9 Oct 2003 16:33:58 -0300 (ADT) Received: (qmail 71865 invoked from network); 9 Oct 2003 19:34:04 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 9 Oct 2003 19:34:04 -0000 Date: Thu, 9 Oct 2003 15:34:03 -0400 (EDT) From: Jeff To: pgsql-performance@postgresql.org Subject: backup/restore - another area. 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: 200310/303 X-Sequence-Number: 4051 Boy, I must be getting annoying by now huh? Anyway, after the joys of Solaris being fast I'm moving onto another area - backup & restore. I've been checking the archives and haven't seen any "good" tips for backing up big databases (and more importantly, restoring). I've noticed while doing a backup (with both -Fc and regular recipe) that my IO is no where near being stressed. According to vmstat, it sits around reading about 512kB/sec (with occasional spikes) and every 5-6 seconds it writes out a 3MB hunk. So as a test I decided to cp a 1GB file and got a constant read speed of 20MB/sec and the writes. well. were more sporatic (buffering most likely) and it would write out 60MB every 3 seconds. And. then.. on the restore I notice similar things - IO hardly being stressed at all... reading in at ~512kB/sec and every now and then writing out a few MB. So, I've been thinking of various backup/restore strategies... some I'm sure some people do, some need code written and may be controvertial.. Idea #1: Use an LVM and take a snapshop - archive that. >From the way I see it. the downside is the LVM will use a lot of space until the snapshot is removed. Also PG may be in a slightly inconsistant state - but this should "appear" to PG the same as if the power went out. For restore, simply unarchive this snapshot and point postgres at it. Let it recover and you are good to go. Little overhead from what I see... I'm leaning towards this method the more I think of it. Idea #2: a new program/internal "system". Lets call it pg_backup. It would generate a very fast backup (that restores very fast) at the expense of disk space. Pretty much what we would do is write out new copies of all the pages in the db - both indexes and tables. the pro's to this is it does not depend on an LVM and therefore is accessable to all platforms. it also has the other benfets mentioned above, except speed. For a restore PG would need something like a 'restore mode' where we can just have it pump pages into it somehow.. It would not have to build index, check constraints, and all that because by definition the backup would contain valid data. The downside for both of these are that the backup is only good for that version of PG on that architecture. Speaking in Informix world this is how it is - it has a fast backup & fast restore that does essentially #2 and then it has export/import options (works like our current pg_dump and restore). and oh yeah -I've tried disabling fsync on load and while it did go faster it was only 2 minutes faster (9m vs 11m). Any thoughts on this? What do you ther folk with big db's do? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 9 16:59:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EB12DD1B577 for ; Thu, 9 Oct 2003 19:59:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13242-01 for ; Thu, 9 Oct 2003 16:58:44 -0300 (ADT) Received: from chimta05.algx.net (mta6.algx.net [67.92.168.235]) by svr1.postgresql.org (Postfix) with ESMTP id 2A0E6D1B57F for ; Thu, 9 Oct 2003 16:56:34 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx05.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMI006NJA29EN@chimmx05.algx.net> for pgsql-performance@postgresql.org; Thu, 09 Oct 2003 14:56:36 -0500 (CDT) Date: Thu, 09 Oct 2003 15:56:33 -0400 From: Jason Hihn Subject: Re: PostgreSQL vs MySQL In-reply-to: To: "scott.marlowe" , Jeff Cc: David Griffiths , pgsql-performance@postgresql.org Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/305 X-Sequence-Number: 4053 I concur 100%. PostgreSQL was big and scary and MySQL seemed cute and cuddly, warm and fuzzy. Then I took my undergrad CS RDBMS course (a course that focused on designing the backend software), and only then was I ready to appreciate and wield the battle axe that is PostgreSQL. He also let me use PostgreSQL for my final project (the standard was Oracle). I got an A. :) I do have to admit that I prefer OSS (and docs) better than proprietary. I had some Informix work and that was not fun at all. So even though the MySQL is pink fuzzy bunnies, PostgreSQL is at least a brown fuzzy bunny [to me anyway]. > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of > scott.marlowe > Sent: Thursday, October 09, 2003 3:26 PM > To: Jeff > Cc: David Griffiths; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] PostgreSQL vs MySQL > > > On Thu, 9 Oct 2003, Jeff wrote: > > > On Thu, 9 Oct 2003, David Griffiths wrote: > > > > > 1) the MySQL docs are better (sorry - I found them easier to read, and > > > more comprehensive; I had an easier time finding the answers I needed) > > > > Huh. I had the opposite experience. Each to his own. > > I think everybody agrees PG needs a better tuning doc (or > pointers to it, > > or something). > > I think the issue is that Postgresql documentation is oriented > towards DBA > types, who already understand databases in general, so they can find what > they want, while MySQL docs are oriented towards dbms newbies, who don't > know much, if anything, about databases. > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > From pgsql-performance-owner@postgresql.org Thu Oct 9 17:01:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3F874D1B4F4 for ; Thu, 9 Oct 2003 20:01:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 12422-06 for ; Thu, 9 Oct 2003 17:01:03 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 0E3AFD1B56E for ; Thu, 9 Oct 2003 16:59:25 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h99Iswqd021374; Thu, 9 Oct 2003 14:54:58 -0400 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 h99JwHZ22308; Thu, 9 Oct 2003 15:58:17 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TD8AWPJM; Thu, 9 Oct 2003 15:58:15 -0400 Subject: Re: PostgreSQL vs MySQL From: Robert Treat To: David Griffiths Cc: pgsql-performance@postgresql.org In-Reply-To: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> References: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 09 Oct 2003 15:58:17 -0400 Message-Id: <1065729497.8420.2558.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/306 X-Sequence-Number: 4054 On Thu, 2003-10-09 at 13:30, David Griffiths wrote: > I also have to admit a bit of irritation reading this thread; there is a > fair number of incorrect statements on this thread that, while not > wrong, definately aren't right: > > "Speed depends on the nature of use and the complexity of queries. If > you are doing updates of related tables, ACID is of vital importance and > MySQL doesn't provide it." > MySQL has ACID in InnoDB. Actually it only kinda sorta has acid. As Jeff mentioned, and it can be expanded upon, mysql has a nasty habit of transforming invalid data into something that will insert into a table and not telling you about it. I think Josh mentioned reports that it ignores some constraint definitions. And then theres the whole mixing MyISAM and InnoDB tables completely breaks the ability to rollback transactions... > > "using InnoDB tables (the only way to have foreign keys, transactions, > and row level locking for MySQL) makes MySQL slower and adds complexity > to tuning the database" > Adding this: "innodb_flush_method=O_DSYNC" to the my.cnf made InnoDB as > fast as MyISAM in our tests. It doesn't turn off disk flushing; it's > just a flush method that might work better with different kernels and > drives; it's one of those "play with this and see if it helps" > parameters; there are lots of those in Postgres, it seems. There are 10 > variables for tuning InnoDB (and you don't have to tune for MyISAM, so > it's actually a six-of-one, half-dozen-of-the-other). Setup between the > two seems to be about the same. Well, I've yet to see MySQL benchmark themselves vs. the big boys using InnoDB tables, I'm only guessing that it's because those tables are slower. (Well, guessing and calling upon experience) Sure there may be work arounds, but that does add a certain complexity. (Bonus for us, PostgreSQL is just complex from the get go :-P ) > > "PostgreSQL supports constraints. MySQL doesn't; programmers need to > take care of that from the client side" > Again, InnoDB supports constraints. > We've seen evidence it doesn't. If they've fixed this great. Of course I'll quote from the mysql docs "InnoDB allows you to drop any table even though that would break the foreign key constraints which reference the table." last I knew it did this silently and without warning. there are other issues as well, so it's support is relative... > "Transactions: We've been here before. Suffice to say, MySQL+InnoDB is > almost there. Plain ol' MySQL doesn't have it, which tells you something > about their philosophy towards database design." > InnoDB supports transactions very nicely, has the equivalent of WAL, and > one thing I really like: a tablespace (comprised of data files that can > be spread around multiple hard drives), and in a month or so, InnoDB > will support multiple tablespaces. > Just don't mix InnoDB and MyISAM tables together or you could end up in a world of trouble... its unfortunate that this breaks one of the main keys to building a DBMS, namely hiding implementation details from the end users. > Maybe the Postgres community needs an anti-FUD individual or two; people > that know both databases, and can provide the proper information for > answering questions like this. Well, among the major advocacy folk we do have a mantra about no FUD, but these are public lists so we cant really stop people from posting. Of course this overlooks the fact that different people interpret different information differently. (heh) Take this quote I saw posted in a non postgresql forum a while back: "MySQL doesn't fully support subqueries" which of course created a slew of posts about FUD and postgresql users being idiots. If course, when the posted responded back with the question "Can mysql do subselects in the SELECT, FROM, and WHERE clauses like postgresql, and nest subselects within those subselects?" it stopped everyone in their tracks... > A section in the docs would help as well. In the docs no, on techdocs, maybe. > Yes, I know many of the people advocating Postgres do not want to > compare themselves to MySQL (but rather to Oracle, Sybase, DB2, etc) , > but the volume of responses on a thread like this indicates that the > comparison is going to happen regardless. Better to nip it in the bud > quickly than let it go on over 3-4 days. > It was due to the help of postgresql users that the following site has become available: http://sql-info.de/mysql/gotchas.html I'd suggest you look it over if your trying to evaluate a switch from Oracle to MySQL. And anyone is welcome, actually encouraged, to correct erroneous information they see posted about any system on these lists. God bless if you're willing to try and follow every list every day to watch for these types of posts. > One last observation: someone looking at both databases, reading those > posts, might get a bad impression of Postgres based on the inconsistency > and incorrectness of some of the statements made about MySQL. If a > salesperson provides misinformation about a competitors product and you > find out about it, that salesperson has most likely lost a customer. > Unfortunate that you'd attribute anyone who posts on these lists as a sales person for postgresql... Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-advocacy-owner@postgresql.org Thu Oct 9 17:05:09 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 252A5D1B516; Thu, 9 Oct 2003 20:05:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 15853-04; Thu, 9 Oct 2003 17:04:21 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 79A69D1B4F0; Thu, 9 Oct 2003 17:03:12 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3746810; Thu, 09 Oct 2003 13:03:49 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 13:01:17 -0700 User-Agent: KMail/1.4.3 Cc: David Griffiths , , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310091301.17293.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/64 X-Sequence-Number: 2352 Scott, > any chance of getting the perf.html file from varlena folded into the mai= n=20 > documentation tree somewhere? it's a great document, and it would=20 > definitely help if the tuning section of the main docs said "For a more= =20 > thorough examination of postgresql tuning see this:" and pointed to it. Actually, I'm working on that this weekend. --=20 -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 9 17:15:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F405D1B4F9 for ; Thu, 9 Oct 2003 20:14:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20325-04 for ; Thu, 9 Oct 2003 17:14:15 -0300 (ADT) Received: from colsweeper.cranel.com (newmail.cranel.com [12.32.71.147]) by svr1.postgresql.org (Postfix) with ESMTP id 91EEBD1B4EA for ; Thu, 9 Oct 2003 17:14:12 -0300 (ADT) Received: from colmail01.cranel.com (colmail01.cranel.com) by colsweeper.cranel.com (Content Technologies SMTPRS 4.2.5) with ESMTP id for ; Thu, 9 Oct 2003 16:16:21 -0400 Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by colmail01.cranel.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id T6NHFQVJ; Thu, 9 Oct 2003 16:17:06 -0400 Message-ID: <3F85C190.6080108@cranel.com> Date: Thu, 09 Oct 2003 16:14:08 -0400 From: Greg Spiegelberg Organization: Cranel, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Compare rows, SEMI-SUMMARY References: <3F841A28.8060504@cranel.com> <200310081611.59179.josh@agliodbs.com> <200310082236.59305.josh@agliodbs.com> <1065719782.2529.7.camel@fuji.krosing.net> In-Reply-To: <1065719782.2529.7.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: 200310/308 X-Sequence-Number: 4056 Per Josh's recommendation to implement a Vertical Child Table I came up with 3 possible tables to handle the 3 possible value types: varchar, numeric and bigint. Each table has 7 columns: 1 to denote the time the data was collected, 4 which identify where the data came from, 1 to tell me the value name and the last being the value itself. OLD NEW tables 1 3 columns 642 7 each indexes ~1200 39 views 37 ? rows 1700-3000 30,000 query on table 0.01 sec 0.06 sec query on view 0.02 sec ? Not too bad. Guess there were a few 0's and NULL's out there, eh? 642 * 1,700 = 1,091,400 cells 3 * 7 * 30,000 = 630,000 cells 461,400 NULL's and 0's using the big 'ol table I can get around in this setup, however, I would appreciate some help in recreating my views. The views use to be there simply as an initial filter and to hide all the 0's and NULL's. If I can't do this I will be revisiting and testing possibly hundreds of programs and scripts. Any takers? Greg -- Greg Spiegelberg Sr. Product Development Engineer Cranel, Incorporated. Phone: 614.318.4314 Fax: 614.431.8388 Email: gspiegelberg@Cranel.com Cranel. Technology. Integrity. Focus. From pgsql-performance-owner@postgresql.org Thu Oct 9 17:19:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 133E0D1B4EA for ; Thu, 9 Oct 2003 20:19:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 21289-03 for ; Thu, 9 Oct 2003 17:19:09 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 992A0D1B516 for ; Thu, 9 Oct 2003 17:18:55 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id ; Thu, 9 Oct 2003 13:16:59 -0700 Received: from GRIFFITHS2 ([192.168.12.225]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TTY6Y41G; Thu, 9 Oct 2003 13:16:44 -0700 From: David Griffiths To: Josh Berkus Cc: pgsql-performance@postgresql.org Message-ID: <058f01c38ea3$aea70260$6501a8c0@griffiths2> References: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> <200310091059.03308.josh@agliodbs.com> Subject: Re: OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 13:26:22 -0700 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 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/309 X-Sequence-Number: 4057 > Thanks for being considerate, thourough, and honest about your opinions. > Particulary that you didn't simple depart in a huff. Why would I depart in a huff? I was just trying to make a few objective observations. I really have no biases; I like what I've seen in MySQL, and I like alot of the more Oracle-like features in Postgres. > > 4) we looked at MySQL first (we needed replication, and eRServer had not > > been open-sourced when we started looking) > > I can't do anything about that, now can I? My point was that it's since been open-sourced; it just means I've looked longer at MySQL, as it had replication when we started looking. > Have you checked these pages? They've been posted on this list numerous > times: > http://techdocs.postgresql.org > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html Those are much more instructive; I'm curious - why aren't then in the administrator's section of the docs? > We've been working on this on the advocacy list .... that is, giving an > accurate listing of PostgreSQL features not posessed by MySQL (same for > Oracle and DB2 as well, MySQL is just easier to start becuase we don't have > to worry about being sued). I'd appreciate it if you'd take an interest in > that document and revise anything which is innaccurate or perjorative. I might be able to provide some insight, but I've only been working with MySQL for a month or so (Oracle for about 8 years). > > "PostgreSQL supports constraints. MySQL doesn't; programmers need to > > take care of that from the client side" > > Again, InnoDB supports constraints. > > Really? This is news. We did some tests on constraints on InnoDB, and found > that while they parsed, they were not actually enforced. Was our test in > error? You may have turned them off to load data? I've run into constraints when my data-load script missed some rows in address_type. When it went to do the address_list table, all rows that had the missing address_type failed, as they should. I saw no weakness in the constraints. > > Maybe the Postgres community needs an anti-FUD individual or two; people > > that know both databases, and can provide the proper information for > > answering questions like this. A section in the docs would help as well. > > Yes, I know many of the people advocating Postgres do not want to > > compare themselves to MySQL (but rather to Oracle, Sybase, DB2, etc) , > > but the volume of responses on a thread like this indicates that the > > comparison is going to happen regardless. Better to nip it in the bud > > quickly than let it go on over 3-4 days. > > Would you care to volunteer? We'd be glad to have you. Maybe once all this database testing is done; it's extra work on top of an already heavy load (add a new baby, and free time goes right down the toilet). I need to figure out my performance issues with Postgres, finish my benchmark suite, test a bunch of databases, argue with the CTO, and then start migrating. I'll be sure to post my results to the pgsql-performance@postgresql.org along with the tests. David. From pgsql-performance-owner@postgresql.org Tue Oct 14 13:46:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7D55FD1B553 for ; Thu, 9 Oct 2003 20:32:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23225-02 for ; Thu, 9 Oct 2003 17:31:27 -0300 (ADT) Received: from is.rice.edu (is.rice.edu [128.42.42.24]) by svr1.postgresql.org (Postfix) with ESMTP id 72496D1B56C for ; Thu, 9 Oct 2003 17:31:25 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by localhost.is.rice.edu (Postfix) with ESMTP id 0627541942; Thu, 9 Oct 2003 15:31:27 -0500 (CDT) Received: from is.rice.edu ([127.0.0.1]) by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24280-05; Thu, 9 Oct 2003 15:31:24 -0500 (CDT) Received: by is.rice.edu (Postfix, from userid 18612) id A965A418D9; Thu, 9 Oct 2003 15:31:24 -0500 (CDT) Date: Thu, 9 Oct 2003 15:31:24 -0500 From: Kenneth Marshall To: Jeff Cc: Kenneth Marshall , Bruce Momjian , Neil Conway , "pgsql-performance@postgresql.org" Subject: Re: Sun performance - Major discovery! Message-ID: <20031009203124.GB20719@it.is.rice.edu> References: <20031009162525.GB10888@it.is.rice.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-Virus-Scanned: by amavis-20030314-p2 at is.rice.edu X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/453 X-Sequence-Number: 4201 I would use a simple -xO2 or -xO3 instead as the default with an -fsimple=2. --Ken -x02 -xbuiltin=%all On Thu, Oct 09, 2003 at 01:04:23PM -0400, Jeff wrote: > On Thu, 9 Oct 2003, Kenneth Marshall wrote: > > > Jeff, > > > > My first concern with the -fast option is that it makes an executable > > that is specific for the platform on which the compilation is run > > unless other flags are given. My second concern is the effect it has > > on IEEE floating point behavior w.r.t. rounding, error handling, .... > > And my third concern is that if you use -fast, all other code must > > be compiled and linked with the -fast option for correct operation, > > this includes any functional languages such as perl, python, R,... > > That is a pretty big requirement for a default compilation flag. > > > > Ken Marshall > > > > So you think we should leave PG alone and let it run horrifically slowly? > Do you have a better idea of how to do this? > > And do you have evidence apps compiled with -fast linked to non -fast > (or gcc compiled) have problems? > > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ > > > > ---------------------------(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 Thu Oct 9 20:07:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BA5BBD1B511 for ; Thu, 9 Oct 2003 23:07:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 47587-09 for ; Thu, 9 Oct 2003 20:07:06 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id AC10BD1B4EA for ; Thu, 9 Oct 2003 20:07:03 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 3F83E36A34; Thu, 9 Oct 2003 19:07:01 -0400 (EDT) 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 1A7js5-00074q-00; Thu, 09 Oct 2003 19:07:01 -0400 To: Dror Matalon Cc: Postgresql Performance Subject: Re: Speeding up Aggregates References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> In-Reply-To: <20031008181819.GJ2979@rlx11.zapatec.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 09 Oct 2003 19:07:00 -0400 Message-ID: <87ekxm9fjf.fsf@stark.dyndns.tv> Lines: 23 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: 200310/311 X-Sequence-Number: 4059 Dror Matalon writes: > Actually what finally sovled the problem is repeating the > dtstamp > last_viewed > in the sub select That will at least convince the optimizer to use an index range lookup. But it still will have to scan every record that matches channel==$1, link==$2, and dtstamp>$3. The trick of using limit 1 will be faster still as it only has to retrieve a single record using the index. But you have to be sure to convince it to use the index and the way to do that is to list exactly the same columns in the ORDER BY as are in the index definition. Even if some of the leading columns are redundant because they'll be constant for all of the records retrieved. The optimizer doesn't know to ignore those. > > (This is the thing i pointed out previously in > > <87el6ckrlu.fsf@stark.dyndns.tv> on Feb 13th 2003 on pgsql-general) -- greg From pgsql-performance-owner@postgresql.org Thu Oct 9 20:33:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4AE68D1B50F for ; Thu, 9 Oct 2003 23:33:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59308-08 for ; Thu, 9 Oct 2003 20:32:23 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 34A33D1B4E2 for ; Thu, 9 Oct 2003 20:32:20 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id A5A183697D; Thu, 9 Oct 2003 19:32:22 -0400 (EDT) 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 1A7kGc-0007Yg-00; Thu, 09 Oct 2003 19:32:22 -0400 To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: backup/restore - another area. References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 09 Oct 2003 19:32:22 -0400 Message-ID: <878ynu9ed5.fsf@stark.dyndns.tv> Lines: 40 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: 200310/312 X-Sequence-Number: 4060 Jeff writes: > Idea #1: > Use an LVM and take a snapshop - archive that. > From the way I see it. the downside is the LVM will use a lot of space > until the snapshot is removed. Also PG may be in a slightly inconsistant > state - but this should "appear" to PG the same as if the power went out. > > For restore, simply unarchive this snapshot and point postgres at it. Let > it recover and you are good to go. > > Little overhead from what I see... > I'm leaning towards this method the more I think of it. I don't quite follow your #2 so I can only comment on the above idea of using an LVM snapshot. If you have the hardware and the LVM-fu to be able to do this properly I would recommend it. We actually used to do this with veritas even on Oracle which has full online backup support simply because it was much much faster and the snapshot could be backed up during peak times without any significant performance impact. That's partly because Veritas and Hitachi storage systems kick butt though. Depending on the systems you're considering you may or may not have nearly the same success. Note, you should *test* this backup. You're depending on some subtle semantics with this. If you do it slightly wrong or the LVM does something slightly wrong and you end up with an inconsistent snapshot or missing some critical file the whole backup could be useless. Also, I wouldn't consider this a replacement for having a pg_dump export. In a crisis when you want to restore everything *exactly* the way things were you want the complete filesystem snapshot. But if you just want to load a table the way it was the day before to compare, or if you want to load a test box to do some performance testing, or whatever, you'll need the logical export. -- greg From pgsql-performance-owner@postgresql.org Thu Oct 9 21:18:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8D668D1B4EA for ; Fri, 10 Oct 2003 00:18:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 65528-08 for ; Thu, 9 Oct 2003 21:17:29 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 81C8BD1B507 for ; Thu, 9 Oct 2003 21:17:21 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9A0GnC21875; Thu, 9 Oct 2003 20:16:49 -0400 (EDT) From: Bruce Momjian Message-Id: <200310100016.h9A0GnC21875@candle.pha.pa.us> Subject: Re: further testing on IDE drives In-Reply-To: To: "scott.marlowe" Date: Thu, 9 Oct 2003 20:16:49 -0400 (EDT) Cc: Postgresql Performance X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/313 X-Sequence-Number: 4061 scott.marlowe wrote: > I was testing to get some idea of how to speed up the speed of pgbench > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > /dev/hdx). > > The only parameter that seems to make a noticeable difference was setting > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > it jumped to the range of 45 to 52 tps. with write cache on I was getting > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > about 5 times slower, much better. > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > and see if the data gets corrupted with write caching turned on, i.e. do > my hard drives have the ability to write at least some of their cache > during spin down. Is this a reason we should switch to open_sync as a default, if it is availble, rather than fsync? I think we are doing a single write before fsync a lot more often than we are doing multiple writes before fsync. -- 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 Oct 9 21:19:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F0E0DD1B4F8 for ; Fri, 10 Oct 2003 00:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 71623-08 for ; Thu, 9 Oct 2003 21:18:30 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id F3551D1B50F for ; Thu, 9 Oct 2003 21:18:25 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9A0ITZ21975; Thu, 9 Oct 2003 20:18:29 -0400 (EDT) From: Bruce Momjian Message-Id: <200310100018.h9A0ITZ21975@candle.pha.pa.us> Subject: Re: further testing on IDE drives In-Reply-To: To: "scott.marlowe" Date: Thu, 9 Oct 2003 20:18:29 -0400 (EDT) Cc: Postgresql Performance X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/314 X-Sequence-Number: 4062 How did this drive come by default? Write-cache disabled? --------------------------------------------------------------------------- scott.marlowe wrote: > On Thu, 2 Oct 2003, scott.marlowe wrote: > > > I was testing to get some idea of how to speed up the speed of pgbench > > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > > /dev/hdx). > > > > The only parameter that seems to make a noticeable difference was setting > > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > > it jumped to the range of 45 to 52 tps. with write cache on I was getting > > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > > about 5 times slower, much better. > > > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > > and see if the data gets corrupted with write caching turned on, i.e. do > > my hard drives have the ability to write at least some of their cache > > during spin down. > > OK, back from testing. > > Information: Dual PIV system with a pair of 80 gig IDE drives, model > number: ST380023A (seagate). File system is ext3 and is on a seperate > drive from the OS. > > These drives DO NOT write cache when they lose power. Testing was done by > issuing a 'hdparm -W0/1 /dev/hdx' command where x is the real drive > letter, and 0 or 1 was chosen in place of 0/1. Then I'd issue a 'pgbench > -c 50 -t 100000000' command, wait for a few minutes, then pull the power > cord. > > I'm running RH linux 9.0 stock install, kernel: 2.4.20-8smp. > > Three times pulling the plug with 'hdparm -W0 /dev/hdx' resulted in a > machine that would boot up, recover with journal, and a database that came > up within about 30 seconds, with all the accounts still intact. > > Switching the caching back on with 'hdparm -W1 /dev/hdx' and doing the > same 'pgbench -c 50 -t 100000000' resulted in a corrupted database each > time. > > Also, I tried each of the following fsync methods: fsync, fdatasync, and > open_sync with write caching turned off. Each survived a power off test > with no corruption of the database. fsync and fdatasync result in 11 to > 17 tps with 'pgbench -c 5 -t 500' while open_sync resulted in 45 to 55 > tps, as mentioned in the previous post. > > I'd be interested in hearing from other folks which sync method works > for them and whether or not there are any IDE drives out there that can > write their cache to the platters on power off when caching is enabled. > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- 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-advocacy-owner@postgresql.org Thu Oct 9 21:32:56 2003 X-Original-To: pgsql-advocacy-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 88910D1B549 for ; Fri, 10 Oct 2003 00:32:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 73978-04 for ; Thu, 9 Oct 2003 21:32:04 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4CBB4D1B4E9 for ; Thu, 9 Oct 2003 21:32:01 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3747730; Thu, 09 Oct 2003 17:32:40 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Joshua D. Drake" , Robert Treat Subject: Re: [PERFORM] OFFTOPIC: PostgreSQL vs MySQL Date: Thu, 9 Oct 2003 17:29:59 -0700 User-Agent: KMail/1.4.3 Cc: nickf@ontko.com, pgsql-advocacy@postgresql.org References: <1065726365.1944.2398.camel@camel> <3F85B740.2020707@commandprompt.com> In-Reply-To: <3F85B740.2020707@commandprompt.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310091729.59304.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/65 X-Sequence-Number: 2353 Josh, The plan is to re-design techdocs based on Bricolage, allowing writers to= =20 contribute easier. However, we got as far as installing Bric on David=20 Fetter's test server, and haven't worked on setting up templates yet. Too many things. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 9 21:45:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A80D1D1B4F6 for ; Fri, 10 Oct 2003 00:45:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 75542-05 for ; Thu, 9 Oct 2003 21:45:02 -0300 (ADT) Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net [66.117.144.213]) by svr1.postgresql.org (Postfix) with ESMTP id 987BFD1B4F9 for ; Thu, 9 Oct 2003 21:44:58 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id 271CAACC3 for ; Fri, 10 Oct 2003 00:44:47 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9A0ik15016984 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 17:44:46 -0700 (PDT) (envelope-from dror) Date: Thu, 9 Oct 2003 17:44:46 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031010004446.GN2979@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ekxm9fjf.fsf@stark.dyndns.tv> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/315 X-Sequence-Number: 4063 On Thu, Oct 09, 2003 at 07:07:00PM -0400, Greg Stark wrote: > Dror Matalon writes: > > > Actually what finally sovled the problem is repeating the > > dtstamp > last_viewed > > in the sub select > > That will at least convince the optimizer to use an index range lookup. But it > still will have to scan every record that matches channel==$1, link==$2, and > dtstamp>$3. > > The trick of using limit 1 will be faster still as it only has to retrieve a > single record using the index. But you have to be sure to convince it to use How is doing order by limit 1 faster than doing max()? Seems like the optimizer will need to sort or scan the data set either way. That part didn't actually make a difference in my specific case. > the index and the way to do that is to list exactly the same columns in the > ORDER BY as are in the index definition. > > Even if some of the leading columns are redundant because they'll be constant > for all of the records retrieved. The optimizer doesn't know to ignore those. The main problem in my case was that the optimizer was doing the max() on all 700 rows, rather than the filtered rows. It's not until I put the "dtstamp> last_viewed" in the sub select as well as in the main query that it realized that it can first filter the 696 rows out and then to the max() on the 4 rows that satisfied this constraint. That was the big saving. Hope this all makes sense, Dror > > > > (This is the thing i pointed out previously in > > > <87el6ckrlu.fsf@stark.dyndns.tv> on Feb 13th 2003 on pgsql-general) > > -- > greg > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Thu Oct 9 22:28:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2F70AD1B4F0 for ; Fri, 10 Oct 2003 01:28:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83329-06 for ; Thu, 9 Oct 2003 22:27:50 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id E3A72D1B4EE for ; Thu, 9 Oct 2003 22:27:45 -0300 (ADT) Received: (qmail 18716 invoked by uid 500); 10 Oct 2003 01:35:22 -0000 Date: Thu, 9 Oct 2003 20:35:22 -0500 From: Bruno Wolff III To: Dror Matalon Cc: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031010013522.GB18596@wolff.to> Mail-Followup-To: Dror Matalon , Postgresql Performance References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031010004446.GN2979@rlx11.zapatec.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/316 X-Sequence-Number: 4064 On Thu, Oct 09, 2003 at 17:44:46 -0700, Dror Matalon wrote: > > How is doing order by limit 1 faster than doing max()? Seems like the > optimizer will need to sort or scan the data set either way. That part > didn't actually make a difference in my specific case. max() will never be evaluated by using an index to find the greatest value. So in many cases using order by and limit 1 is faster. From pgsql-performance-owner@postgresql.org Fri Oct 10 00:22:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EFD98D1B4FC for ; Fri, 10 Oct 2003 03:22:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00229-10 for ; Fri, 10 Oct 2003 00:21:39 -0300 (ADT) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id 3B303D1B509 for ; Fri, 10 Oct 2003 00:21:38 -0300 (ADT) Received: from zigo.dhs.org (zigo [127.0.0.1]) by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id h9A3LOpf026786; Fri, 10 Oct 2003 05:21:24 +0200 Received: from localhost (db@localhost) by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id h9A3LOOD026782; Fri, 10 Oct 2003 05:21:24 +0200 Date: Fri, 10 Oct 2003 05:21:24 +0200 (CEST) From: Dennis Bjorklund To: David Griffiths Cc: Josh Berkus , Subject: Re: OFFTOPIC: PostgreSQL vs MySQL In-Reply-To: <058f01c38ea3$aea70260$6501a8c0@griffiths2> 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: 200310/317 X-Sequence-Number: 4065 On Thu, 9 Oct 2003, David Griffiths wrote: > > > "PostgreSQL supports constraints. MySQL doesn't; programmers need to > > > take care of that from the client side" > > > Again, InnoDB supports constraints. > > > > Really? This is news. We did some tests on constraints on InnoDB, and > > found that while they parsed, they were not actually enforced. Was > > our test in error? > > You may have turned them off to load data? I've run into constraints > when my data-load script missed some rows in address_type. When it went > to do the address_list table, all rows that had the missing address_type > failed, as they should. I saw no weakness in the constraints. It sounds like you talk about foreign keys only, while the previous writer talkes about other constraints also. For example, in postgresql you can do: CREATE TABLE foo ( x int, CONSTRAINT bar CHECK (x > 5) ); and then # INSERT INTO foo VALUES (4); ERROR: ExecInsert: rejected due to CHECK constraint "bar" on "foo" I don't know MySQL, but I've got the impression from other posts on the lists that innodb supports foreign keys only. I might be wrong though. -- /Dennis From pgsql-performance-owner@postgresql.org Fri Oct 10 00:56:06 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9DBEED1B584; Fri, 10 Oct 2003 03:55:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13688-01; Fri, 10 Oct 2003 00:55:02 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 4374AD1B564; Fri, 10 Oct 2003 00:55:01 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id DA1071E7D; Thu, 9 Oct 2003 23:54:54 -0400 (EDT) Subject: Re: Sun performance - Major discovery! From: Neil Conway To: Bruce Momjian Cc: Tom Lane , Jeff , PostgreSQL Performance , PostgreSQL Hackers In-Reply-To: <200310090144.h991iQq24994@candle.pha.pa.us> References: <200310090144.h991iQq24994@candle.pha.pa.us> Content-Type: text/plain Message-Id: <1065758093.23683.420.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 09 Oct 2003 23:54:53 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/318 X-Sequence-Number: 4066 On Wed, 2003-10-08 at 21:44, Bruce Momjian wrote: > Agreed. Do we set them all to -O2, then remove it from the ones we > don't get successful reports on? I took the time to compile CVS tip with a few different machines from HP's TestDrive program, to see if there were any regressions using the new optimization flags: (1) (my usual dev machine) $ uname -a Linux tokyo 2.4.19-xfs #1 Mon Jan 20 19:12:29 EST 2003 i686 GNU/Linux $ gcc --version gcc (GCC) 3.3.2 20031005 (Debian prerelease) 'make check' passes (2) $ uname -a Linux spe161 2.4.18-smp #1 SMP Sat Apr 6 21:42:22 EST 2002 alpha unknown $ gcc --version gcc (GCC) 3.3.1 'make check' passes (3) $ uname -a Linux spe170 2.4.17-64 #1 Sat Mar 16 17:31:44 MST 2002 parisc64 unknown $ gcc --version 3.0.4 'make check' passes BTW, this platform doesn't have any code written for native spinlocks. (4) $ uname -a Linux spe156 2.4.18-mckinley-smp #1 SMP Thu Jul 11 12:51:02 MDT 2002 ia64 unknown $ gcc --version When you compile PostgreSQL without changing the CFLAGS configure picks, the initdb required for 'make check' fails with: [...] initializing pg_depend... ok creating system views... ok loading pg_description... ok creating conversions... ERROR: could not identify operator 679 I tried to compile PostgreSQL with CFLAGS='-O0' to see if the above resulted from an optimization-induced compiler error, but I got the following error: $ gcc -O0 -Wall -Wmissing-prototypes -Wmissing-declarations -I../../../../src/include -D_GNU_SOURCE -c -o xlog.o xlog.c ../../../../src/include/storage/s_lock.h: In function `tas': ../../../../src/include/storage/s_lock.h:125: error: inconsistent operand constraints in an `asm' Whereas this works fine: $ gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I../../../../src/include -D_GNU_SOURCE -c -o xlog.o xlog.c $ BTW, line 138 of s_lock.h is: #if defined(__arm__) || defined(__arm__) That seems a little redundant. Anyway, I tried running initdb after compiling all of pgsql with "-O0', except for the files that included s_lock.h, but make check still failed: creating information schema... ok vacuuming database template1... /house/neilc/pgsql/src/test/regress/./tmp_check/install//usr/local/pgsql/bin/initdb: line 882: 22035 Segmentation fault (core dumped) "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <; Fri, 10 Oct 2003 03:56:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 11613-09 for ; Fri, 10 Oct 2003 00:55:27 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 6EA94D1B509 for ; Fri, 10 Oct 2003 00:55:27 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id C375F5FAF for ; Fri, 10 Oct 2003 03:55:26 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9A3tQWX017289 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 20:55:26 -0700 (PDT) (envelope-from dror) Date: Thu, 9 Oct 2003 20:55:26 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031010035526.GT2979@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031010013522.GB18596@wolff.to> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/319 X-Sequence-Number: 4067 On Thu, Oct 09, 2003 at 08:35:22PM -0500, Bruno Wolff III wrote: > On Thu, Oct 09, 2003 at 17:44:46 -0700, > Dror Matalon wrote: > > > > How is doing order by limit 1 faster than doing max()? Seems like the > > optimizer will need to sort or scan the data set either way. That part > > didn't actually make a difference in my specific case. > > max() will never be evaluated by using an index to find the greatest value. > So in many cases using order by and limit 1 is faster. Ouch. I just double checked and you're right. Is this considered a bug, or just an implementation issue? While I've seen this hint a few times in the lists, it seems like it's one of those magic incantations that those in the know, know about, and that people new to postgres are going to be surprised by the need to use this idiom. Regards, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 10 01:03:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2667FD1B573; Fri, 10 Oct 2003 04:03:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 20633-01; Fri, 10 Oct 2003 01:02:35 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 63857D1B580; Fri, 10 Oct 2003 01:01:21 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9A419r20313; Fri, 10 Oct 2003 00:01:09 -0400 (EDT) From: Bruce Momjian Message-Id: <200310100401.h9A419r20313@candle.pha.pa.us> Subject: Re: Sun performance - Major discovery! In-Reply-To: <1065758093.23683.420.camel@tokyo> To: Neil Conway Date: Fri, 10 Oct 2003 00:01:09 -0400 (EDT) Cc: Tom Lane , Jeff , PostgreSQL Performance , PostgreSQL Hackers X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/320 X-Sequence-Number: 4068 Isn't it great how you have the same directory on every host so you can download once and run the same tests easily. Neil Conway wrote: > $ uname -a > Linux spe170 2.4.17-64 #1 Sat Mar 16 17:31:44 MST 2002 parisc64 unknown > $ gcc --version > 3.0.4 > > 'make check' passes I didn't know there was a pa-risc-64 chip. > BTW, this platform doesn't have any code written for native spinlocks. > > (4) > > $ uname -a > Linux spe156 2.4.18-mckinley-smp #1 SMP Thu Jul 11 12:51:02 MDT 2002 > ia64 unknown > $ gcc --version > > When you compile PostgreSQL without changing the CFLAGS configure picks, > the initdb required for 'make check' fails with: > > [...] > initializing pg_depend... ok > creating system views... ok > loading pg_description... ok > creating conversions... ERROR: could not identify operator 679 > > I tried to compile PostgreSQL with CFLAGS='-O0' to see if the above > resulted from an optimization-induced compiler error, but I got the > following error: > > $ gcc -O0 -Wall -Wmissing-prototypes -Wmissing-declarations > -I../../../../src/include -D_GNU_SOURCE -c -o xlog.o xlog.c > ../../../../src/include/storage/s_lock.h: In function `tas': > ../../../../src/include/storage/s_lock.h:125: error: inconsistent > operand constraints in an `asm' > > Whereas this works fine: > > $ gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations > -I../../../../src/include -D_GNU_SOURCE -c -o xlog.o xlog.c > $ > > BTW, line 138 of s_lock.h is: > > #if defined(__arm__) || defined(__arm__) Fix just committed. Thanks. > That seems a little redundant. > > Anyway, I tried running initdb after compiling all of pgsql with "-O0', > except for the files that included s_lock.h, but make check still > failed: > > creating information schema... ok > vacuuming database template1... > /house/neilc/pgsql/src/test/regress/./tmp_check/install//usr/local/pgsql/bin/initdb: line 882: 22035 Segmentation fault (core dumped) "$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null < ANALYZE; > VACUUM FULL FREEZE; > EOF > > The core file seems to indicate a stack overflow due to an infinitely > recursive function: > > (gdb) bt 25 > #0 0x4000000000645dc0 in hash_search () > #1 0x4000000000616930 in RelationSysNameCacheGetRelation () > #2 0x4000000000616db0 in RelationSysNameGetRelation () > #3 0x4000000000082e40 in relation_openr () > #4 0x4000000000083910 in heap_openr () > #5 0x400000000060e6b0 in ScanPgRelation () > #6 0x4000000000611d60 in RelationBuildDesc () > #7 0x4000000000616e70 in RelationSysNameGetRelation () > #8 0x4000000000082e40 in relation_openr () > #9 0x4000000000083910 in heap_openr () > #10 0x400000000060e6b0 in ScanPgRelation () > #11 0x4000000000611d60 in RelationBuildDesc () > #12 0x4000000000616e70 in RelationSysNameGetRelation () > #13 0x4000000000082e40 in relation_openr () > #14 0x4000000000083910 in heap_openr () > #15 0x400000000060e6b0 in ScanPgRelation () > #16 0x4000000000611d60 in RelationBuildDesc () > #17 0x4000000000616e70 in RelationSysNameGetRelation () > #18 0x4000000000082e40 in relation_openr () > #19 0x4000000000083910 in heap_openr () > #20 0x400000000060e6b0 in ScanPgRelation () > #21 0x4000000000611d60 in RelationBuildDesc () > #22 0x4000000000616e70 in RelationSysNameGetRelation () > #23 0x4000000000082e40 in relation_openr () > #24 0x4000000000083910 in heap_openr () > (More stack frames follow...) > > (It also dumps core in the same place during initdb if CFLAGS='-O' is > specified.) > > So it looks like the Itanium port is a little broken. Does anyone have > an idea what needs to be done to fix it? My guess is that the compiler itself is broken --- what else could it be? -- 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 Fri Oct 10 01:50:21 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B006BD1B506 for ; Fri, 10 Oct 2003 04:50:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22647-10 for ; Fri, 10 Oct 2003 01:49:35 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 4A782D1B545 for ; Fri, 10 Oct 2003 01:49:34 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id C3F8536983; Fri, 10 Oct 2003 00:49:27 -0400 (EDT) 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 1A7pDT-0005Xi-00; Fri, 10 Oct 2003 00:49:27 -0400 To: Dror Matalon Cc: Postgresql Performance Subject: Re: Speeding up Aggregates References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.com> In-Reply-To: <20031010035526.GT2979@rlx11.zapatec.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 Oct 2003 00:49:27 -0400 Message-ID: <874qyh8zoo.fsf@stark.dyndns.tv> Lines: 28 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: 200310/321 X-Sequence-Number: 4069 Dror Matalon writes: > Ouch. I just double checked and you're right. Is this considered a bug, > or just an implementation issue? Call it a wishlist bug. The problem is it would be a hard feature to implement properly. And none of the people paid to work on postgres by various companies seem to have this on their to-do lists. So don't expect it in the near future. > While I've seen this hint a few times in the lists, it seems like it's > one of those magic incantations that those in the know, know about, and > that people new to postgres are going to be surprised by the need to use > this idiom. Yup. Though it's in the FAQ and comes up on the mailing list about once a week or so, so it's hard to see how to document it any better. Perhaps a warning specifically on the min/max functions in the documentation? Say, what do people think about a comment board thing like php.net has attached to the documentation. People can add comments that show up directly on the bottom of the documentation for each function. I find it's mostly full of junk but skimming the comments often turns up one or two relevant warnings, especially when I'm wondering why something's not behaving the way I expect. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 10 02:31:56 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E0211D1B545 for ; Fri, 10 Oct 2003 05:31:54 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33343-01 for ; Fri, 10 Oct 2003 02:31:06 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 670D7D1B566 for ; Fri, 10 Oct 2003 02:30:49 -0300 (ADT) 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 h9A5UhhI058170; Fri, 10 Oct 2003 13:30:44 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3F8644EA.6000008@familyhealth.com.au> Date: Fri, 10 Oct 2003 13:34:34 +0800 From: Christopher Kings-Lynne 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: Greg Stark Cc: Dror Matalon , Postgresql Performance Subject: Re: Speeding up Aggregates References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.com> <874qyh8zoo.fsf@stark.dyndns.tv> In-Reply-To: <874qyh8zoo.fsf@stark.dyndns.tv> 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: 200310/322 X-Sequence-Number: 4070 > Say, what do people think about a comment board thing like php.net has > attached to the documentation. People can add comments that show up directly > on the bottom of the documentation for each function. I find it's mostly full > of junk but skimming the comments often turns up one or two relevant warnings, > especially when I'm wondering why something's not behaving the way I expect. I thought we had that: http://www.postgresql.org/docs/7.3/interactive/functions-aggregate.html ...and someone has already made the comment. Chris From pgsql-performance-owner@postgresql.org Fri Oct 10 04:17:25 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E6F8ED1B55E for ; Fri, 10 Oct 2003 07:17:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52462-04 for ; Fri, 10 Oct 2003 04:16:35 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id B44C1D1B54E for ; Fri, 10 Oct 2003 04:16:25 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h9A7Fm4r036103; Fri, 10 Oct 2003 10:15:48 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h9A7Fld0036099; Fri, 10 Oct 2003 10:15:48 +0300 (EEST) (envelope-from ant@imt.com.ua) Date: Fri, 10 Oct 2003 10:15:47 +0300 (EEST) From: Andriy Tkachuk To: Gaetano Mendola Cc: "pgsql-performance@postgresql.org" Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql In-Reply-To: <3F858FCE.3040907@bigfoot.com> Message-ID: <20031010101408.G35607-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/323 X-Sequence-Number: 4071 On Thu, 9 Oct 2003, Gaetano Mendola wrote: > Andriy Tkachuk wrote: > > On Wed, 8 Oct 2003, Tom Lane wrote: > > > > > >>Andriy Tkachuk writes: > >> > >>>At second. calc_total() is immutable function: > >>>but it seems that it's not cached in one session: > >> > >>It's not supposed to be. > > > > > > but it's written id doc: > > > > IMMUTABLE indicates that the function always returns the same > > result when given the same argument values; that is, it does not > > do database lookups or otherwise use information not directly > > present in its parameter list. If this option is given, any call > > of the function with all-constant arguments can be immediately > > replaced with the function value. > > The doc say "can be" not must and will be. ok, but on what it depends on? thanks, andriy http://www.imt.com.ua From pgsql-performance-owner@postgresql.org Fri Oct 10 04:44:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C6371D1B56D for ; Fri, 10 Oct 2003 07:44:05 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52508-08 for ; Fri, 10 Oct 2003 04:43:17 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id A3326D1B558 for ; Fri, 10 Oct 2003 04:43:13 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9A7mWLZ028200 for ; Fri, 10 Oct 2003 13:18:32 +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 h9A7mTwc028160; Fri, 10 Oct 2003 13:18:30 +0530 Message-ID: <3F86630D.6020801@persistent.co.in> Date: Fri, 10 Oct 2003 13:13:09 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Griffiths Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: OFFTOPIC: PostgreSQL vs MySQL References: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> <200310091059.03308.josh@agliodbs.com> <058f01c38ea3$aea70260$6501a8c0@griffiths2> In-Reply-To: <058f01c38ea3$aea70260$6501a8c0@griffiths2> 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: 200310/324 X-Sequence-Number: 4072 David Griffiths wrote: >>Have you checked these pages? They've been posted on this list numerous >>times: >>http://techdocs.postgresql.org >>http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html >>http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > Those are much more instructive; I'm curious - why aren't then in the > administrator's > section of the docs? Because they are much more recent. Not even 6 months old. And lot of people differ on how exactly these tips applies. What goes in postgresql documentation is fact and nothing but facts. Clearly such tips do not have any place in postgresql documentation(At least in my opinion) A pointer might get added to postgresql documentation. That's about it at the most. Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 10 05:52:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 85E55D1B54D for ; Fri, 10 Oct 2003 08:52:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62759-08 for ; Fri, 10 Oct 2003 05:51:44 -0300 (ADT) Received: from smtp.blueyonder.co.uk (82-34-96-210.cable.ubr06.gill.blueyonder.co.uk [82.34.96.210]) by svr1.postgresql.org (Postfix) with ESMTP id 54B20D1B4E5 for ; Fri, 10 Oct 2003 05:51:42 -0300 (ADT) Received: from reddragon.localdomain ([127.0.0.1] helo=localhost) by smtp.blueyonder.co.uk with esmtp (Exim 4.10) id 1A7szv-0001Vp-00; Fri, 10 Oct 2003 09:51:43 +0100 Date: Fri, 10 Oct 2003 09:51:43 +0100 (BST) From: Peter Childs X-X-Sender: peter@RedDragon.Childs To: Dror Matalon Cc: Postgresql Performance Subject: Re: Speeding up Aggregates In-Reply-To: <20031010004446.GN2979@rlx11.zapatec.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: 200310/325 X-Sequence-Number: 4073 On Thu, 9 Oct 2003, Dror Matalon wrote: > On Thu, Oct 09, 2003 at 07:07:00PM -0400, Greg Stark wrote: > > Dror Matalon writes: > > > > > Actually what finally sovled the problem is repeating the > > > dtstamp > last_viewed > > > in the sub select > > > > That will at least convince the optimizer to use an index range lookup. But it > > still will have to scan every record that matches channel==$1, link==$2, and > > dtstamp>$3. > > > > The trick of using limit 1 will be faster still as it only has to retrieve a > > single record using the index. But you have to be sure to convince it to use > > How is doing order by limit 1 faster than doing max()? Seems like the > optimizer will need to sort or scan the data set either way. That part > didn't actually make a difference in my specific case. > max(field) = sequential scan looking for the hightest. order by field desc limit 1 = index scan (if available), read first record. else (if no index) sequential scan for highest. aggregates don't use indexes because its only appilicable for max() and min() and can't be done for sum(), count(), etc writing an alogorithim to use the index would be complex as you would need to tell the optimized from the inside a function (you can write aggrate functions your self if you wish) to do somthing slighly differently. for my large table.... select max(field) from table; (5264.21 msec) select field from table order by field limit 1; (54.88 msec) Peter Childs From pgsql-performance-owner@postgresql.org Fri Oct 10 06:42:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2676CD1B517 for ; Fri, 10 Oct 2003 09:42:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 65534-08 for ; Fri, 10 Oct 2003 06:41:40 -0300 (ADT) Received: from ensim.wwd-hosting.net (ensim.wwd-hosting.net [207.44.132.72]) by svr1.postgresql.org (Postfix) with ESMTP id 96319D1B50B for ; Fri, 10 Oct 2003 06:41:37 -0300 (ADT) Received: from picklematrix.net ([0.0.0.0]) (authenticated (0 bits)) by ensim.wwd-hosting.net (8.11.6/8.11.6) with ESMTP id h9A9fcs20564 for ; Fri, 10 Oct 2003 05:41:39 -0400 Date: Thu, 9 Oct 2003 23:41:36 -1000 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: way to speed up a SELECT DISTINCT? From: Seth Ladd To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/326 X-Sequence-Number: 4074 Hello, I am running 7.3.2 RPMs on RH9, on a celeron 1.7 w/ 1gig ram. I have a table that has 6.9 million rows, 2 columns, and an index on each column. When I run: SELECT DISTINCT column1 FROM table It is very, very slow (10-15 min to complete). An EXPLAIN shows no indexes are being used. Is there any way to speed this up, or is that DISTINCT going to keep hounding me? I checked the mailing list, and didn't see anything like this. Any tips or hints would be greatly appreciated. Thanks for your help! Seth From pgsql-performance-owner@postgresql.org Fri Oct 10 07:07:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8E29AD1B51B for ; Fri, 10 Oct 2003 10:07:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74581-01 for ; Fri, 10 Oct 2003 07:07:25 -0300 (ADT) Received: from smtp.blueyonder.co.uk (82-34-96-210.cable.ubr06.gill.blueyonder.co.uk [82.34.96.210]) by svr1.postgresql.org (Postfix) with ESMTP id 38297D1B4FD for ; Fri, 10 Oct 2003 07:07:22 -0300 (ADT) Received: from reddragon.localdomain ([127.0.0.1] helo=localhost) by smtp.blueyonder.co.uk with esmtp (Exim 4.10) id 1A7uB9-0001am-00; Fri, 10 Oct 2003 11:07:23 +0100 Date: Fri, 10 Oct 2003 11:07:23 +0100 (BST) From: Peter Childs X-X-Sender: peter@RedDragon.Childs To: Seth Ladd Cc: pgsql-performance@postgresql.org Subject: Re: way to speed up a SELECT DISTINCT? In-Reply-To: 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: 200310/327 X-Sequence-Number: 4075 On Thu, 9 Oct 2003, Seth Ladd wrote: > Hello, > > I am running 7.3.2 RPMs on RH9, on a celeron 1.7 w/ 1gig ram. > > I have a table that has 6.9 million rows, 2 columns, and an index on > each column. When I run: > > SELECT DISTINCT column1 FROM table > > It is very, very slow (10-15 min to complete). An EXPLAIN shows no > indexes are being used. > > Is there any way to speed this up, or is that DISTINCT going to keep > hounding me? > > I checked the mailing list, and didn't see anything like this. > > Any tips or hints would be greatly appreciated. Thanks for your help! > Seth > > Try group by instead. I think this is an old bug its fixed in 7.3.2 which I'm using. Peter Childs ` peter@bernardo:express=# explain select distinct region from region; QUERY PLAN ---------------------------------------------------------------------------------------------- Unique (cost=0.00..4326.95 rows=9518 width=14) -> Index Scan using regionview_region on region (cost=0.00..4089.00 rows=95183 width=14) (2 rows) peter@bernardo:express=# explain select distinct region from region group by region; QUERY PLAN ---------------------------------------------------------------------------------------------------- Unique (cost=0.00..4350.75 rows=952 width=14) -> Group (cost=0.00..4326.95 rows=9518 width=14) -> Index Scan using regionview_region on region (cost=0.00..4089.00 rows=95183 width=14) (3 rows) From pgsql-performance-owner@postgresql.org Fri Oct 10 07:51:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A703FD1B525 for ; Fri, 10 Oct 2003 10:51:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 81297-07 for ; Fri, 10 Oct 2003 07:50:51 -0300 (ADT) Received: from ensim.wwd-hosting.net (ensim.wwd-hosting.net [207.44.132.72]) by svr1.postgresql.org (Postfix) with ESMTP id 87BB7D1B528 for ; Fri, 10 Oct 2003 07:50:48 -0300 (ADT) Received: from picklematrix.net ([0.0.0.0]) (authenticated (0 bits)) by ensim.wwd-hosting.net (8.11.6/8.11.6) with ESMTP id h9AAopO30990 for ; Fri, 10 Oct 2003 06:50:51 -0400 Date: Fri, 10 Oct 2003 00:50:48 -1000 Subject: Re: way to speed up a SELECT DISTINCT? Content-Type: text/plain; delsp=yes; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Seth Ladd To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <9BE142FC-FB0F-11D7-A8D2-000A9576D038@picklematrix.net> X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/328 X-Sequence-Number: 4076 >> Is there any way to speed this up, or is that DISTINCT going to keep >> hounding me? >> >> I checked the mailing list, and didn't see anything like this. >> >> Any tips or hints would be greatly appreciated. Thanks for your help! >> Seth >> >> > Try group by instead. I think this is an old bug its fixed in > 7.3.2 which I'm using. > > Peter Childs > ` > > > peter@bernardo:express=# explain select distinct region from region; > QUERY PLAN > ----------------------------------------------------------------------- > ----------------------- > Unique (cost=0.00..4326.95 rows=9518 width=14) > -> Index Scan using regionview_region on region > (cost=0.00..4089.00 > rows=95183 width=14) > (2 rows) Thanks for the tip, I'll give this a shot soon. I am curious, your example above does not use GROUP BY yet you have an INDEX SCAN. I am using a similar query, yet I get a full table scan. I wonder how they are different? I'll try the group by anyway. Thanks, Seth From pgsql-performance-owner@postgresql.org Fri Oct 10 08:01:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8741ED1B4E1 for ; Fri, 10 Oct 2003 11:01:21 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 74611-09 for ; Fri, 10 Oct 2003 08:00:38 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 9E098D1B522 for ; Fri, 10 Oct 2003 08:00:32 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9AB5s8U020203 for ; Fri, 10 Oct 2003 16:35:54 +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 h9AB5qwc020173; Fri, 10 Oct 2003 16:35:53 +0530 Message-ID: <3F86914E.2070100@persistent.co.in> Date: Fri, 10 Oct 2003 16:30:30 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Seth Ladd Cc: pgsql-performance@postgresql.org Subject: Re: way to speed up a SELECT DISTINCT? References: <9BE142FC-FB0F-11D7-A8D2-000A9576D038@picklematrix.net> In-Reply-To: <9BE142FC-FB0F-11D7-A8D2-000A9576D038@picklematrix.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: 200310/329 X-Sequence-Number: 4077 Seth Ladd wrote: >> peter@bernardo:express=# explain select distinct region from region; >> QUERY PLAN >> ----------------------------------------------------------------------- >> ----------------------- >> Unique (cost=0.00..4326.95 rows=9518 width=14) >> -> Index Scan using regionview_region on region (cost=0.00..4089.00 >> rows=95183 width=14) >> (2 rows) > > > Thanks for the tip, I'll give this a shot soon. I am curious, your > example above does not use GROUP BY yet you have an INDEX SCAN. I am > using a similar query, yet I get a full table scan. I wonder how they > are different? Have you tuned your shared buffers and effective cache correctly? Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 10 08:06:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C4417D1B4E1 for ; Fri, 10 Oct 2003 11:06:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82899-05 for ; Fri, 10 Oct 2003 08:05:35 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id A4EBFD1B528 for ; Fri, 10 Oct 2003 08:05:31 -0300 (ADT) Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id h9AB5RhI061025; Fri, 10 Oct 2003 19:05:27 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from localhost (chriskl@localhost) by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id h9AB5R15061022; Fri, 10 Oct 2003 19:05:27 +0800 (WST) X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process doing -bs Date: Fri, 10 Oct 2003 19:05:27 +0800 (WST) From: Christopher Kings-Lynne To: Seth Ladd Cc: pgsql-performance@postgresql.org Subject: Re: way to speed up a SELECT DISTINCT? In-Reply-To: <9BE142FC-FB0F-11D7-A8D2-000A9576D038@picklematrix.net> Message-ID: <20031010190403.E61002-100000@houston.familyhealth.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/330 X-Sequence-Number: 4078 > Thanks for the tip, I'll give this a shot soon. I am curious, your > example above does not use GROUP BY yet you have an INDEX SCAN. I am > using a similar query, yet I get a full table scan. I wonder how they > are different? Please send us the results of EXPLAIN ANALYZE the query. The EXPLAIN results usually aren't too interesting for degenerate queries. Also, make sure you have run ANALYZE on your database. Chris From pgsql-performance-owner@postgresql.org Fri Oct 10 08:17:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CB36FD1B522 for ; Fri, 10 Oct 2003 11:17:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 90219-05 for ; Fri, 10 Oct 2003 08:17:10 -0300 (ADT) Received: from smtp.blueyonder.co.uk (82-34-96-210.cable.ubr06.gill.blueyonder.co.uk [82.34.96.210]) by svr1.postgresql.org (Postfix) with ESMTP id 86243D1B4E1 for ; Fri, 10 Oct 2003 08:17:07 -0300 (ADT) Received: from reddragon.localdomain ([127.0.0.1] helo=localhost) by smtp.blueyonder.co.uk with esmtp (Exim 4.10) id 1A7vGg-0001gU-00; Fri, 10 Oct 2003 12:17:10 +0100 Date: Fri, 10 Oct 2003 12:17:10 +0100 (BST) From: Peter Childs X-X-Sender: peter@RedDragon.Childs To: Seth Ladd Cc: pgsql-performance@postgresql.org Subject: Re: way to speed up a SELECT DISTINCT? In-Reply-To: <9BE142FC-FB0F-11D7-A8D2-000A9576D038@picklematrix.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: 200310/331 X-Sequence-Number: 4079 On Fri, 10 Oct 2003, Seth Ladd wrote: > >> Is there any way to speed this up, or is that DISTINCT going to keep > >> hounding me? > >> > >> I checked the mailing list, and didn't see anything like this. > >> > >> Any tips or hints would be greatly appreciated. Thanks for your help! > >> Seth > >> > >> > > Try group by instead. I think this is an old bug its fixed in > > 7.3.2 which I'm using. > > > > Peter Childs > > ` > > > > > > peter@bernardo:express=# explain select distinct region from region; > > QUERY PLAN > > ----------------------------------------------------------------------- > > ----------------------- > > Unique (cost=0.00..4326.95 rows=9518 width=14) > > -> Index Scan using regionview_region on region > > (cost=0.00..4089.00 > > rows=95183 width=14) > > (2 rows) > > Thanks for the tip, I'll give this a shot soon. I am curious, your > example above does not use GROUP BY yet you have an INDEX SCAN. I am > using a similar query, yet I get a full table scan. I wonder how they > are different? > > I'll try the group by anyway. > Its a guess but ANALYSE might help. ` Peter Childs From pgsql-performance-owner@postgresql.org Fri Oct 10 09:09:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 67C18D1B52E for ; Fri, 10 Oct 2003 12:09:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00438-03 for ; Fri, 10 Oct 2003 09:08:40 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 00E41D1B4E1 for ; Fri, 10 Oct 2003 09:08:32 -0300 (ADT) Received: (qmail 76448 invoked from network); 10 Oct 2003 12:08:37 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 10 Oct 2003 12:08:37 -0000 Date: Fri, 10 Oct 2003 08:08:37 -0400 (EDT) From: Jeff To: Greg Stark Cc: "pgsql-performance@postgresql.org" Subject: Re: backup/restore - another area. In-Reply-To: <878ynu9ed5.fsf@stark.dyndns.tv> 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: 200310/332 X-Sequence-Number: 4080 On 9 Oct 2003, Greg Stark wrote: > I don't quite follow your #2 so I can only comment on the above idea of using > an LVM snapshot. If you have the hardware and the LVM-fu to be able to do this > properly I would recommend it. > Just to be a bit clearer incase it was my wording: Method #2 is nearly identical to method #1, except that no logical volume manager is needed. We cannot just cp $PGDATA because it is (or could be) changing and we need to take data from a constitant point. So what we do is write code that understands xids and all that and simply "dumps" out the pages of data in a raw form that can be quickly reloaded. The key is that the data be in a somewhat consistant state. Method #2 requires a ton more work but it would be able to run on platforms without an lvm (or requiring the use of an lvm). Does that make more sense? The idea here is to backup & restore as fast as possible, throwing away some things like inter-version compat and whatnot. Being able to add "fast backup / restore" is a good thing in the list of enterprise features. > Also, I wouldn't consider this a replacement for having a pg_dump export. In a > crisis when you want to restore everything *exactly* the way things were you > want the complete filesystem snapshot. But if you just want to load a table > the way it was the day before to compare, or if you want to load a test box to > do some performance testing, or whatever, you'll need the logical export. > Yeah, a pg_dump now and then would be useful (and safe). If you wanted to get fancy schmancy you could take the snapshot, archive it, transfer it and unarchive it on machine B. (We actually used to do that here until machine B no longer had the capacity to hold all our data :) -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 10 09:28:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 474EED1B4F0 for ; Fri, 10 Oct 2003 12:28:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01919-03 for ; Fri, 10 Oct 2003 09:28:04 -0300 (ADT) Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) by svr1.postgresql.org (Postfix) with ESMTP id B90E4D1B4FC for ; Fri, 10 Oct 2003 09:28:00 -0300 (ADT) Received: from idigx.com ([208.207.88.122]) by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id h9ACRNC10698; Fri, 10 Oct 2003 07:27:23 -0500 Message-ID: <3F86A5AA.6060705@idigx.com> Date: Fri, 10 Oct 2003 07:27:22 -0500 From: Thomas Swan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030924 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jason Hihn Cc: Greg Spiegelberg , PgSQL Performance ML Subject: Re: Compare rows References: In-Reply-To: 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: 200310/333 X-Sequence-Number: 4081 I took this approach with a former company in designing an dynamic e-commerce system. This kept the addition of new products from requiring an alteration of the schema. With an ORB manager and cache control the performance was not significantly, but the automatic extensibility and the ease of maintainabilty was greatly enhanced. Thomas Jason Hihn wrote: > > >>-----Original Message----- >>From: pgsql-performance-owner@postgresql.org >>[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Greg >>Spiegelberg >>Sent: Wednesday, October 08, 2003 3:11 PM >>To: PgSQL Performance ML >>Subject: Re: [PERFORM] Compare rows >> >> >>Josh Berkus wrote: >> >> >>>Greg, >>> >>> >>> >>> >>>>The data represents metrics at a point in time on a system for >>>>network, disk, memory, bus, controller, and so-on. Rx, Tx, errors, >>>>speed, and whatever else can be gathered. >>>> >>>>We arrived at this one 642 column table after testing the whole >>>>process from data gathering, methods of temporarily storing then >>>>loading to the database. Initially, 37+ tables were in use but >>>>the one big-un has saved us over 3.4 minutes. >>>> >>>> >>>Hmmm ... if few of those columns are NULL, then you are >>> >>> >>probably right ... >> >> >>>this is probably the most normalized design. If, however, >>> >>> >>many of columns >> >> >>>are NULL the majority of the time, then the design you should >>> >>> >>be using is a >> >> >>>vertial child table, of the form ( value_type | value ). >>> >>>Such a vertical child table would also make your comparison >>> >>> >>between instances >> >> >>>*much* easier, as it could be executed via a simple >>> >>> >>4-table-outer-join and 3 >> >> >>>where clauses. So even if you don't have a lot of NULLs, you >>> >>> >>probably want >> >> >>>to consider this. >>> >>> >>You lost me on that one. What's a "vertical child table"? >> >> > >Parent table Fkey | Option | Value >------------------+--------+------- > | OS | Solaris > | DISK1 | 30g > ^^^^^^^^ ^^^-- values > fields are values in a column rather than 'fields' > > > > >>Statistically, about 6% of the rows use more than 200 of the columns, >>27% of the rows use 80-199 or more columns, 45% of the rows use 40-79 >>columns and the remaining 22% of the rows use 39 or less of the columns. >>That is a lot of NULLS. Never gave that much thought. >> >>To ensure query efficiency, hide the NULLs and simulate the multiple >>tables I have a boatload of indexes, ensure that every query makees use >>of an index, and have created 37 views. It's worked pretty well so >>far >> >> >> >> >>>>The reason for my initial question was this. We save changes only. >>>>In other words, if system S has row T1 for day D1 and if on day D2 >>>>we have another row T1 (excluding our time column) we don't want >>>>to save it. >>>> >>>> >>>If re-designing the table per the above is not a possibility, >>> >>> >>then I'd suggest >> >> >>>that you locate 3-5 columns that: >>>1) are not NULL for any row; >>>2) combined, serve to identify a tiny subset of rows, i.e. 3% >>> >>> >>or less of the >> >> >>>table. >>> >>> >>There are always, always, always 7 columns that contain data. >> >> >> >> >>>Then put a multi-column index on those columns, and do your >>> >>> >>comparison. >> >> >>>Hopefully the planner should pick up on the availablity of the >>> >>> >>index and scan >> >> >>>only the rows retrieved by the index. However, there is the distinct >>>possibility that the presence of 637 WHERE criteria will >>> >>> >>confuse the planner, >> >> >>>causing it to resort to a full table seq scan; in that case, >>> >>> >>you will want to >> >> >>>use a subselect to force the issue. >>> >>> >>That's what I'm trying to avoid is a big WHERE (c1,c2,...,c637) <> >>(d1,d2,...,d637) clause. Ugly. >> >> >> >> >>>Or, as Joe Conway suggested, you could figure out some kind of >>> >>> >>value hash that >> >> >>>uniquely identifies your rows. >>> >>> >>I've given that some though and though appealing I don't think I'd care >>to spend the CPU cycles to do it. Best way I can figure to accomplish >>it would be to generate an MD5 on each row without the timestamp and >>store it in another column, create an index on the MD5 column, generate >>MD5 on each line I want to insert. Makes for a simple WHERE... >> >>Okay. I'll give it a whirl. What's one more column, right? >> >>Greg >> >>-- >>Greg Spiegelberg >> Sr. Product Development Engineer >> Cranel, Incorporated. >> Phone: 614.318.4314 >> Fax: 614.431.8388 >> Email: gspiegelberg@Cranel.com >>Cranel. Technology. Integrity. Focus. >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> >> >> > >---------------------------(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 Oct 10 09:36:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2E4A1D1B55E for ; Fri, 10 Oct 2003 12:36:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 00420-10 for ; Fri, 10 Oct 2003 09:35:57 -0300 (ADT) Received: from easily.co.uk (unknown [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 1ACF4D1B4F2 for ; Fri, 10 Oct 2003 09:35:53 -0300 (ADT) Received: from [213.152.63.90] (HELO webbased10) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with SMTP id 30137810 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 13:35:54 +0100 Message-ID: <007901c38f2b$0b585590$2802a8c0@webbased10> From: "Nick Barr" To: Subject: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 13:35:53 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0076_01C38F33.6CF81E90" 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=BAYES_30, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/334 X-Sequence-Number: 4082 This is a multi-part message in MIME format. ------=_NextPart_000_0076_01C38F33.6CF81E90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Heya Guys n Gals, Having been following the thread on "go for a script! / ex: PostgreSQL vs. MySQL". I thought I would throw something together in Perl. My current issue is that I only have access to a RH Linux box and so cannot make it cross-platform on my own :-(. Anyhow please find it attached. It runs fine on my box, it doesnt actually write to postgresql.conf because I didnt want to mess it up, it does however write to postgresql.conf.new for the moment. The diffs seem to be writing correctly. There are a set of parameters at the top which may need to get tweaked for your platform. I can also carry on posting to this list new versions if people want. Clearly this lot is open source, so please feel free to play with it and post patches/new features back either to the list or my email directly. In case you cant see my email address, it is nicky at the domain below. I will also post it on me website and as I develop it further new versions will appear there http://www.chuckie.co.uk/postgresql/pg_autoconfig.pl Is this a useful start? Nick ------=_NextPart_000_0076_01C38F33.6CF81E90 Content-Type: application/octet-stream; name="pg_autoconfig.pl" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pg_autoconfig.pl" #!/usr/bin/perl # Copyright (c) 2003 Nicholas Barr # # This is free software. There is NO warranty; not even for MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. use strict; my %settings =3D (); $settings{"path_uname"} =3D "/bin/uname"; $settings{"path_uptime"} =3D "/usr/bin/uptie"; $settings{"path_pgsql"} =3D "/var/lib/pgsql"; $settings{"pgsql_pagesize_kbytes"} =3D 8; $settings{"pgsql_pagesize_bytes"} =3D $settings{"pgsql_pagesize_kbytes"} * = 1024; ###################### # RECOMMENDED RATIOS # ###################### # ratio_shared_buffer # # The ratio of shared buffers compared to total memory # Range : 0 - 1 $settings{"ratio_shared_buffer"} =3D 0.0625; # i.e. 1/16th of total memory # ratio_effective_cache_size # # The ratio of the effective cache size comapared to # kernel cache size. This should be done on a box that # has been up quite a while # Range : 0 - 1 $settings{"ratio_effective_cache_size"} =3D 0.8; # Initialise the operating system parameters my $os_type =3D ""; # Type of operating system (i.e. Linux/Solaris etc.) my $os_vers =3D ""; # Version of the kernel if we actually care? # Iniitialise the various memory parameters my $mem_total =3D 0; my $mem_used =3D 0; my $mem_free =3D 0; my $mem_shared =3D 0; my $mem_buffers =3D 0; my $mem_cached =3D 0; # Initialise the various shared memory parameters my $shm_max =3D 0; my $uptime =3D 0; print "PostgreSQL Autoconfigurer Thingy\n"; print "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n\n"; ($os_type, $os_vers) =3D getOperatingSystem(); ($mem_total, $mem_used, $mem_free, $mem_shared, $mem_buffers, $mem_cached) = =3D getMemory(); ($shm_max) =3D getShmMax(); ($uptime) =3D getUptime(); my $mem_kcache =3D int ($mem_buffers + $mem_cached); my $pgsql_rec_shrdbuf =3D int (($mem_total * $settings{"ratio_shared_buff= er"}) / $settings{"pgsql_pagesize_bytes"}); my $pgsql_max_shrdbuf =3D int ($shm_max / $settings{"pgsql_pagesize_bytes= "}); my $pgsql_shrdbuf; my $pgsql_max_effective =3D int ($mem_kcache / $settings{"pgsql_pagesize_by= tes"}); my $pgsql_rec_effective =3D int ($pgsql_max_effective * $settings{"ratio_ef= fective_cache_size"}); my $pgsql_effective; print "O/S : " . $os_type . ", Kernel : " . $os_vers . "\n"; print "Uptime : " . formatTime($uptime) . "\n"; print "Total memory : " . formatSize($mem_total) . ", Max shared memory : "= . formatSize($shm_max) . "\n"; print " RECOMMEND : shared_buffers =3D " . $pgsql_rec_shrdbuf . "\n"; print " MAX : shared_buffers =3D " . $pgsql_max_shrdbuf . "\n"; $pgsql_shrdbuf =3D $pgsql_rec_shrdbuf; if ($pgsql_rec_shrdbuf > $pgsql_max_shrdbuf) { print " Recomended value exceeds maximum. Will use max for now. You will = need to tweak your shmmax parameter if you wish to increase this.\n"; $pgsql_shrdbuf =3D $pgsql_max_shrdbuf; } print "Kernel cache : " . formatSize($mem_kcache) . "\n"; print " RECOMMEND : effective_cache_size =3D " . $pgsql_rec_effective . "\= n"; print " MAX : effective_cache_size =3D " . $pgsql_max_effective . "\= n"; $pgsql_effective =3D $pgsql_rec_effective; print "Looking for postgresql.conf.\n"; $settings{"path_pgsql_full"} =3D $settings{"path_pgsql"} . "/data/postgresq= l.conf"; if (-e $settings{"path_pgsql_full"}) { print " Found in " . $settings{"path_pgsql_full"} . ".\n"; my $curr_shared_buffers =3D 0; my $curr_effective_cache_size =3D 0; open (READ,"<" . $settings{"path_pgsql_full"}); while() { if (/^\#*shared_buffers\s*=3D\s*([0-9]+)/) { $curr_shared_buffers =3D $1; } if (/^\#*effective_cache_size\s*=3D\s*([0-9]+)/) { $curr_effective_cache_size =3D $1; } } close(READ); print " shared_buffers =3D " . $curr_shared_buffers; if ($curr_shared_buffers !=3D $pgsql_shrdbuf) { print " *"; } print "\n"; print " effective_cache_size =3D " . $curr_effective_cache_size; if ($curr_effective_cache_size !=3D $pgsql_effective) { print " *"; } print "\n"; print "Do you wish to change these settings (y or n) ? "; my $line =3D ; =09 $line =3D trim($line); if (($line eq "y") || ($line eq "Y")) { open(READ, "<" . $settings{"path_pgsql_full"}); open(WRITE, ">" . $settings{"path_pgsql_full"} . "\.new"); while() { if (/^\#*shared_buffers\s*=3D\s*([0-9]+)/) { print WRITE "shared_buffers =3D " . $pgsql_shrdbuf . "\n"; } elsif (/^\#*effective_cache_size\s*=3D\s*([0-9]+)/) { print WRITE "effective_cache_size =3D " . $pgsql_effective . "\n"; } else { print WRITE $_; } } close (WRITE); close (READ); } } sub getOperatingSystem { my $os_type =3D ""; my $os_vers =3D 0; open (READOS, $settings{"path_uname"} . " -s |"); $os_type =3D trim(); close(READOS); open (READOS, $settings{"path_uname"} . " -r |"); $os_vers =3D trim(); close(READOS); return ($os_type, $os_vers); } sub getMemory { my $mem_total; my $mem_used; my $mem_free; my $mem_shared; my $mem_buffers; my $mem_cached; my @line_parts; if ($os_type eq "Linux") { open (READMEM, "/proc/meminfo"); while () { @line_parts =3D split(" "); if ($os_type eq "Linux") { if ($line_parts[0] eq "Mem:") { ($mem_total, $mem_used, $mem_free, $mem_shared, $mem_buffers, $mem_cac= hed) =3D=20 @line_parts[1..$#line_parts]; } } } close(READMEM); } return ($mem_total, $mem_used, $mem_free, $mem_shared, $mem_buffers, $mem_= cached); } sub getShmMax { my $shm_max =3D 0; if ($os_type eq "Linux") { open (READOS, "/proc/sys/kernel/shmmax"); $shm_max =3D trim(); close(READOS); } return $shm_max; } sub getUptime { my $uptime =3D 0; if ($os_type eq "Linux") { open (READUP, "/proc/uptime"); ($uptime) =3D split(" ", ); close(READUP); } return $uptime; } sub formatSize { my $size =3D shift; my $newsize =3D $size; my $newtext =3D "bytes"; my $newprec =3D 0; my $onekay =3D 1024; if ( ($newsize / $onekay) >=3D 0.5) { $newprec =3D 2; $newsize /=3D $onekay; $newtext =3D "kB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "MB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "GB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "TB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "PB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "EB"; if ( ($newsize / $onekay) >=3D 0.5) { $newsize /=3D $onekay; $newtext =3D "ZB"; } } } } } } } return sprintf("%.".$newprec."f %s", $newsize, $newtext); } sub formatTime { my $time =3D shift; my $num; my $str; $num =3D $time; $str =3D "seconds"; return $num . " " . $str; } sub trim { my $string =3D shift; $string =3D~ s/^\s*(.*)/$1/ge; $string =3D~ s/(.*)\s*$/$1/ge; return $string; } ------=_NextPart_000_0076_01C38F33.6CF81E90-- From pgsql-performance-owner@postgresql.org Fri Oct 10 09:41:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 63515D1B4F0 for ; Fri, 10 Oct 2003 12:41:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04072-01 for ; Fri, 10 Oct 2003 09:40:14 -0300 (ADT) Received: from easily.co.uk (unknown [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 0CED6D1B4FC for ; Fri, 10 Oct 2003 09:40:11 -0300 (ADT) Received: from [213.152.63.90] (HELO webbased10) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with SMTP id 30138592 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 13:40:11 +0100 Message-ID: <008e01c38f2b$a4d87240$2802a8c0@webbased10> From: "Nick Barr" To: Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 13:40:10 +0100 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=ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/335 X-Sequence-Number: 4083 ----- Original Message ----- From: "Nick Barr" To: Sent: Friday, October 10, 2003 1:35 PM Subject: go for a script! / ex: PostgreSQL vs. MySQL > I will also post it on me website and as I develop it further new versions > will appear there > > http://www.chuckie.co.uk/postgresql/pg_autoconfig.pl Make that http://www.chuckie.co.uk/postgresql/pg_autoconfig.txt Nick From pgsql-performance-owner@postgresql.org Fri Oct 10 10:00:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 02472D1B53E for ; Fri, 10 Oct 2003 13:00:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05932-02 for ; Fri, 10 Oct 2003 09:59:52 -0300 (ADT) Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) by svr1.postgresql.org (Postfix) with ESMTP id 2FB43D1B4F0 for ; Fri, 10 Oct 2003 09:59:48 -0300 (ADT) Received: from idigx.com ([208.207.88.122]) by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id h9ACxoC14064; Fri, 10 Oct 2003 07:59:50 -0500 Message-ID: <3F86AD45.3000903@idigx.com> Date: Fri, 10 Oct 2003 07:59:49 -0500 From: Thomas Swan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030924 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL vs MySQL References: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> In-Reply-To: <03d201c38e8a$ff1b5c00$6501a8c0@griffiths2> 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: 200310/336 X-Sequence-Number: 4084 David Griffiths wrote: > This is a timely thread for myself, as I'm in the middle of testing > both databases as an Oracle replacement. > > As of this moment, I know more about MySQL (tuning, setup, features) > than I do about Postgres. Not because I like MySQL more, but because > > 1) the MySQL docs are better (sorry - I found them easier to read, and > more comprehensive; I had an easier time finding the answers I needed) > 2) there are more web pages devoted to MySQL (probably because it has > a bit more market share) > 3) there are more books on MySQL at the bookstore (I haven't had a > chance to pick up Bruce's book yet; it might be all the book I'd ever > need) > 4) we looked at MySQL first (we needed replication, and eRServer had > not been open-sourced when we started looking) > > With regards to #1, I'd like to specifically mention tuning - the docs > at http://www.postgresql.org/docs/7.3/static/runtime-config.html give > a basic explanation of the different options, but much more is needed > for tuning. I'm running into a problem with an update statement (that > uses a select in a sub-query) in Postgres - it's taking hours to run > (the equiv, using a multi-table update statement in MySQL instead of a > sub-query, takes all of 2 seconds). I'll be posting it later once I do > more reading to make sure I've done as much as I can to solve it myself. David, I think you have valid observations. And the issue regarding replication has been quite a hot topic on occasion in the developer lists. I'm hoping at some point it would become part of the standard PostgreSQL package; but point in time recovery, PITR, is needed as a stepping stone to providing that functionality. Have you attempted the multi table update inside of a transaction for PostgreSQL yet and thus assuring the all of your updates are only visible after the commit? Depending on the design and the nature of the updates, their could be a race condition if the updates on one table are utilized by another process before the rest of the updates have completed. Sets of updates in a single transaction can improve performance as well. > > I really agree with this post: > > "I guess my point is simply this: instead of saying: "okay we use > default settings that will run on _old_ hardware too" we should go for > a little script that creates a "still save but much better" config > file. There's just no point in setting SHARED_BUFFERS to something > like 16 (what's the current default?) if the PC has >= 1 GB of RAM. > Setting it to 8192 would still be save, but 512 times better... ;-) > (IIRC 8192 would take 64 MB of RAM, which should be save if you leave > the default MAX_CONNECTIONS.)" It provides examples, and some real > numbers to help someone new to the database take an initial crack at > tuning. Remember, you're trying to compete with the big-guys (Oracle, > etc), so providing info that an Oracle DBA needs is pretty critical. > I'm currently at a complete loss for tuning Postgres (it seems to do > things very differently than both Oracle and MySQL). > > > I also have to admit a bit of irritation reading this thread; there is > a fair number of incorrect statements on this thread that, while not > wrong, definately aren't right: > > "Speed depends on the nature of use and the complexity of queries. If > you are doing updates of related tables, ACID is of vital importance > and MySQL doesn't provide it." > MySQL has ACID in InnoDB. I've found that MySQL is actually very fast > on complex queries w/InnoDB (six tables, 1 million rows, two of the > joins are outer-joins. In fact, I can get InnoDB to be almost as fast > as MyISAM. Complex updates are also very very fast. We have not tried > flooding either database with dozens of complex statements from > multiple clients; that's coming soon, and from what I've read, MySQL > won't do too well. > > "using InnoDB tables (the only way to have foreign keys, transactions, > and row level locking for MySQL) makes MySQL slower and adds > complexity to tuning the database" > Adding this: "innodb_flush_method=O_DSYNC" to the my.cnf made InnoDB > as fast as MyISAM in our tests. It doesn't turn off disk flushing; > it's just a flush method that might work better with different kernels > and drives; it's one of those "play with this and see if it helps" > parameters; there are lots of those in Postgres, it seems. There are > 10 variables for tuning InnoDB (and you don't have to tune for MyISAM, > so it's actually a six-of-one, half-dozen-of-the-other). Setup between > the two seems to be about the same. > > "PostgreSQL supports constraints. MySQL doesn't; programmers need to > take care of that from the client side" > Again, InnoDB supports constraints. > > "Transactions: We've been here before. Suffice to say, MySQL+InnoDB is > almost there. Plain ol' MySQL doesn't have it, which tells you > something about their philosophy towards database design." > InnoDB supports transactions very nicely, has the equivalent of WAL, > and one thing I really like: a tablespace (comprised of data files > that can be spread around multiple hard drives), and in a month or so, > InnoDB will support multiple tablespaces. > > > To be fair, here are a few MySQL "bad-things" that weren't mentioned: > > 1) InnoDB can't do a hot-backup with the basic backup tools. To > hot-backup an InnoDB database, you need to pay $450 US per database > per year ($1150 per database perpetual) for a proprietary hot-backup tool > 2) InnoDB can't do full-text searching. > 3) I see alot more corrupt-database bugs on the MySQL lists (most are > MyISAM, but a few InnoDB bugs pop up from time to time) - way more > than I see on the Postgres lists. > 4) There are some really cranky people on the MySQL lists; the > Postgres lists seem to be much more effective (esp. with people like > Tom Lane). Maybe it's because they get alot of dumb questions, as > people unfamiliar with databases turn to MySQL first? > > Maybe the Postgres community needs an anti-FUD individual or two; > people that know both databases, and can provide the proper > information for answering questions like this. A section in the docs > would help as well. Yes, I know many of the people advocating Postgres > do not want to compare themselves to MySQL (but rather to Oracle, > Sybase, DB2, etc) , but the volume of responses on a thread like this > indicates that the comparison is going to happen regardless. Better to > nip it in the bud quickly than let it go on over 3-4 days. > > One last observation: someone looking at both databases, reading those > posts, might get a bad impression of Postgres based on the > inconsistency and incorrectness of some of the statements made about > MySQL. If a salesperson provides misinformation about a competitors > product and you find out about it, that salesperson has most likely > lost a customer. > > Anyway, I hope I haven't offended anyone - I'm not trying to troll or > flame, but rather just give some constructive criticism from someone > outside both the MySQL and Postgres camps. > > David > From pgsql-performance-owner@postgresql.org Fri Oct 10 12:37:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0F3DAD1B558 for ; Fri, 10 Oct 2003 15:37:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 39207-02 for ; Fri, 10 Oct 2003 12:36:50 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 7E191D1B53B for ; Fri, 10 Oct 2003 12:36:49 -0300 (ADT) 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 h9AFZVGQ018732; Fri, 10 Oct 2003 09:35:32 -0600 (MDT) Date: Fri, 10 Oct 2003 09:26:24 -0600 (MDT) From: "scott.marlowe" To: Bruce Momjian Cc: Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: <200310100018.h9A0ITZ21975@candle.pha.pa.us> 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: 200310/337 X-Sequence-Number: 4085 Nope, write-cache enabled by default. On Thu, 9 Oct 2003, Bruce Momjian wrote: > > How did this drive come by default? Write-cache disabled? > > --------------------------------------------------------------------------- > > scott.marlowe wrote: > > On Thu, 2 Oct 2003, scott.marlowe wrote: > > > > > I was testing to get some idea of how to speed up the speed of pgbench > > > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > > > /dev/hdx). > > > > > > The only parameter that seems to make a noticeable difference was setting > > > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > > > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > > > it jumped to the range of 45 to 52 tps. with write cache on I was getting > > > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > > > about 5 times slower, much better. > > > > > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > > > and see if the data gets corrupted with write caching turned on, i.e. do > > > my hard drives have the ability to write at least some of their cache > > > during spin down. > > > > OK, back from testing. > > > > Information: Dual PIV system with a pair of 80 gig IDE drives, model > > number: ST380023A (seagate). File system is ext3 and is on a seperate > > drive from the OS. > > > > These drives DO NOT write cache when they lose power. Testing was done by > > issuing a 'hdparm -W0/1 /dev/hdx' command where x is the real drive > > letter, and 0 or 1 was chosen in place of 0/1. Then I'd issue a 'pgbench > > -c 50 -t 100000000' command, wait for a few minutes, then pull the power > > cord. > > > > I'm running RH linux 9.0 stock install, kernel: 2.4.20-8smp. > > > > Three times pulling the plug with 'hdparm -W0 /dev/hdx' resulted in a > > machine that would boot up, recover with journal, and a database that came > > up within about 30 seconds, with all the accounts still intact. > > > > Switching the caching back on with 'hdparm -W1 /dev/hdx' and doing the > > same 'pgbench -c 50 -t 100000000' resulted in a corrupted database each > > time. > > > > Also, I tried each of the following fsync methods: fsync, fdatasync, and > > open_sync with write caching turned off. Each survived a power off test > > with no corruption of the database. fsync and fdatasync result in 11 to > > 17 tps with 'pgbench -c 5 -t 500' while open_sync resulted in 45 to 55 > > tps, as mentioned in the previous post. > > > > I'd be interested in hearing from other folks which sync method works > > for them and whether or not there are any IDE drives out there that can > > write their cache to the platters on power off when caching is enabled. > > > > > > ---------------------------(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 Oct 10 12:38:30 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BFBEBD1B4EE for ; Fri, 10 Oct 2003 15:38:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37929-07 for ; Fri, 10 Oct 2003 12:37:39 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 57231D1B513 for ; Fri, 10 Oct 2003 12:37:38 -0300 (ADT) 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 h9AFaRGQ018851; Fri, 10 Oct 2003 09:36:27 -0600 (MDT) Date: Fri, 10 Oct 2003 09:27:19 -0600 (MDT) From: "scott.marlowe" To: Bruce Momjian Cc: Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: <200310100016.h9A0GnC21875@candle.pha.pa.us> 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: 200310/338 X-Sequence-Number: 4086 On Thu, 9 Oct 2003, Bruce Momjian wrote: > scott.marlowe wrote: > > I was testing to get some idea of how to speed up the speed of pgbench > > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > > /dev/hdx). > > > > The only parameter that seems to make a noticeable difference was setting > > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > > it jumped to the range of 45 to 52 tps. with write cache on I was getting > > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > > about 5 times slower, much better. > > > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > > and see if the data gets corrupted with write caching turned on, i.e. do > > my hard drives have the ability to write at least some of their cache > > during spin down. > > Is this a reason we should switch to open_sync as a default, if it is > availble, rather than fsync? I think we are doing a single write before > fsync a lot more often than we are doing multiple writes before fsync. Sounds reasonable to me. Are there many / any scenarios where a plain fsync would be faster than open_sync? From pgsql-performance-owner@postgresql.org Fri Oct 10 12:49:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 67331D1B4F2 for ; Fri, 10 Oct 2003 15:49:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40547-04 for ; Fri, 10 Oct 2003 12:48:48 -0300 (ADT) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 030AED1B537 for ; Fri, 10 Oct 2003 12:48:42 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB18236; Fri, 10 Oct 2003 09:48:35 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16262.54365.65000.672148@gargle.gargle.HOWL> Date: Fri, 10 Oct 2003 09:46:37 -0600 To: Postgresql Performance Subject: Re: Speeding up Aggregates In-Reply-To: <874qyh8zoo.fsf@stark.dyndns.tv> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.com> <874qyh8zoo.fsf@stark.dyndns.tv> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/339 X-Sequence-Number: 4087 Greg Stark writes: > Call it a wishlist bug. The problem is it would be a hard feature to > implement properly. And none of the people paid to work on postgres > by various companies seem to have this on their to-do lists. So > don't expect it in the near future. We are using Postgres heavily, and we should be able to find some time and/or funding to help. We're becoming more and more frustrated with the discontinuous behaviour of the planner. It seems every complex query we have these days needs some "hint" like "ORDER BY foo DESC LIMIT 1" to make it run on the order of seconds, not minutes. We usually figure out a way to write the query so the planner does the right thing, and pushes the discontinuity out far enough that the user doesn't see it. However, it takes a lot of work, and it seems to me that work would be put to better use improving the planner than improving our knowledge of how to get the planner to do the right thing by coding the SQL in some unusual way. Please allow me to go out on a limb here. I know that Tom is philosophically opposed to planner hints. However, we do have a problem that the planner is never going to be smart enough. This leaves the SQL coder the only option of collecting a bag of (non-portable) SQL tricks. I saw what the best SQL coders did at Tandem, and frankly, it's scary. Being at Tandem, the SQL coders also had the option (if they could argue their case strong enough) of adding a new rule to the optimizer. This doesn't solve the problem for outsiders no matter how good they are at SQL. Would it be possible to extend the planner with a pattern matching language? It would formalize what it is doing already, and would allow outsiders to teach the planner about idiosyncrasies without changing the SQL. It would be like a style sheet in Latex (or Scribe :-) if you are familiar with these typesetting languages. Comments? Rob From pgsql-performance-owner@postgresql.org Fri Oct 10 13:32:03 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4F988D1B551 for ; Fri, 10 Oct 2003 16:31:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51851-04 for ; Fri, 10 Oct 2003 13:31:09 -0300 (ADT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 6572DD1B4EE for ; Fri, 10 Oct 2003 13:31:05 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id 4D137EC01B for ; Fri, 10 Oct 2003 18:27:46 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id 30734EC01A for ; Fri, 10 Oct 2003 18:27:46 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9=20Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Postgresql Performance Subject: One or more processor ? Date: Fri, 10 Oct 2003 18:30:49 +0200 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200310101830.49608.herve@elma.fr> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/340 X-Sequence-Number: 4088 Hi, A simple question about PostgreSQL ... I have a Pentium Xeon Quadri processors ... If I do a SQL request ... does PostgreSQL use one or more processor ? And if it use only one ... why ? Could you explain me this ;o) Thanks per advance. -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Fri Oct 10 13:36:44 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 50B06D1B558 for ; Fri, 10 Oct 2003 16:36:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51268-10 for ; Fri, 10 Oct 2003 13:35:49 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 6F23FD1B513 for ; Fri, 10 Oct 2003 13:35:47 -0300 (ADT) Received: (qmail 77875 invoked from network); 10 Oct 2003 16:35:50 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 10 Oct 2003 16:35:50 -0000 Date: Fri, 10 Oct 2003 12:35:50 -0400 (EDT) From: Jeff To: =?iso-8859-15?q?Herv=E9=20Piedvache?= Cc: Postgresql Performance Subject: Re: One or more processor ? In-Reply-To: <200310101830.49608.herve@elma.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/341 X-Sequence-Number: 4089 On Fri, 10 Oct 2003, [iso-8859-15] Herv� Piedvache wrote: > If I do a SQL request ... does PostgreSQL use one or more processor ? > Nope. Just one processor this is because PG is process not thread based. However, if you opened 4 connections and each issued a sql statement all 4 processors would be used. Check the -HACKERS archives for lengthy discussions of this. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 10 13:37:00 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 76B50D1B4E2 for ; Fri, 10 Oct 2003 16:36:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51654-08 for ; Fri, 10 Oct 2003 13:36:12 -0300 (ADT) Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) by svr1.postgresql.org (Postfix) with ESMTP id 8C536D1B55D for ; Fri, 10 Oct 2003 13:36:11 -0300 (ADT) Received: from mailer.elma.loc (localhost [127.0.0.1]) by localhost (Postfix) with ESMTP id F3156EC01B for ; Fri, 10 Oct 2003 18:33:07 +0200 (CEST) Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) by mailer.elma.loc (Postfix) with ESMTP id D755DEC01A for ; Fri, 10 Oct 2003 18:33:07 +0200 (CEST) From: =?iso-8859-15?q?Herv=E9=20Piedvache?= Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique To: Postgresql Performance Subject: PostgreSQL Scalable ? Date: Fri, 10 Oct 2003 18:36:11 +0200 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200310101836.11281.herve@elma.fr> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/342 X-Sequence-Number: 4090 Hi, One other small question ... Does PostgreSQL is scalable ? I mean ... is it possible to have two servers, one rack of disks connected to the 2 servers to get access in same time to the same database ? Other point is there any possibilties to make servers clusters with PostgreSQL ? If no why ? If yes how ? ;o) To be clear I would like to make a system with PostgreSQL able to answer about 70 000 000 requests by day (Internet services) ... I'm not sure about the server configuration I have to make. Thanks per advance for your answers. Regards, -- Herv� Piedvache Elma Ing�nierie Informatique 6 rue du Faubourg Saint-Honor� F-75008 - Paris - France Pho. 33-144949901 Fax. 33-144949902 From pgsql-performance-owner@postgresql.org Fri Oct 10 13:39:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A2EA7D1B571 for ; Fri, 10 Oct 2003 16:39:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53526-01 for ; Fri, 10 Oct 2003 13:39:06 -0300 (ADT) Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) by svr1.postgresql.org (Postfix) with ESMTP id 7D659D1B4EE for ; Fri, 10 Oct 2003 13:38:49 -0300 (ADT) Received: from zigo.dhs.org (zigo [127.0.0.1]) by zigo.dhs.org (8.12.8/8.12.8) with ESMTP id h9AGckpf004748; Fri, 10 Oct 2003 18:38:46 +0200 Received: from localhost (db@localhost) by zigo.dhs.org (8.12.8/8.12.8/Submit) with ESMTP id h9AGck1w004744; Fri, 10 Oct 2003 18:38:46 +0200 Date: Fri, 10 Oct 2003 18:38:46 +0200 (CEST) From: Dennis Bjorklund To: =?iso-8859-15?q?Herv=E9=20Piedvache?= Cc: Postgresql Performance Subject: Re: One or more processor ? In-Reply-To: <200310101830.49608.herve@elma.fr> Message-ID: 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: 200310/343 X-Sequence-Number: 4091 On Fri, 10 Oct 2003, [iso-8859-15] Herv� Piedvache wrote: > A simple question about PostgreSQL ... I have a Pentium Xeon Quadri > processors ... If I do a SQL request ... does PostgreSQL use one or more > processor ? Each connection becomes a process, and each process runs on one processor. So, with only one connection you use only one processor (and the OS might use an other processor). Most databases has many concurrent users and then it will use more processors. -- /Dennis From pgsql-performance-owner@postgresql.org Fri Oct 10 13:42:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E68C4D1B502 for ; Fri, 10 Oct 2003 16:42:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53656-03 for ; Fri, 10 Oct 2003 13:42:00 -0300 (ADT) Received: from mta7.adelphia.net (mta7.adelphia.net [68.168.78.193]) by svr1.postgresql.org (Postfix) with ESMTP id B9D89D1B567 for ; Fri, 10 Oct 2003 13:41:48 -0300 (ADT) Received: from potentialtech.com ([68.68.113.33]) by mta7.adelphia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031010164150.VALY21600.mta7.adelphia.net@potentialtech.com>; Fri, 10 Oct 2003 12:41:50 -0400 Message-ID: <3F86E15C.1010309@potentialtech.com> Date: Fri, 10 Oct 2003 12:42:04 -0400 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: =?ISO-8859-15?Q?Herv=E9_Piedvache?= Cc: Postgresql Performance Subject: Re: One or more processor ? References: <200310101830.49608.herve@elma.fr> In-Reply-To: <200310101830.49608.herve@elma.fr> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/344 X-Sequence-Number: 4092 Herv� Piedvache wrote: > Hi, > > A simple question about PostgreSQL ... I have a Pentium Xeon Quadri processors > ... > If I do a SQL request ... does PostgreSQL use one or more processor ? PostgreSQL uses one processor per connection. If you have 4 simultaneous connections, you'll use all four processors (assuming your operating system is properly designed/configured). > And if it use only one ... why ? > Could you explain me this ;o) The answer to that is beyond my knowledge, but I have a few guesses: 1) Doing so is more complicated than you think. 2) The code was originally written for uniprocessor machines, and nobody has volunteered to update it yet. 3) kernel threading isn't as predictable as some people would like to think, thus they developers have avoided using it so far. 4) It simply isn't practical to expect a single query to execute on multiple processors simultaneously. Do you know of any RDBMS that actually will execute a single query on multiple processors? -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Oct 10 13:45:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 035F4D1B580 for ; Fri, 10 Oct 2003 16:45:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52902-08 for ; Fri, 10 Oct 2003 13:44:24 -0300 (ADT) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id C5048D1B537 for ; Fri, 10 Oct 2003 13:44:21 -0300 (ADT) Received: (qmail 24915 invoked from network); 10 Oct 2003 16:44:21 -0000 Received: from unknown (HELO localhost) (207.228.252.42) by 0 with SMTP; 10 Oct 2003 16:44:21 -0000 From: greg@turnstep.com To: pgsql-performance@postgresql.org Subject: Re: Compare rows X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <200310081611.59179.josh@agliodbs.com> Date: Fri, 10 Oct 2003 16:44:21 -0000 X-Mailer: JoyMail 1.38 Message-ID: <1756cdfe0672f1cab443627e1fd7a4b3@biglumber.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/345 X-Sequence-Number: 4093 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > The most efficient way for you to store data would be like this: > main table > id address > 3 67.92 > 7 69.5 > > child table > id value_type value > 3 uptime 0.3 > 3 memory 37 > 7 uptime 1.1 > 7 memory 15 Actually, a more efficient* way is this: value table vid value_name 1 uptime 2 memory child table id vid value 3 1 0.3 3 2 37 7 1 1.1 7 2 15 * Still not necessarily the *most* efficient, depending on how the values are distributed, but it sure beats storing "uptime" over and over again. :) - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200310101243 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iD8DBQE/huHxvJuQZxSWSsgRAiMNAKD4kQCwdv3fXyEFUu64mymtf567dwCcCKd5 ZzJaV7wjfs00DBT62bVpHhs= =32b8 -----END PGP SIGNATURE----- From pgsql-performance-owner@postgresql.org Fri Oct 10 13:56:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4186BD1B4FD for ; Fri, 10 Oct 2003 16:56:29 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54645-09 for ; Fri, 10 Oct 2003 13:55:40 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 69732D1B537 for ; Fri, 10 Oct 2003 13:55:38 -0300 (ADT) Received: (qmail 78039 invoked from network); 10 Oct 2003 16:55:42 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 10 Oct 2003 16:55:42 -0000 Date: Fri, 10 Oct 2003 12:55:42 -0400 (EDT) From: Jeff To: =?iso-8859-15?q?Herv=E9=20Piedvache?= Cc: Postgresql Performance Subject: Re: PostgreSQL Scalable ? In-Reply-To: <200310101836.11281.herve@elma.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/346 X-Sequence-Number: 4094 On Fri, 10 Oct 2003, [iso-8859-15] Herv� Piedvache wrote: > One other small question ... Does PostgreSQL is scalable ? > I mean ... is it possible to have two servers, one rack of disks connected to > the 2 servers to get access in same time to the same database ? No. You need to replicate the DB to another machine to have this work - and even still, all writes need to go to the 'master' db. Reads can go to either. > To be clear I would like to make a system with PostgreSQL able to answer about > 70 000 000 requests by day (Internet services) ... I'm not sure about the > server configuration I have to make. > Well, 70M requests/day is only about 810 / second - assuming we're talking about simple selects that is very easy to achieve. Considering hardware you should look at: multiple cpus, gigs of memory, and very fast disks. (Raid5 w/battery backed write caches seem to be popular). You should also look at how much data this guy will hold, what is the read/write ratio and all the "normal" things you should do while planning a db. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 10 14:10:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 77223D1B53B for ; Fri, 10 Oct 2003 17:10:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55638-07 for ; Fri, 10 Oct 2003 14:09:38 -0300 (ADT) Received: from chimta04.algx.net (mta5.algx.net [67.92.168.234]) by svr1.postgresql.org (Postfix) with ESMTP id 6CDB7D1B513 for ; Fri, 10 Oct 2003 14:09:37 -0300 (ADT) Received: from JSH ([67.92.23.74]) by chimmx04.algx.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with SMTP id <0HMJ002AYWZYCX@chimmx04.algx.net> for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 12:09:37 -0500 (CDT) Date: Fri, 10 Oct 2003 13:09:34 -0400 From: Jason Hihn Subject: Re: One or more processor ? In-reply-to: <3F86E15C.1010309@potentialtech.com> To: Bill Moran , =?iso-8859-15?Q?Herv=E9_Piedvache?= Cc: Postgresql Performance Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Content-type: text/plain; charset=iso-8859-15 Content-transfer-encoding: 8BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/348 X-Sequence-Number: 4096 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Bill Moran > Sent: Friday, October 10, 2003 12:42 PM > To: Herv� Piedvache > Cc: Postgresql Performance > Subject: Re: [PERFORM] One or more processor ? > > > Herv� Piedvache wrote: > > Hi, > > > > A simple question about PostgreSQL ... I have a Pentium Xeon > Quadri processors > > ... > > If I do a SQL request ... does PostgreSQL use one or more processor ? > > PostgreSQL uses one processor per connection. If you have 4 simultaneous > connections, you'll use all four processors (assuming your > operating system > is properly designed/configured). > > > And if it use only one ... why ? > > Could you explain me this ;o) > > The answer to that is beyond my knowledge, but I have a few guesses: > 1) Doing so is more complicated than you think. You need to be able to paralellize the algorithm. Even so, a 99% paralelizable algorithm over 2 cpus is only 50% faster than 1 cpu. So choose your poison: 2 processes @100% in 1tu or 1 process at 150% at .66tu (tu=time unit). This ofcourse is over simplification. I don't think 99% is reasonable in query processing (though it can depend on the query) so I expect the 2 connection method to be better, unless you only ever have 1 connection. From pgsql-performance-owner@postgresql.org Fri Oct 10 14:04:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 57860D1B513 for ; Fri, 10 Oct 2003 17:04:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55663-07 for ; Fri, 10 Oct 2003 14:03:31 -0300 (ADT) Received: from phaedrusdeinus.org (dsl092-130-239.chi1.dsl.speakeasy.net [66.92.130.239]) by svr1.postgresql.org (Postfix) with SMTP id 5F75BD1B4FD for ; Fri, 10 Oct 2003 14:03:29 -0300 (ADT) Received: (qmail 52315 invoked by uid 1001); 10 Oct 2003 17:15:34 -0000 Date: Fri, 10 Oct 2003 12:15:34 -0500 From: johnnnnnn To: pgsql-performance@postgresql.org Subject: Re: One or more processor ? Message-ID: <20031010171534.GB7976@performics.com> References: <200310101830.49608.herve@elma.fr> <3F86E15C.1010309@potentialtech.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F86E15C.1010309@potentialtech.com> User-Agent: Mutt/1.5.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/347 X-Sequence-Number: 4095 On Fri, Oct 10, 2003 at 12:42:04PM -0400, Bill Moran wrote: > 4) It simply isn't practical to expect a single query to > execute on multiple processors simultaneously. > > Do you know of any RDBMS that actually will execute a single query > on multiple processors? Yes, DB2 will do this if configured correctly. It's very useful for large, complicated queries that have multiple subplans. -johnnnnnnnn From pgsql-performance-owner@postgresql.org Fri Oct 10 14:25:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C3106D1B4ED for ; Fri, 10 Oct 2003 17:25:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55574-10 for ; Fri, 10 Oct 2003 14:24:41 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 6C022D1B55D for ; Fri, 10 Oct 2003 14:24:39 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9AHOTs24892; Fri, 10 Oct 2003 13:24:29 -0400 (EDT) From: Bruce Momjian Message-Id: <200310101724.h9AHOTs24892@candle.pha.pa.us> Subject: Re: further testing on IDE drives In-Reply-To: To: "scott.marlowe" Date: Fri, 10 Oct 2003 13:24:29 -0400 (EDT) Cc: Postgresql Performance X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/349 X-Sequence-Number: 4097 scott.marlowe wrote: > On Thu, 9 Oct 2003, Bruce Momjian wrote: > > > scott.marlowe wrote: > > > I was testing to get some idea of how to speed up the speed of pgbench > > > with IDE drives and the write caching turned off in Linux (i.e. hdparm -W0 > > > /dev/hdx). > > > > > > The only parameter that seems to make a noticeable difference was setting > > > wal_sync_method = open_sync. With it set to either fsync, or fdatasync, > > > the speed with pgbench -c 5 -t 1000 ran from 11 to 17 tps. With open_sync > > > it jumped to the range of 45 to 52 tps. with write cache on I was getting > > > 280 to 320 tps. so, not instead of being 20 to 30 times slower, I'm only > > > about 5 times slower, much better. > > > > > > Now I'm off to start a "pgbench -c 10 -t 10000" and pull the power cord > > > and see if the data gets corrupted with write caching turned on, i.e. do > > > my hard drives have the ability to write at least some of their cache > > > during spin down. > > > > Is this a reason we should switch to open_sync as a default, if it is > > availble, rather than fsync? I think we are doing a single write before > > fsync a lot more often than we are doing multiple writes before fsync. > > Sounds reasonable to me. Are there many / any scenarios where a plain > fsync would be faster than open_sync? Yes. If you were doing multiple WAL writes before transaction fsync, you would be fsyncing every write, rather than doing two writes and fsync'ing them both. I wonder if larger transactions would find open_sync slower? -- 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 Fri Oct 10 14:27:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 30ED3D1B51B for ; Fri, 10 Oct 2003 17:27:10 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 63915-03 for ; Fri, 10 Oct 2003 14:26:25 -0300 (ADT) Received: from mta9.adelphia.net (mta9.adelphia.net [68.168.78.199]) by svr1.postgresql.org (Postfix) with ESMTP id BFC14D1B4ED for ; Fri, 10 Oct 2003 14:26:23 -0300 (ADT) Received: from potentialtech.com ([68.68.113.33]) by mta9.adelphia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031010172626.TJYK4462.mta9.adelphia.net@potentialtech.com>; Fri, 10 Oct 2003 13:26:26 -0400 Message-ID: <3F86EBD0.3050609@potentialtech.com> Date: Fri, 10 Oct 2003 13:26:40 -0400 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: johnnnnnn Cc: pgsql-performance@postgresql.org Subject: Re: One or more processor ? References: <200310101830.49608.herve@elma.fr> <3F86E15C.1010309@potentialtech.com> <20031010171534.GB7976@performics.com> In-Reply-To: <20031010171534.GB7976@performics.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: 200310/350 X-Sequence-Number: 4098 johnnnnnn wrote: > On Fri, Oct 10, 2003 at 12:42:04PM -0400, Bill Moran wrote: > >>4) It simply isn't practical to expect a single query to >> execute on multiple processors simultaneously. >> >>Do you know of any RDBMS that actually will execute a single query >>on multiple processors? > > Yes, DB2 will do this if configured correctly. It's very useful for > large, complicated queries that have multiple subplans. I expected there would be someone who did (although I didn't know for sure). Is DB2 the only one that can do that? -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Oct 10 14:35:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0D344D1B502 for ; Fri, 10 Oct 2003 17:35:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 63480-07 for ; Fri, 10 Oct 2003 14:34:48 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 42570D1B4ED for ; Fri, 10 Oct 2003 14:34:46 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750212; Fri, 10 Oct 2003 10:35:16 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Dror Matalon , Postgresql Performance Subject: Re: Speeding up Aggregates Date: Fri, 10 Oct 2003 10:32:32 -0700 User-Agent: KMail/1.4.3 References: <20031003202120.GO87525@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.com> In-Reply-To: <20031010035526.GT2979@rlx11.zapatec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101032.32271.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/351 X-Sequence-Number: 4099 Dror, > Ouch. I just double checked and you're right. Is this considered a bug, > or just an implementation issue? It's an implementation issue, which may be fixed by 7.5 but not sooner. Basically, the free ability of PostgreSQL users to define their own aggregates limits our ability to define query planner optimization for aggregates. Only recently has anyone suggested a feasable way around this. > While I've seen this hint a few times in the lists, it seems like it's > one of those magic incantations that those in the know, know about, and > that people new to postgres are going to be surprised by the need to use > this idiom. It IS in the FAQ. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 14:37:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 39E30D1B8A4 for ; Fri, 10 Oct 2003 17:37:56 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 65648-05 for ; Fri, 10 Oct 2003 14:37:08 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D15FED1B592 for ; Fri, 10 Oct 2003 14:37:00 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750228; Fri, 10 Oct 2003 10:37:36 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Nick Barr" , Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 10:34:52 -0700 User-Agent: KMail/1.4.3 References: <007901c38f2b$0b585590$2802a8c0@webbased10> In-Reply-To: <007901c38f2b$0b585590$2802a8c0@webbased10> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101034.52073.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/352 X-Sequence-Number: 4100 Nick, > Having been following the thread on "go for a script! / ex: PostgreSQL vs. > MySQL". I thought I would throw something together in Perl. Cool! Would you be willing to work with me so that I can inject some of my knowledge of .conf tuning? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 14:44:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AE5B6D1B55D for ; Fri, 10 Oct 2003 17:44:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66297-07 for ; Fri, 10 Oct 2003 14:43:28 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id F0913D1B571 for ; Fri, 10 Oct 2003 14:43:17 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750270; Fri, 10 Oct 2003 10:43:53 -0700 Content-Type: text/plain; charset="iso-8859-15" From: Josh Berkus Organization: Aglio Database Solutions To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , Postgresql Performance Subject: Re: PostgreSQL Scalable ? Date: Fri, 10 Oct 2003 10:41:09 -0700 User-Agent: KMail/1.4.3 References: <200310101836.11281.herve@elma.fr> In-Reply-To: <200310101836.11281.herve@elma.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101041.09459.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/353 X-Sequence-Number: 4101 Herve' > One other small question ... Does PostgreSQL is scalable ? Given that we have several members of our community with 2TB databases, and one entitiy with a 32TB database, I'd say yes. > I mean ... is it possible to have two servers, one rack of disks connected > to the 2 servers to get access in same time to the same database ? Not at this time, no. > Other point is there any possibilties to make servers clusters with > PostgreSQL ? If no why ? If yes how ? ;o) Only via replication or creative use of DBLink. Nobody has yet offered to build us database server clustering, which would be very nice to have, but would require a substantial investment from a corporate sponsor. > To be clear I would like to make a system with PostgreSQL able to answer > about 70 000 000 requests by day (Internet services) ... I'm not sure about > the server configuration I have to make. That sounds doable on proper hardware with good tuning. Might I suggest that you consider hiring a consultant and start from there? I believe that Afilias Limited (www.afilias.info) has the requisite experience in Europe. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 14:46:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 23356D1B4EE for ; Fri, 10 Oct 2003 17:46:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67684-01 for ; Fri, 10 Oct 2003 14:45:26 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 5C472D1B502 for ; Fri, 10 Oct 2003 14:45:19 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750284; Fri, 10 Oct 2003 10:45:55 -0700 Content-Type: text/plain; charset="iso-8859-15" From: Josh Berkus Organization: Aglio Database Solutions To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , Postgresql Performance Subject: Re: One or more processor ? Date: Fri, 10 Oct 2003 10:43:10 -0700 User-Agent: KMail/1.4.3 References: <200310101830.49608.herve@elma.fr> In-Reply-To: <200310101830.49608.herve@elma.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101043.11000.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/354 X-Sequence-Number: 4102 Herve' > A simple question about PostgreSQL ... I have a Pentium Xeon Quadri > processors ... > If I do a SQL request ... does PostgreSQL use one or more processor ? For your configuration, yes, you want multiple processors. Postgres (or rather, the host OS) will distribute active connections over the multiple processors. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 14:47:19 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2AF88D1B542 for ; Fri, 10 Oct 2003 17:47:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67149-05 for ; Fri, 10 Oct 2003 14:46:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id AF301D1B545 for ; Fri, 10 Oct 2003 14:46:29 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750286; Fri, 10 Oct 2003 10:47:05 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Bruce Momjian , "scott.marlowe" Subject: Re: further testing on IDE drives Date: Fri, 10 Oct 2003 10:44:21 -0700 User-Agent: KMail/1.4.3 Cc: Postgresql Performance References: <200310101724.h9AHOTs24892@candle.pha.pa.us> In-Reply-To: <200310101724.h9AHOTs24892@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101044.21177.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/355 X-Sequence-Number: 4103 Bruce, > Yes. If you were doing multiple WAL writes before transaction fsync, > you would be fsyncing every write, rather than doing two writes and > fsync'ing them both. I wonder if larger transactions would find > open_sync slower? Want me to test? I've got an ide-based test machine here, and the TPCC databases. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 15:12:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0DA1CD1B551 for ; Fri, 10 Oct 2003 18:12:27 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 69221-09 for ; Fri, 10 Oct 2003 15:11:42 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 99A15D1B527 for ; Fri, 10 Oct 2003 15:11:40 -0300 (ADT) 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 h9AIA8GQ006321; Fri, 10 Oct 2003 12:10:09 -0600 (MDT) Date: Fri, 10 Oct 2003 12:01:00 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: Bruce Momjian , Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: <200310101044.21177.josh@agliodbs.com> 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: 200310/357 X-Sequence-Number: 4105 On Fri, 10 Oct 2003, Josh Berkus wrote: > Bruce, > > > Yes. If you were doing multiple WAL writes before transaction fsync, > > you would be fsyncing every write, rather than doing two writes and > > fsync'ing them both. I wonder if larger transactions would find > > open_sync slower? > > Want me to test? I've got an ide-based test machine here, and the TPCC > databases. Just make sure the drive's write cache is disabled. From pgsql-performance-owner@postgresql.org Fri Oct 10 15:11:24 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 54010D1B4E2 for ; Fri, 10 Oct 2003 18:11:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 76610-01 for ; Fri, 10 Oct 2003 15:10:33 -0300 (ADT) Received: from easily.co.uk (unknown [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id 06E2ED1B563 for ; Fri, 10 Oct 2003 15:10:32 -0300 (ADT) Received: from [82.33.0.73] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 30186917; Fri, 10 Oct 2003 19:10:29 +0100 Message-ID: <3F86F5BB.90605@chuckie.co.uk> Date: Fri, 10 Oct 2003 19:08:59 +0100 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 Berkus Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> In-Reply-To: <200310101034.52073.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: 200310/356 X-Sequence-Number: 4104 Josh Berkus wrote: >Nick, > > > >>Having been following the thread on "go for a script! / ex: PostgreSQL vs. >>MySQL". I thought I would throw something together in Perl. >> >> > >Cool! Would you be willing to work with me so that I can inject some of my >knowledge of .conf tuning? > > > Sounds good to me. I will carry on working on it but I would definitely need some help, or at least a list of parameters to tweak, and some recomended values based on data about the puter in question. So far: shared_buffers = 1/16th of total memory effective_cache_size = 80% of the supposed kernel cache. I guess we also may be able to offer a simple and advanced mode. Simple mode would work on these recomended values, but kick it into advanced mode and the user can tweak things more finely. This would only be recomended for the Guru's out there of course. This may take a bit more time to do though. As I said in the previous email I have only got access to Linux, so cross-platform help would be good too. I will try to make it as easy to do cross platform stuff as possible of course. Nick From pgsql-performance-owner@postgresql.org Fri Oct 10 15:26:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F1B3D1B545 for ; Fri, 10 Oct 2003 18:26:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77979-07 for ; Fri, 10 Oct 2003 15:25:27 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id CA827D1B573 for ; Fri, 10 Oct 2003 15:23:54 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 65E9A5FAF for ; Fri, 10 Oct 2003 18:23:49 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9AINmgi018927 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 11:23:48 -0700 (PDT) (envelope-from dror) Date: Fri, 10 Oct 2003 11:23:48 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031010182348.GD2979@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.com> <200310101032.32271.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310101032.32271.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/358 X-Sequence-Number: 4106 On Fri, Oct 10, 2003 at 10:32:32AM -0700, Josh Berkus wrote: > Dror, > > > Ouch. I just double checked and you're right. Is this considered a bug, > > or just an implementation issue? > > It's an implementation issue, which may be fixed by 7.5 but not sooner. > Basically, the free ability of PostgreSQL users to define their own > aggregates limits our ability to define query planner optimization for > aggregates. Only recently has anyone suggested a feasable way around this. > > > While I've seen this hint a few times in the lists, it seems like it's > > one of those magic incantations that those in the know, know about, and > > that people new to postgres are going to be surprised by the need to use > > this idiom. > > It IS in the FAQ. Might be a good idea to put it in its own section rather than under "My queries are slow or don't make use of the indexes. Why?" Also, you might want to take out for 7.4 4.22) Why are my subqueries using IN so slow? > > -- > Josh Berkus > Aglio Database Solutions > San Francisco -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Fri Oct 10 15:33:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 508F1D1B4ED for ; Fri, 10 Oct 2003 18:33:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 78846-09 for ; Fri, 10 Oct 2003 15:33:09 -0300 (ADT) Received: from jamesr.best.vwh.net (jamesr.best.vwh.net [192.220.76.165]) by svr1.postgresql.org (Postfix) with SMTP id 20B51D1B4FD for ; Fri, 10 Oct 2003 15:33:07 -0300 (ADT) Received: (qmail 29458 invoked by uid 19621); 10 Oct 2003 18:33:05 -0000 Received: from unknown (HELO ?10.0.0.210?) ([65.87.16.98]) (envelope-sender ) by 192.220.76.165 (qmail-ldap-1.03) with SMTP for ; 10 Oct 2003 18:33:05 -0000 Subject: Re: PostgreSQL Scalable ? From: James Rogers To: pgsql-performance@postgresql.org Cc: herve@elma.fr In-Reply-To: <200310101041.09459.josh@agliodbs.com> References: <200310101836.11281.herve@elma.fr> <200310101041.09459.josh@agliodbs.com> Content-Type: text/plain Organization: Message-Id: <1065810785.3099.18.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 10 Oct 2003 11:33:05 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/359 X-Sequence-Number: 4107 On Fri, 2003-10-10 at 10:41, Josh Berkus wrote: > Herve' > > One other small question ... Does PostgreSQL is scalable ? > > Given that we have several members of our community with 2TB databases, and > one entitiy with a 32TB database, I'd say yes. It depends on what is meant by "scalable". In terms of physical data size, definitely yes. In terms of concurrency, it is also pretty good with only a few caveats (e.g. large SMP systems aren't really exploited to their potential). However, in terms of working set size it is only "fair to middling", which is why I'm looking into those parts right now. So "scalable" really depends on what your load profile looks like. For some load profiles it is extremely scalable and for other load profiles less so, though nothing exhibits truly "poor" scalability that I've found. A lot of scalability is how you set the parameters and design the system if the underlying engine is reasonably competent. For the vast majority of purposes, you'll find that PostgreSQL scales just fine. Cheers, -James Rogers jamesr@best.com From pgsql-performance-owner@postgresql.org Fri Oct 10 15:40:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C3412D1B540 for ; Fri, 10 Oct 2003 18:40:19 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 80817-01 for ; Fri, 10 Oct 2003 15:39:35 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 9024DD1B4F0 for ; Fri, 10 Oct 2003 15:39:30 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9AIdJn03045; Fri, 10 Oct 2003 14:39:19 -0400 (EDT) From: Bruce Momjian Message-Id: <200310101839.h9AIdJn03045@candle.pha.pa.us> Subject: Re: further testing on IDE drives In-Reply-To: <200310101044.21177.josh@agliodbs.com> To: Josh Berkus Date: Fri, 10 Oct 2003 14:39:19 -0400 (EDT) Cc: "scott.marlowe" , Postgresql Performance X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/360 X-Sequence-Number: 4108 Josh Berkus wrote: > Bruce, > > > Yes. If you were doing multiple WAL writes before transaction fsync, > > you would be fsyncing every write, rather than doing two writes and > > fsync'ing them both. I wonder if larger transactions would find > > open_sync slower? > > Want me to test? I've got an ide-based test machine here, and the TPCC > databases. I would be interested to see if wal_sync_method = fsync is slower than wal_sync_method = open_sync. How often are we doing more then one write before a fsync anyway? -- 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 Fri Oct 10 16:21:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 25FBED1B4F0 for ; Fri, 10 Oct 2003 19:21:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 91494-01 for ; Fri, 10 Oct 2003 16:21:11 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 4F584D1B52A for ; Fri, 10 Oct 2003 16:21:10 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h9AJLAQh043684 for ; Fri, 10 Oct 2003 19: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 h9AJA3DH042272 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 19:10:03 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: One or more processor ? Date: Fri, 10 Oct 2003 14:49:30 -0400 Organization: Hub.Org Networking Services Lines: 28 Message-ID: <6065ix3p39.fsf@dev6.int.libertyrms.info> References: <200310101830.49608.herve@elma.fr> 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:kABb2qBePhvBa6AaamRgYRajKVE= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/361 X-Sequence-Number: 4109 herve@elma.fr (=?iso-8859-15?q?Herv=E9=20Piedvache?=) writes: > A simple question about PostgreSQL ... I have a Pentium Xeon Quadri processors > ... > If I do a SQL request ... does PostgreSQL use one or more processor ? Just one processor. > And if it use only one ... why ? > Could you explain me this ;o) ... Because partitioning requests across multiple processors is a hairy and difficult proposition. Some musing has been done on how threading might be used to split processing of queries across multiple CPUs, but it represents a pretty immense task involving substantial effort for design, implementation, and testing. It's tough to make this portable across all the system PostgreSQL supports, too. So while musing has been done, nobody has seriously tried implementing it. -- output = ("cbbrowne" "@" "libertyrms.info") Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Fri Oct 10 17:22:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 92A2FD1B4EE for ; Fri, 10 Oct 2003 20:22:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01967-03 for ; Fri, 10 Oct 2003 17:22:09 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id CB35FD1B4EF for ; Fri, 10 Oct 2003 17:22:07 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id CB16D3E60 for ; Fri, 10 Oct 2003 16:22:09 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 88557-02 for ; Fri, 10 Oct 2003 16:22:09 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 0D4A33E45 for ; Fri, 10 Oct 2003 16:22:09 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9AKM8eu085430 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 16:22:08 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 16:22:08 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 21 Message-ID: References: <200310090956.11356.josh@agliodbs.com> <20031009171715.GR2979@rlx11.zapatec.com> <20031009181112.GA71907@perrin.nxad.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065817328 37790 216.194.193.105 (10 Oct 2003 20:22:08 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 10 Oct 2003 20:22:08 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:3PEamKR/iQfmWBjd9xkuFjOVCNY= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/362 X-Sequence-Number: 4110 >>>>> "SC" == Sean Chittenden writes: SC> patches to extract info from their OS so that initdb can make useful SC> decisions. Or, lastly, does anyone think that this should be in a SC> different, external program? -sc Well, there should definitely be a way to run a "get current best tuning advice" for those times when I go and do something like add a Gig of RAM. ;-) Also, I'm sure the tuning advice will change over time, so having to do initdb to get that advice would be a bit onerous. As long as initdb has an option for just getting the tuning info, I see no reason to make it separate. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 10 17:27:49 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D62FAD1B528 for ; Fri, 10 Oct 2003 20:27:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02832-02 for ; Fri, 10 Oct 2003 17:26:59 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id F2946D1B56C for ; Fri, 10 Oct 2003 17:26:57 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 1A5383EB6 for ; Fri, 10 Oct 2003 16:27:00 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 87429-03 for ; Fri, 10 Oct 2003 16:26:59 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 673013E45 for ; Fri, 10 Oct 2003 16:26:59 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9AKQxsc096043 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 16:26:59 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 16:26:58 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 15 Message-ID: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065817619 37790 216.194.193.105 (10 Oct 2003 20:26:59 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 10 Oct 2003 20:26:59 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:8pOrDBmF63Cr3NK0AE6Yb3gXiIw= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/363 X-Sequence-Number: 4111 >>>>> "NB" == Nick Barr writes: NB> So far: NB> shared_buffers = 1/16th of total memory NB> effective_cache_size = 80% of the supposed kernel cache. Please take into account the blocksize compiled into PG, too... -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 10 17:41:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BEFBBD1B4F6 for ; Fri, 10 Oct 2003 20:41:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01863-08 for ; Fri, 10 Oct 2003 17:40:29 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4136DD1B4F0 for ; Fri, 10 Oct 2003 17:40:27 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750938; Fri, 10 Oct 2003 13:41:03 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Nick Barr Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 13:38:18 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> In-Reply-To: <3F86F5BB.90605@chuckie.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101338.18167.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/364 X-Sequence-Number: 4112 Nick, > Sounds good to me. I will carry on working on it but I would definitely > need some help, or at least a list of parameters to tweak, and some > recomended values based on data about the puter in question. > shared_buffers = 1/16th of total memory > effective_cache_size = 80% of the supposed kernel cache. But only if it's a dedicated DB machine. If it's not, all memory values should be cut in half. > I guess we also may be able to offer a simple and advanced mode. Simple > mode would work on these recomended values, but kick it into advanced > mode and the user can tweak things more finely. This would only be > recomended for the Guru's out there of course. This may take a bit more > time to do though. What I would prefer would be an interactive script which would, by asking the user simple questions and system scanning, collect all the information necessary to set: max_connections shared_buffers sort_mem vacuum_mem effective_cache_size random_page_cost max_fsm_pages checkpoint_segments & checkpoint_timeout tcp_ip and on the OS, it should set: shmmax & shmmall and should offer to create a chron job which does appropriate frequency VACUUM ANALYZE. > As I said in the previous email I have only got access to Linux, so > cross-platform help would be good too. I will try to make it as easy to > do cross platform stuff as possible of course. Let's get it working on Linux; then we can rely on the community to port it to other platforms. I myself can work on the ports to Solaris and OS X. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 17:42:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 03144D1B4EF for ; Fri, 10 Oct 2003 20:42:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05044-02 for ; Fri, 10 Oct 2003 17:41:59 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 76B77D1B4E3 for ; Fri, 10 Oct 2003 17:41:56 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750944; Fri, 10 Oct 2003 13:42:33 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Vivek Khera , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 13:39:48 -0700 User-Agent: KMail/1.4.3 References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F86F5BB.90605@chuckie.co.uk> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101339.48392.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/365 X-Sequence-Number: 4113 Vivek, > NB> shared_buffers = 1/16th of total memory > NB> effective_cache_size = 80% of the supposed kernel cache. > > Please take into account the blocksize compiled into PG, too... We can;t change the blocksize in a script that only does the .conf file. Or are you suggesting something else? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 17:45:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id EDDCED1B52E for ; Fri, 10 Oct 2003 20:45:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 02852-10 for ; Fri, 10 Oct 2003 17:44:22 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 54F30D1B528 for ; Fri, 10 Oct 2003 17:44:19 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750925; Fri, 10 Oct 2003 13:44:56 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Christopher Browne , pgsql-performance@postgresql.org Subject: Re: One or more processor ? Date: Fri, 10 Oct 2003 13:42:11 -0700 User-Agent: KMail/1.4.3 References: <200310101830.49608.herve@elma.fr> <6065ix3p39.fsf@dev6.int.libertyrms.info> In-Reply-To: <6065ix3p39.fsf@dev6.int.libertyrms.info> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101342.11317.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/366 X-Sequence-Number: 4114 Chris, > > If I do a SQL request ... does PostgreSQL use one or more processor ? > > Just one processor. For one query, yes. For multiple queries, PostgreSQL will use multiple processors, and that's what he's concerned about given his earlier posts. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 17:46:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2BC35D1B53B for ; Fri, 10 Oct 2003 20:46:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05214-01 for ; Fri, 10 Oct 2003 17:45:28 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id C8840D1B4EE for ; Fri, 10 Oct 2003 17:45:25 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3750964; Fri, 10 Oct 2003 13:46:03 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Bruce Momjian Subject: Re: further testing on IDE drives Date: Fri, 10 Oct 2003 13:43:17 -0700 User-Agent: KMail/1.4.3 Cc: "scott.marlowe" , Postgresql Performance References: <200310101839.h9AIdJn03045@candle.pha.pa.us> In-Reply-To: <200310101839.h9AIdJn03045@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310101343.17978.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/367 X-Sequence-Number: 4115 Bruce, > I would be interested to see if wal_sync_method = fsync is slower than > wal_sync_method = open_sync. How often are we doing more then one write > before a fsync anyway? OK. I'll see if I can get to it around my other stuff I have to do this weekend. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 17:49:53 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6657DD1B550 for ; Fri, 10 Oct 2003 20:49:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04790-04 for ; Fri, 10 Oct 2003 17:49:07 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 7E35FD1B4E3 for ; Fri, 10 Oct 2003 17:49:05 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id C61C03EB6 for ; Fri, 10 Oct 2003 16:49:07 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 83792-01-21 for ; Fri, 10 Oct 2003 16:49:07 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id E8D593EAF for ; Fri, 10 Oct 2003 16:49:06 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9AKn6CW002127 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 16:49:06 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: further testing on IDE drives Date: Fri, 10 Oct 2003 16:49:06 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 19 Message-ID: References: <200310101724.h9AHOTs24892@candle.pha.pa.us> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1065818946 37790 216.194.193.105 (10 Oct 2003 20:49:06 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 10 Oct 2003 20:49:06 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:T80+oWuac2+UQ7PTOsvmy2vaT1U= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/368 X-Sequence-Number: 4116 >>>>> "BM" == Bruce Momjian writes: >> Sounds reasonable to me. Are there many / any scenarios where a plain >> fsync would be faster than open_sync? BM> Yes. If you were doing multiple WAL writes before transaction fsync, BM> you would be fsyncing every write, rather than doing two writes and BM> fsync'ing them both. I wonder if larger transactions would find BM> open_sync slower? consider loading a large database from a backup dump. one big transaction during the COPY. I don't know the implications it has on this scenario, though. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Tue Oct 14 13:46:39 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B216BD1B550 for ; Fri, 10 Oct 2003 21:22:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13930-04 for ; Fri, 10 Oct 2003 18:21:53 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 17422D1B591 for ; Fri, 10 Oct 2003 18:21:11 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h9ALLAQh062820 for ; Fri, 10 Oct 2003 21: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 h9AL7duo060847 for pgsql-performance@postgresql.org; Fri, 10 Oct 2003 21:07:39 GMT From: "Relaxin" X-Newsgroups: comp.databases.postgresql.performance Subject: Re: One or more processor ? Date: Fri, 10 Oct 2003 14:03:51 -0700 Organization: Hub.Org Networking Services Lines: 10 Message-ID: References: <200310101830.49608.herve@elma.fr> <3F86E15C.1010309@potentialtech.com> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/454 X-Sequence-Number: 4202 > Do you know of any RDBMS that actually will execute a single query on > multiple processors? SQL Server does in a sense. It can split a query onto multiple threads (which could possible use multiple processors) and then brings the results from the threads into one and then sends the results to the client. From pgsql-general-owner@postgresql.org Fri Oct 10 18:13:20 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2F278D1B541; Fri, 10 Oct 2003 21:13:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05652-05; Fri, 10 Oct 2003 18:12:32 -0300 (ADT) Received: from seapdc01.PNTS (ip63.c216.blk1.bel.nwlink.com [209.20.216.63]) by svr1.postgresql.org (Postfix) with ESMTP id 8BE8CD1B528; Fri, 10 Oct 2003 18:12:29 -0300 (ADT) Received: from busbydev (BUSBY-DEV [10.0.0.17]) by seapdc01.PNTS with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TSH2QR5Q; Fri, 10 Oct 2003 14:31:55 -0700 Message-ID: <006a01c38f72$25461720$1100000a@busbydev> Reply-To: "David Busby" From: "David Busby" To: , Subject: Index/Foreign Key Question Date: Fri, 10 Oct 2003 14:04:51 -0700 Organization: Pacific Northwest Ticket Service 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.0 tagged_above=0.0 required=5.0 tests=BAYES_30, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200310/523 X-Sequence-Number: 50596 List, I'm creating this multi company POS database. My inventory table looks like (all items are unique): id,category_id,invoice_id,x,y,z,gid,uid I have a primary key on id, and then an foreign keys on category_id and invoice_id. GID is the group ID of the company, UID is the companies user, they are also connected via foreign key to the respective tables. My question is this: Do I need to create more indexes on this table when inventory selects look like select * from inventory where category_id = 1 and invoice_id is null and gid = 2 So where would the indexes need to be placed? Or since I have the FK setup are the indexes already in place? I expect to soon have >500K items in the inventory table and don't want it to slow down. I'll have the same type of issue with clients, invoices, purchase_orders and perhaps more Ideas? Thanks! David Busby Systems Engineer From pgsql-performance-owner@postgresql.org Fri Oct 10 18:15:29 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 63734D1B542 for ; Fri, 10 Oct 2003 21:15:25 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 05796-06 for ; Fri, 10 Oct 2003 18:14:40 -0300 (ADT) Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) by svr1.postgresql.org (Postfix) with ESMTP id 6607FD1B528 for ; Fri, 10 Oct 2003 18:14:38 -0300 (ADT) Received: by yertle.kcilink.com (Postfix, from userid 100) id 33F422178C; Fri, 10 Oct 2003 17:14:25 -0400 (EDT) From: Vivek Khera MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16263.8497.95525.673249@yertle.int.kciLink.com> Date: Fri, 10 Oct 2003 17:14:25 -0400 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL In-Reply-To: <200310101339.48392.josh@agliodbs.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F86F5BB.90605@chuckie.co.uk> <200310101339.48392.josh@agliodbs.com> X-Mailer: VM 7.14 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/370 X-Sequence-Number: 4118 >>>>> "JB" == Josh Berkus writes: JB> Vivek, NB> shared_buffers = 1/16th of total memory NB> effective_cache_size = 80% of the supposed kernel cache. >> >> Please take into account the blocksize compiled into PG, too... JB> We can;t change the blocksize in a script that only does the .conf JB> file. Or are you suggesting something else? when you compute optimal shared buffers and effective cache size, these are in terms of blocksize. so if I have 16k block size, you can't compute based on default 8k blocksize. at worst, it would have to be a parameter you pass to the tuning script. From pgsql-performance-owner@postgresql.org Fri Oct 10 18:24:04 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 35EFBD1B528 for ; Fri, 10 Oct 2003 21:24:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13280-06 for ; Fri, 10 Oct 2003 18:23:14 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 30F0DD1B4EA for ; Fri, 10 Oct 2003 18:23:11 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9ALMvo12903; Fri, 10 Oct 2003 17:22:57 -0400 (EDT) From: Bruce Momjian Message-Id: <200310102122.h9ALMvo12903@candle.pha.pa.us> Subject: Re: further testing on IDE drives In-Reply-To: To: Vivek Khera Date: Fri, 10 Oct 2003 17:22:57 -0400 (EDT) Cc: pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/371 X-Sequence-Number: 4119 Vivek Khera wrote: > >>>>> "BM" == Bruce Momjian writes: > > >> Sounds reasonable to me. Are there many / any scenarios where a plain > >> fsync would be faster than open_sync? > > BM> Yes. If you were doing multiple WAL writes before transaction fsync, > BM> you would be fsyncing every write, rather than doing two writes and > BM> fsync'ing them both. I wonder if larger transactions would find > BM> open_sync slower? > > consider loading a large database from a backup dump. one big > transaction during the COPY. I don't know the implications it has on > this scenario, though. COPY only does fsync on COPY completion, so I am not sure there are enough fsync's there to make a difference. -- 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-general-owner@postgresql.org Fri Oct 10 18:32:45 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6C6A1D1B541; Fri, 10 Oct 2003 21:32:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14800-03; Fri, 10 Oct 2003 18:31:55 -0300 (ADT) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1CE43D1B522; Fri, 10 Oct 2003 18:31:53 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031010213156.EJOS17519.lakemtao03.cox.net@lhosts>; Fri, 10 Oct 2003 17:31:56 -0400 Subject: Re: [PERFORM] Index/Foreign Key Question From: Ron Johnson To: PgSQL General ML , PgSQL Performance ML In-Reply-To: <006a01c38f72$25461720$1100000a@busbydev> References: <006a01c38f72$25461720$1100000a@busbydev> Content-Type: text/plain Message-Id: <1065821515.16433.10.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Fri, 10 Oct 2003 16:31:55 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/530 X-Sequence-Number: 50603 On Fri, 2003-10-10 at 16:04, David Busby wrote: > List, > I'm creating this multi company POS database. > My inventory table looks like (all items are unique): > > id,category_id,invoice_id,x,y,z,gid,uid > > I have a primary key on id, and then an foreign keys on category_id and > invoice_id. > GID is the group ID of the company, UID is the companies user, they are also > connected via foreign key to the respective tables. My question is this: Do > I need to create more indexes on this table when inventory selects look like > > select * from inventory where > category_id = 1 and invoice_id is null and gid = 2 > > So where would the indexes need to be placed? Or since I have the FK setup > are the indexes already in place? I expect to soon have >500K items in the > inventory table and don't want it to slow down. I'll have the same type of > issue with clients, invoices, purchase_orders and perhaps more I'd make a multi-segment (non-unique?) index on: GID CATEGORY_ID INVOICE_ID -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA LUKE: Is Perl better than Python? YODA: No... no... no. Quicker, easier, more seductive. LUKE: But how will I know why Python is better than Perl? YODA: You will know. When your code you try to read six months from now. From pgsql-performance-owner@postgresql.org Fri Oct 10 18:41:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 36E1AD1B4F2 for ; Fri, 10 Oct 2003 21:41:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 13873-10 for ; Fri, 10 Oct 2003 18:40:15 -0300 (ADT) Received: from seapdc01.PNTS (ip63.c216.blk1.bel.nwlink.com [209.20.216.63]) by svr1.postgresql.org (Postfix) with ESMTP id 94B7BD1B537 for ; Fri, 10 Oct 2003 18:40:12 -0300 (ADT) Received: from busbydev (BUSBY-DEV [10.0.0.17]) by seapdc01.PNTS with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TSH2QR75; Fri, 10 Oct 2003 14:59:34 -0700 Message-ID: <009c01c38f76$02150230$1100000a@busbydev> Reply-To: "David Busby" From: "David Busby" To: "PgSQL Performance ML" References: <006a01c38f72$25461720$1100000a@busbydev> <1065821515.16433.10.camel@haggis> Subject: Re: Index/Foreign Key Question Date: Fri, 10 Oct 2003 14:32:30 -0700 Organization: Pacific Northwest Ticket Service MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" 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: 200310/373 X-Sequence-Number: 4121 ----- Original Message ----- From: "Ron Johnson" > On Fri, 2003-10-10 at 16:04, David Busby wrote: > > List, > > I'm creating this multi company POS database. > > My inventory table looks like (all items are unique): > > > > id,category_id,invoice_id,x,y,z,gid,uid > > > > I have a primary key on id, and then an foreign keys on category_id and > > invoice_id. > > GID is the group ID of the company, UID is the companies user, they are also > > connected via foreign key to the respective tables. My question is this: Do > > I need to create more indexes on this table when inventory selects look like > > > > select * from inventory where > > category_id = 1 and invoice_id is null and gid = 2 > > > > So where would the indexes need to be placed? Or since I have the FK setup > > are the indexes already in place? I expect to soon have >500K items in the > > inventory table and don't want it to slow down. I'll have the same type of > > issue with clients, invoices, purchase_orders and perhaps more > > I'd make a multi-segment (non-unique?) index on: > GID > CATEGORY_ID > INVOICE_ID > So the multi column index would be better than the three individual indexes? Does PostgreSQL only pick one index per table on the select statements? What about the option of using schemas to segment the data? That would eliminate the GID column and help performance correct? It also means I have to make company_a.invoice and company_b.invoice tables huh? /B From pgsql-performance-owner@postgresql.org Fri Oct 10 18:51:52 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D884BD1B4EA for ; Fri, 10 Oct 2003 21:51:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14431-09 for ; Fri, 10 Oct 2003 18:51:08 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 5EC6DD1B4E9 for ; Fri, 10 Oct 2003 18:51:05 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3751258; Fri, 10 Oct 2003 14:51:41 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Vivek Khera Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Fri, 10 Oct 2003 14:49:00 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101339.48392.josh@agliodbs.com> <16263.8497.95525.673249@yertle.int.kciLink.com> In-Reply-To: <16263.8497.95525.673249@yertle.int.kciLink.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310101449.00893.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/374 X-Sequence-Number: 4122 Vivek, =20 > when you compute optimal shared buffers and effective cache size, > these are in terms of blocksize. so if I have 16k block size, you > can't compute based on default 8k blocksize. at worst, it would have > to be a parameter you pass to the tuning script. Oh, yes! Thank you.=20=20=20 --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 10 20:03:46 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4DC5BD1B4ED for ; Fri, 10 Oct 2003 23:03:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23196-08 for ; Fri, 10 Oct 2003 20:02:58 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 8B694D1B53E for ; Fri, 10 Oct 2003 20:02:54 -0300 (ADT) 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 h9AN28GQ027281; Fri, 10 Oct 2003 17:02:09 -0600 (MDT) Date: Fri, 10 Oct 2003 16:52:59 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: Bruce Momjian , Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: <200310101044.21177.josh@agliodbs.com> 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: 200310/376 X-Sequence-Number: 4124 On Fri, 10 Oct 2003, Josh Berkus wrote: > Bruce, > > > Yes. If you were doing multiple WAL writes before transaction fsync, > > you would be fsyncing every write, rather than doing two writes and > > fsync'ing them both. I wonder if larger transactions would find > > open_sync slower? > > Want me to test? I've got an ide-based test machine here, and the TPCC > databases. OK, I decided to do a quick dirty test of things that are big transactions in each mode my kernel supports. I did this: createdb dbname time pg_dump -O -h otherserver dbname|psql dbname then I would drop the db, edit postgresql.conf, and restart the server. open_sync was WAY faster at this than the other two methods. open_sync: 1st run: real 11m27.107s user 0m26.570s sys 0m1.150s 2nd run: real 6m5.712s user 0m26.700s sys 0m1.700s fsync: 1st run: real 15m8.127s user 0m26.710s sys 0m0.990s 2nd run: real 15m8.396s user 0m26.990s sys 0m1.870s fdatasync: 1st run: real 15m47.878s user 0m26.570s sys 0m1.480s 2nd run: real 15m9.402s user 0m27.000s sys 0m1.660s I did the first runs in order, then started over, i.e. opensync run1, fsync run1, fdatasync run1, opensync run2, etc... The machine I was restoring to was under no other load. The machine I was reading from had little or no load, but is a production server, so it's possible the load there could have had a small effect, but probably not this big of a one. The machine this is one is setup so that the data partition is on a drive with write cache enabled, but the pg_xlog and pg_clog directories are on a drive with write cache disabled. Same drive models as listed before in my previous test, Seagate generic 80gig IDE drives, model ST380023A. From pgsql-performance-owner@postgresql.org Fri Oct 10 20:00:13 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 31B9BD1B4EA for ; Fri, 10 Oct 2003 23:00:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 25023-07 for ; Fri, 10 Oct 2003 19:59:25 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 34359D1B4EE for ; Fri, 10 Oct 2003 19:59:22 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 69B4A2105E; Fri, 10 Oct 2003 15:59:24 -0700 (PDT) Date: Fri, 10 Oct 2003 15:59:24 -0700 From: Sean Chittenden To: Vivek Khera Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031010225924.GC8664@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/375 X-Sequence-Number: 4123 > NB> So far: > > NB> shared_buffers = 1/16th of total memory > NB> effective_cache_size = 80% of the supposed kernel cache. > > Please take into account the blocksize compiled into PG, too... Would anyone object to a patch that exports the blocksize via a readonly GUC? Too many tunables are page dependant, which is infuriating when copying configs from DB to DB. I wish pgsql had some notion of percentages for values that end with a '%'. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Fri Oct 10 21:24:34 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 88345D1B4FD for ; Sat, 11 Oct 2003 00:24:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 35198-04 for ; Fri, 10 Oct 2003 21:23:46 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 715BDD1B4EF for ; Fri, 10 Oct 2003 21:23:43 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 95B6F35203; Fri, 10 Oct 2003 17:23:31 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 943383514B; Fri, 10 Oct 2003 17:23:31 -0700 (PDT) Date: Fri, 10 Oct 2003 17:23:31 -0700 (PDT) From: Stephan Szabo To: David Busby Cc: PgSQL Performance ML Subject: Re: Index/Foreign Key Question In-Reply-To: <009c01c38f76$02150230$1100000a@busbydev> Message-ID: <20031010171953.B18529@megazone.bigpanda.com> References: <006a01c38f72$25461720$1100000a@busbydev> <1065821515.16433.10.camel@haggis> <009c01c38f76$02150230$1100000a@busbydev> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/377 X-Sequence-Number: 4125 On Fri, 10 Oct 2003, David Busby wrote: > ----- Original Message ----- > From: "Ron Johnson" > > On Fri, 2003-10-10 at 16:04, David Busby wrote: > > > List, > > > I'm creating this multi company POS database. > > > My inventory table looks like (all items are unique): > > > > > > id,category_id,invoice_id,x,y,z,gid,uid > > > > > > I have a primary key on id, and then an foreign keys on category_id and > > > invoice_id. > > > GID is the group ID of the company, UID is the companies user, they are > also > > > connected via foreign key to the respective tables. My question is > this: Do > > > I need to create more indexes on this table when inventory selects look > like > > > > > > select * from inventory where > > > category_id = 1 and invoice_id is null and gid = 2 > > > > > > So where would the indexes need to be placed? Or since I have the FK > setup > > > are the indexes already in place? I expect to soon have >500K items in > the > > > inventory table and don't want it to slow down. I'll have the same type > of > > > issue with clients, invoices, purchase_orders and perhaps more > > > > I'd make a multi-segment (non-unique?) index on: > > GID > > CATEGORY_ID > > INVOICE_ID > > > > So the multi column index would be better than the three individual indexes? For the query in question, yes. However, you probably want a category_id index and an invoice_id index if you are going to change the related tables because the (gid, category_id, invoice_id) isn't good enough for the foreign key checks (and the fk columns aren't automatically indexed because it can easily become a pessimization depending on the workload that's being done). From pgsql-performance-owner@postgresql.org Fri Oct 10 22:50:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 07DBED1B537 for ; Sat, 11 Oct 2003 01:50:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53818-01 for ; Fri, 10 Oct 2003 22:49:17 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 07F96D1B531 for ; Fri, 10 Oct 2003 22:49:12 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9B1n5905115; Fri, 10 Oct 2003 21:49:05 -0400 (EDT) From: Bruce Momjian Message-Id: <200310110149.h9B1n5905115@candle.pha.pa.us> Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL In-Reply-To: <20031010225924.GC8664@perrin.nxad.com> To: Sean Chittenden Date: Fri, 10 Oct 2003 21:49:05 -0400 (EDT) Cc: Vivek Khera , pgsql-performance@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/378 X-Sequence-Number: 4126 Sean Chittenden wrote: > > NB> So far: > > > > NB> shared_buffers = 1/16th of total memory > > NB> effective_cache_size = 80% of the supposed kernel cache. > > > > Please take into account the blocksize compiled into PG, too... > > Would anyone object to a patch that exports the blocksize via a > readonly GUC? Too many tunables are page dependant, which is > infuriating when copying configs from DB to DB. I wish pgsql had some > notion of percentages for values that end with a '%'. -sc Makes sense to me --- we already have some read-only GUC variables. -- 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 Fri Oct 10 22:55:36 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D458CD1B529 for ; Sat, 11 Oct 2003 01:55:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 53678-03 for ; Fri, 10 Oct 2003 22:54:51 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id A5C6AD1B549 for ; Fri, 10 Oct 2003 22:54:47 -0300 (ADT) Received: (qmail 7009 invoked from network); 11 Oct 2003 01:54:51 -0000 Received: from unknown (HELO ?192.168.1.199?) (134.22.69.154) by 205.178.180.9 with SMTP; 11 Oct 2003 01:54:51 -0000 Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL From: Rod Taylor To: Sean Chittenden Cc: Vivek Khera , Postgresql Performance In-Reply-To: <20031010225924.GC8664@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <20031010225924.GC8664@perrin.nxad.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-rNA2OK2rGeTZoh4whapq" Message-Id: <1065837333.12875.1.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 10 Oct 2003 21:55:34 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/379 X-Sequence-Number: 4127 --=-rNA2OK2rGeTZoh4whapq Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Fri, 2003-10-10 at 18:59, Sean Chittenden wrote: > > NB> So far: > >=20 > > NB> shared_buffers =3D 1/16th of total memory > > NB> effective_cache_size =3D 80% of the supposed kernel cache. > >=20 > > Please take into account the blocksize compiled into PG, too... >=20 > Would anyone object to a patch that exports the blocksize via a > readonly GUC? Too many tunables are page dependant, which is > infuriating when copying configs from DB to DB. I wish pgsql had some > notion of percentages for values that end with a '%'. Rather than showing the block size, how about we change the tunables to be physical sizes rather than block based? effective_cache_size =3D 1.5GB shared_buffers =3D 25MB Percentages would be slick as well, but doing the above should fix most of the issue -- and be friendlier to read. --=-rNA2OK2rGeTZoh4whapq Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/h2MV6DETLow6vwwRArg5AJ9OnAlnLPtk4Nua+zUgBCLUUGiscACdF/ZR vpySO7LXPMhdrmTznWEqOsA= =eYRm -----END PGP SIGNATURE----- --=-rNA2OK2rGeTZoh4whapq-- From pgsql-performance-owner@postgresql.org Fri Oct 10 23:01:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5A499D1B56F for ; Sat, 11 Oct 2003 02:01:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 54572-02 for ; Fri, 10 Oct 2003 23:01:12 -0300 (ADT) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by svr1.postgresql.org (Postfix) with ESMTP id 33458D1B4E3 for ; Fri, 10 Oct 2003 23:01:08 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031011020112.HGJW17519.lakemtao03.cox.net@lhosts> for ; Fri, 10 Oct 2003 22:01:12 -0400 Subject: Re: Index/Foreign Key Question From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <009c01c38f76$02150230$1100000a@busbydev> References: <006a01c38f72$25461720$1100000a@busbydev> <1065821515.16433.10.camel@haggis> <009c01c38f76$02150230$1100000a@busbydev> Content-Type: text/plain Message-Id: <1065837672.16433.23.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Fri, 10 Oct 2003 21:01:12 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/380 X-Sequence-Number: 4128 On Fri, 2003-10-10 at 16:32, David Busby wrote: > ----- Original Message ----- > From: "Ron Johnson" > > On Fri, 2003-10-10 at 16:04, David Busby wrote: > > > List, > > > I'm creating this multi company POS database. > > > My inventory table looks like (all items are unique): > > > > > > id,category_id,invoice_id,x,y,z,gid,uid > > > > > > I have a primary key on id, and then an foreign keys on category_id and > > > invoice_id. > > > GID is the group ID of the company, UID is the companies user, they are > also > > > connected via foreign key to the respective tables. My question is > this: Do > > > I need to create more indexes on this table when inventory selects look > like > > > > > > select * from inventory where > > > category_id = 1 and invoice_id is null and gid = 2 > > > > > > So where would the indexes need to be placed? Or since I have the FK > setup > > > are the indexes already in place? I expect to soon have >500K items in > the > > > inventory table and don't want it to slow down. I'll have the same type > of > > > issue with clients, invoices, purchase_orders and perhaps more > > > > I'd make a multi-segment (non-unique?) index on: > > GID > > CATEGORY_ID > > INVOICE_ID > > > > So the multi column index would be better than the three individual indexes? Yes, because it more closely matches the WHERE clause. Otherwise, it would have to look thru all three indexes, comparing OIDs. > Does PostgreSQL only pick one index per table on the select statements? That's it's preference. > What about the option of using schemas to segment the data? That would > eliminate the GID column and help performance correct? It also means I have > to make company_a.invoice and company_b.invoice tables huh? Yes, any time you add or alter a table, you'd have to do it on all the schemas. However, multiple schemas would protect each company's data from the other, and if the table structures are stable the maintenance costs are low. Also, you could script the mods, to reduce the work even more. Also, you could have multiple databases. This isn't Oracle, so have as many as you want. The benefit of this method is scalability. I.e., if the load grows too high, just buy another box, and move 1/2 the databases to it. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "Our computers and their computers are the same color. The conversion should be no problem!" Unknown From pgsql-performance-owner@postgresql.org Sat Oct 11 02:21:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AC57AD1B4E3 for ; Sat, 11 Oct 2003 05:21:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 76550-10 for ; Sat, 11 Oct 2003 02:20:53 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id AC074D1B4EA for ; Sat, 11 Oct 2003 02:20:46 -0300 (ADT) Received: from [203.221.127.74] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8CBH-0005nB-00; Sat, 11 Oct 2003 15:20:43 +1000 Message-ID: <3F87932B.4050507@familyhealth.com.au> Date: Sat, 11 Oct 2003 13:20:43 +0800 From: Christopher Kings-Lynne 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: Vivek Khera Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> 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: 200310/381 X-Sequence-Number: 4129 > NB> shared_buffers = 1/16th of total memory > NB> effective_cache_size = 80% of the supposed kernel cache. I think Sean(?) mentioned this one for FreeBSD (Bash code): echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" I've used it for my dedicated servers. Is this calculation correct? Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 06:23:58 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2E014D1B50E for ; Sat, 11 Oct 2003 09:23:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23902-06 for ; Sat, 11 Oct 2003 06:23:13 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 29A3BD1B4FC for ; Sat, 11 Oct 2003 06:23:07 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 978FD21066; Sat, 11 Oct 2003 02:23:08 -0700 (PDT) Date: Sat, 11 Oct 2003 02:23:08 -0700 From: Sean Chittenden To: Christopher Kings-Lynne Cc: Vivek Khera , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031011092308.GA39942@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <3F87932B.4050507@familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F87932B.4050507@familyhealth.com.au> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/382 X-Sequence-Number: 4130 > >NB> shared_buffers = 1/16th of total memory > >NB> effective_cache_size = 80% of the supposed kernel cache. > > I think Sean(?) mentioned this one for FreeBSD (Bash code): sh, not bash. :) > echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" > > I've used it for my dedicated servers. Is this calculation correct? Yes, or it's real close at least. vfs.hibufspace is the amount of kernel space that's used for caching IO operations (minus the necessary space taken for the kernel). If you're real paranoid, you could do some kernel profiling and figure out how much of the cache is actually disk IO and multiply the above by some percentage, say 80%? I haven't found it necessary to do so yet. Since hibufspace is all IO and caching any net activity is kinda pointless and I assume that 100% of it is used for a disk cache and don't use a multiplier. The 8192, however, is the size of a PG page, so, if you tweak PG's page size, you have to change this constant (*grumbles*). -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Sat Oct 11 06:43:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 72A95D1B511; Sat, 11 Oct 2003 09:43:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32918-01; Sat, 11 Oct 2003 06:42:52 -0300 (ADT) Received: from mta02-svc.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by svr1.postgresql.org (Postfix) with ESMTP id E1F03D1B50E; Sat, 11 Oct 2003 06:42:45 -0300 (ADT) Received: from elliott ([81.99.97.206]) by mta02-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with SMTP id <20031011094253.JFKS16630.mta02-svc.ntlworld.com@elliott>; Sat, 11 Oct 2003 10:42:53 +0100 From: "Chris Faulkner" To: "Pgsql-Performance" , "Pgsql-Sql" Subject: sql performance and cache Date: Sat, 11 Oct 2003 10:43:04 +0100 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) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/383 X-Sequence-Number: 4131 Hello all I have two very similar queries which I need to execute. They both have exactly the same from / where conditions. When I execute the first, it takes about 16 seconds. The second is executed almost immediately after, it takes 13 seconds. In short, I'd like to know why the query result isn't being cached and any ideas on how to improve the execution. The first query attempts to find the maximum size of an array in the result set- the field is called "level". IT contains anything between 1 and 10 integers. I just need to know what the largest size is. I do this to find out the maximum size of the "level" array. "max(replace(split_part(array_dims(level),':',2),']','')::int)" I know this is big and ugly but is there any better way of doing it ? The second query just returns the result set - it has exactly the same FROM/Where clause. OK - so I could execute the query once, and get the maximum size of the array and the result set in one. I know what I am doing is less than optimal but I had expected the query results to be cached. So the second execution would be very quick. So why aren't they ? I have increased my cache size - shared_buffers is 2000 and I have doubled the default max_fsm... settings (although I am not sure what they do). sort_mem is 8192. The from / where is FROM oscar_node N, oscar_point P where N."GEOM_ID_OF_POINT" = P."POINT_ID" and N."TILE_REF" = P."TILE_REF" and N."TILE_REF" in ('TQ27NE','TQ28SE','TQ37NW','TQ38SW') and P."TILE_REF" in ('TQ27NE','TQ28SE','TQ37NW','TQ38SW') and P."FEAT_CODE" = 3500 and P.wkb_geometry && GeometryFromText('BOX3D(529540.0 179658.88,530540.0 180307.12)'::box3d,-1) oscar_node and oscar_point both have about 3m rows. PK on oscar_node is composite of "TILE_REF" and "NODE_ID". PK on oscar_point is "TILE_REF" and "POINT_ID". The tables are indexed on feat_code and I have an index on wkb_geometry. (This is a GIST index). I have increased the statistics size and done the analyze command. Here is my explain plan Nested Loop (cost=0.00..147.11 rows=1 width=148) Join Filter: ("inner"."GEOM_ID_OF_POINT" = "outer"."POINT_ID") -> Index Scan using gidx_oscar_point on oscar_point p (cost=0.00..61.34 rows=1 width=57) Index Cond: (wkb_geometry && 'SRID=-1;BOX3D(529540 179658.88 0,530540 180307.12 0)'::geometry) Filter: ((("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = 'TQ28SE'::bpchar) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = 'TQ38SW'::bpchar)) AND ("FEAT_CODE" = 3500)) -> Index Scan using idx_on_tile_ref on oscar_node n (cost=0.00..85.74 rows=2 width=91) Index Cond: (n."TILE_REF" = "outer"."TILE_REF") Filter: (("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = 'TQ28SE'::bpchar) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = 'TQ38SW'::bpchar)) I am seeing this message in my logs. "bt_fixroot: not valid old root page" Maybe this is relevant to my performance problems. I know this has been a long message but I would really appreciate any performance tips. Thanks Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 07:12:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 919A6D1B50D; Sat, 11 Oct 2003 10:12:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31948-06; Sat, 11 Oct 2003 07:12:00 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id AFC19D1B516; Sat, 11 Oct 2003 07:11:52 -0300 (ADT) Received: from [203.221.127.74] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8Gj6-0001IU-00; Sat, 11 Oct 2003 20:11:56 +1000 Message-ID: <3F87D764.8030306@familyhealth.com.au> Date: Sat, 11 Oct 2003 18:11:48 +0800 From: Christopher Kings-Lynne 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: Chris Faulkner Cc: Pgsql-Performance , Pgsql-Sql Subject: Re: sql performance and cache 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: 200310/384 X-Sequence-Number: 4132 > I have two very similar queries which I need to execute. They both have > exactly the same from / where conditions. When I execute the first, it takes > about 16 seconds. The second is executed almost immediately after, it takes > 13 seconds. In short, I'd like to know why the query result isn't being > cached and any ideas on how to improve the execution. > OK - so I could execute the query once, and get the maximum size of the > array and the result set in one. I know what I am doing is less than optimal > but I had expected the query results to be cached. So the second execution > would be very quick. So why aren't they ? I have increased my cache size - > shared_buffers is 2000 and I have doubled the default max_fsm... settings > (although I am not sure what they do). sort_mem is 8192. PostgreSQL does not have, and has never had a query cache - so nothing you do is going to make that second query faster. Perhaps you are confusing it with the MySQL query cache? Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 07:17:23 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id F3AE7D1B516 for ; Sat, 11 Oct 2003 10:17:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 31948-08 for ; Sat, 11 Oct 2003 07:16:42 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 68022D1B50D for ; Sat, 11 Oct 2003 07:16:35 -0300 (ADT) Received: from [203.221.127.74] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8Gnj-0001TJ-00; Sat, 11 Oct 2003 20:16:43 +1000 Message-ID: <3F87D883.2000206@familyhealth.com.au> Date: Sat, 11 Oct 2003 18:16:35 +0800 From: Christopher Kings-Lynne 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: Christopher Kings-Lynne Cc: Chris Faulkner , Pgsql-Performance Subject: Re: sql performance and cache References: <3F87D764.8030306@familyhealth.com.au> In-Reply-To: <3F87D764.8030306@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: 200310/385 X-Sequence-Number: 4133 > PostgreSQL does not have, and has never had a query cache - so nothing > you do is going to make that second query faster. Let me clarify that. PostgreSQL will of course cache the disk pages used in getting the data for your query, which is why the second time you run it, it is 3 seconds faster. However, it does not cache the _results_ of the query. Each time you run it, it will be fully re-evaluated. The btree error you give is bad and I'm sure the more experienced list members will want you to dig into it for them. Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 07:22:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AAD80D1B4E3 for ; Sat, 11 Oct 2003 10:22:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 24197-10 for ; Sat, 11 Oct 2003 07:21:51 -0300 (ADT) Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by svr1.postgresql.org (Postfix) with ESMTP id AF3B8D1B4FC for ; Sat, 11 Oct 2003 07:21:43 -0300 (ADT) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A8Gsb-00012r-00 for ; Sat, 11 Oct 2003 12:21:45 +0200 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 1A8GsY-00012j-00 for ; Sat, 11 Oct 2003 12:21:42 +0200 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1A8GsY-0004Zr-00 for ; Sat, 11 Oct 2003 12:21:42 +0200 From: Harald Fuchs Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: 11 Oct 2003 12:22:42 +0200 Organization: Linux Private Site Lines: 16 Message-ID: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <20031010225924.GC8664@perrin.nxad.com> <1065837333.12875.1.camel@jester> Reply-To: hf99@protecting.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-No-Archive: yes User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/386 X-Sequence-Number: 4134 In article <1065837333.12875.1.camel@jester>, Rod Taylor writes: >> Would anyone object to a patch that exports the blocksize via a >> readonly GUC? Too many tunables are page dependant, which is >> infuriating when copying configs from DB to DB. I wish pgsql had some >> notion of percentages for values that end with a '%'. > Rather than showing the block size, how about we change the tunables to > be physical sizes rather than block based? > effective_cache_size = 1.5GB > shared_buffers = 25MB Amen! Being forced to set config values in some obscure units rather than bytes is an ugly braindamage which should be easy to fix. From pgsql-performance-owner@postgresql.org Sat Oct 11 07:39:55 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 06E25D1B510; Sat, 11 Oct 2003 10:39:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40400-02; Sat, 11 Oct 2003 07:39:11 -0300 (ADT) 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 C45FBD1B522; Sat, 11 Oct 2003 07:39:04 -0300 (ADT) 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 1A8H9U-000BwU-0Z; Sat, 11 Oct 2003 11:39:12 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 157DF17924; Sat, 11 Oct 2003 11:39:11 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 47558178E2; Sat, 11 Oct 2003 11:39:10 +0100 (BST) From: Richard Huxton To: "Chris Faulkner" , "Pgsql-Performance" , "Pgsql-Sql" Subject: Re: [SQL] sql performance and cache Date: Sat, 11 Oct 2003 11:39:10 +0100 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310111139.10326.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/387 X-Sequence-Number: 4135 On Saturday 11 October 2003 10:43, Chris Faulkner wrote: > Hello all > > I have two very similar queries which I need to execute. They both have > exactly the same from / where conditions. When I execute the first, it > takes about 16 seconds. The second is executed almost immediately after, it > takes 13 seconds. In short, I'd like to know why the query result isn't > being cached and any ideas on how to improve the execution. The short answer is that PG doesn't cache query results. The only way it could do so safely is to lock all tables you access to make sure that no other process changes them. That would effectively turn PG into a single-user DB in short notice. > The first query attempts to find the maximum size of an array in the result > set- the field is called "level". IT contains anything between 1 and 10 > integers. I just need to know what the largest size is. I do this to find > out the maximum size of the "level" array. > > "max(replace(split_part(array_dims(level),':',2),']','')::int)" > > I know this is big and ugly but is there any better way of doing it ? > > The second query just returns the result set - it has exactly the same > FROM/Where clause. I assume these two queries are linked? If you rely on the max size being unchanged and have more than one process using the database, you should make sure you lock the rows in question. > OK - so I could execute the query once, and get the maximum size of the > array and the result set in one. I know what I am doing is less than > optimal but I had expected the query results to be cached. So the second > execution would be very quick. So why aren't they ? I have increased my > cache size - shared_buffers is 2000 and I have doubled the default > max_fsm... settings (although I am not sure what they do). sort_mem is > 8192. PG will cache the underlying data, but not the results. The values you are changing are used to hold table/index rows etc. This means the second query shouldn't need to access the disk if the rows it requires are cached. There is a discussion of the postgresql.conf file and how to tune it at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php Given the explain attached, 16 secs seems slow. Could you post an EXPLAIN ANALYSE of either/both queries to the performance list. I'd drop the sql list when we're just talking about performance. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Sat Oct 11 07:44:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 46E7AD1B51C for ; Sat, 11 Oct 2003 10:44:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40856-01 for ; Sat, 11 Oct 2003 07:43:31 -0300 (ADT) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by svr1.postgresql.org (Postfix) with ESMTP id 0579ED1B519 for ; Sat, 11 Oct 2003 07:43:24 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031011104327.JTFN17519.lakemtao03.cox.net@lhosts> for ; Sat, 11 Oct 2003 06:43:27 -0400 Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <20031010225924.GC8664@perrin.nxad.com> <1065837333.12875.1.camel@jester> Content-Type: text/plain Message-Id: <1065869007.24193.45.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Sat, 11 Oct 2003 05:43:27 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/388 X-Sequence-Number: 4136 On Sat, 2003-10-11 at 05:22, Harald Fuchs wrote: > In article <1065837333.12875.1.camel@jester>, > Rod Taylor writes: > > >> Would anyone object to a patch that exports the blocksize via a > >> readonly GUC? Too many tunables are page dependant, which is > >> infuriating when copying configs from DB to DB. I wish pgsql had some > >> notion of percentages for values that end with a '%'. > > > Rather than showing the block size, how about we change the tunables to > > be physical sizes rather than block based? > > > effective_cache_size = 1.5GB > > shared_buffers = 25MB > > Amen! Being forced to set config values in some obscure units rather > than bytes is an ugly braindamage which should be easy to fix. But it's too user-friendly to do it this way! -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA When Swedes start committing terrorism, I'll become suspicious of Scandanavians. From pgsql-performance-owner@postgresql.org Sat Oct 11 08:12:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2FE02D1B4E3; Sat, 11 Oct 2003 11:12:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32043-10; Sat, 11 Oct 2003 08:11:49 -0300 (ADT) Received: from mta06-svc.ntlworld.com (mta06-svc.ntlworld.com [62.253.162.46]) by svr1.postgresql.org (Postfix) with ESMTP id A67FDD1B516; Sat, 11 Oct 2003 08:11:41 -0300 (ADT) Received: from elliott ([81.99.97.206]) by mta06-svc.ntlworld.com (InterMail vM.4.01.03.37 201-229-121-137-20020806) with SMTP id <20031011111149.KNJE12263.mta06-svc.ntlworld.com@elliott>; Sat, 11 Oct 2003 12:11:49 +0100 From: "Chris Faulkner" To: "Pgsql-Performance" , "Pgsql-Sql" Subject: Re: [SQL] sql performance and cache Date: Sat, 11 Oct 2003 12:12:01 +0100 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) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal In-Reply-To: <200310111139.10326.dev@archonet.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/389 X-Sequence-Number: 4137 Hello Thanks for the reply. > The short answer is that PG doesn't cache query results. The only > way it could > do so safely is to lock all tables you access to make sure that no other > process changes them. That would effectively turn PG into a > single-user DB in > short notice. I am not sure I agree with you. I have done similar things with Oracle and found that the second query will execute much more quickly than the first. It could be made to work in at least two scenarios - as a user/application perspective - you accept that the result might not be up-to-date and take what comes back. This would be acceptable in my case because I know that the tables will not change. OR - the database could cache the result set. If some of the data is changed by another query or session, then the database flushes the result set out of the cache. > I assume these two queries are linked? If you rely on the max size being > unchanged and have more than one process using the database, you > should make > sure you lock the rows in question. I can rely on the max size remaining the same. As I mentioned above, the tables are entirely read only. The data will not be updated or deleted by anyone - I don't need to worry about that. The data will be updated en masse once every 3 months. > There is a discussion of the postgresql.conf file and how to tune it at: > http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php Thanks for that. > Given the explain attached, 16 secs seems slow. Could you post an EXPLAIN > ANALYSE of either/both queries to the performance list. I'd drop > the sql list > when we're just talking about performance. To be honest, my main concern was about the cache. If the second one could use a cache amd execute in 2 seconds, that would be better that reducing the execution of each individual query by 30% or so. Thanks for the offer of help on this one. explain analyze gives me the same as the last message - did you want verbose ? Nested Loop (cost=0.00..147.11 rows=1 width=148) (actual time=84.00..12323.00 rows=67 loops=1) Join Filter: ("inner"."GEOM_ID_OF_POINT" = "outer"."POINT_ID") -> Index Scan using gidx_oscar_point on oscar_point p (cost=0.00..61.34 rows=1 width=57) (actual time=0.00..9.00 rows=67 loops=1) Index Cond: (wkb_geometry && 'SRID=-1;BOX3D(529540 179658.88 0,530540 1 80307.12 0)'::geometry) Filter: ((("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = 'TQ28SE'::bp char) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = 'TQ38SW'::bpchar)) AND ("FEAT_CODE" = 3500)) -> Index Scan using idx_on_tile_ref on oscar_node n (cost=0.00..85.74 rows=2 width=91) (actual time=0.06..150.07 rows=4797 loops=67) Index Cond: (n."TILE_REF" = "outer"."TILE_REF") Filter: (("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = 'TQ28SE'::bpchar) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = 'TQ38SW'::bpchar)) Total runtime: 12325.00 msec (9 rows) Thanks Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 08:27:14 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A90E5D1B511; Sat, 11 Oct 2003 11:27:11 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33180-09; Sat, 11 Oct 2003 08:26:31 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 479CCD1B529; Sat, 11 Oct 2003 08:26:24 -0300 (ADT) Received: from [203.221.127.74] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8HtI-00045d-00; Sat, 11 Oct 2003 21:26:33 +1000 Message-ID: <3F87E8DF.5080608@familyhealth.com.au> Date: Sat, 11 Oct 2003 19:26:23 +0800 From: Christopher Kings-Lynne 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: Chris Faulkner Cc: Pgsql-Performance , Pgsql-Sql Subject: Re: [SQL] sql performance and cache 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: 200310/390 X-Sequence-Number: 4138 > Nested Loop (cost=0.00..147.11 rows=1 width=148) (actual > time=84.00..12323.00 rows=67 loops=1) The planner estimate doesn't seem to match reality in that particular step. Are you sure you've run: ANALYZE oscar_node; ANALYZE oscar_point; And you could even run VACUUM FULL on them just to make sure. Does that make any difference? Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 08:27:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C7D7ED1B522 for ; Sat, 11 Oct 2003 11:27:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40172-08 for ; Sat, 11 Oct 2003 08:26:34 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 5F573D1B4E3 for ; Sat, 11 Oct 2003 08:26:26 -0300 (ADT) Received: from [203.221.127.74] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8HtO-00045i-00; Sat, 11 Oct 2003 21:26:38 +1000 Message-ID: <3F87E8E5.1000203@familyhealth.com.au> Date: Sat, 11 Oct 2003 19:26:29 +0800 From: Christopher Kings-Lynne 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: Chris Faulkner Cc: Pgsql-Performance Subject: Re: [SQL] sql performance and cache 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: 200310/391 X-Sequence-Number: 4139 > Nested Loop (cost=0.00..147.11 rows=1 width=148) (actual > time=84.00..12323.00 rows=67 loops=1) The planner estimate doesn't seem to match reality in that particular step. Are you sure you've run: ANALYZE oscar_node; ANALYZE oscar_point; And you could even run VACUUM FULL on them just to make sure. Does that make any difference? Chris From pgsql-performance-owner@postgresql.org Sat Oct 11 08:56:16 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CB503D1B51C; Sat, 11 Oct 2003 11:56:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48933-02; Sat, 11 Oct 2003 08:55:31 -0300 (ADT) 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 6EDE6D1B4E3; Sat, 11 Oct 2003 08:55:24 -0300 (ADT) 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 1A8ILM-0007ji-0X; Sat, 11 Oct 2003 12:55:32 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 1949117924; Sat, 11 Oct 2003 12:55:31 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 59A9D16961; Sat, 11 Oct 2003 12:55:30 +0100 (BST) From: Richard Huxton To: "Chris Faulkner" , "Pgsql-Performance" , "Pgsql-Sql" Subject: Re: [SQL] sql performance and cache Date: Sat, 11 Oct 2003 12:55:08 +0100 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200310111255.08777.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/392 X-Sequence-Number: 4140 On Saturday 11 October 2003 12:12, Chris Faulkner wrote: > Hello > > Thanks for the reply. > > > The short answer is that PG doesn't cache query results. The only > > way it could > > do so safely is to lock all tables you access to make sure that no other > > process changes them. That would effectively turn PG into a > > single-user DB in > > short notice. > > I am not sure I agree with you. I have done similar things with Oracle and > found that the second query will execute much more quickly than the first. > It could be made to work in at least two scenarios I'm guessing because the underlying rows and perhaps the plan are cached, rather than the results. If you cached the results of the first query you'd only have the max length, not your other data anyway. [snip] > > I assume these two queries are linked? If you rely on the max size being > > unchanged and have more than one process using the database, you > > should make > > sure you lock the rows in question. > > I can rely on the max size remaining the same. As I mentioned above, the > tables are entirely read only. The data will not be updated or deleted by > anyone - I don't need to worry about that. The data will be updated en > masse once every 3 months. Hmm - might be worth adding a column for your array length and pre-calculating if your data is basically static. > > There is a discussion of the postgresql.conf file and how to tune it at: > > http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > > Thanks for that. > > > Given the explain attached, 16 secs seems slow. Could you post an EXPLAIN > > ANALYSE of either/both queries to the performance list. I'd drop > > the sql list > > when we're just talking about performance. > > To be honest, my main concern was about the cache. If the second one could > use a cache amd execute in 2 seconds, that would be better that reducing > the execution of each individual query by 30% or so. I'm puzzled as to why they aren't both below 2 seconds to start with - you're not dealing with that many rows. > Thanks for the offer of help on this one. explain analyze gives me the same > as the last message - did you want verbose ? Nope, this is what I need. Verbose prints pages of stuff that only the developers would be interested in. This one actually runs the query and gives you a second set of figures showing times. > Nested Loop (cost=0.00..147.11 rows=1 width=148) (actual > time=84.00..12323.00 rows=67 loops=1) > Join Filter: ("inner"."GEOM_ID_OF_POINT" = "outer"."POINT_ID") > -> Index Scan using gidx_oscar_point on oscar_point p > (cost=0.00..61.34 rows=1 width=57) (actual time=0.00..9.00 rows=67 loops=1) > Index Cond: (wkb_geometry && 'SRID=-1;BOX3D(529540 179658.88 > 0,530540 1 > 80307.12 0)'::geometry) > Filter: ((("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = > 'TQ28SE'::bp > char) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = > 'TQ38SW'::bpchar)) AND > ("FEAT_CODE" = 3500)) This next bit is the issue. It's joining on TILE_REF and then filtering by your three static values. That's taking 67 * 150ms = 10.05secs > -> Index Scan using idx_on_tile_ref on oscar_node n (cost=0.00..85.74 > rows=2 width=91) (actual time=0.06..150.07 rows=4797 loops=67) > Index Cond: (n."TILE_REF" = "outer"."TILE_REF") > Filter: (("TILE_REF" = 'TQ27NE'::bpchar) OR ("TILE_REF" = > 'TQ28SE'::bpchar) OR ("TILE_REF" = 'TQ37NW'::bpchar) OR ("TILE_REF" = > 'TQ38SW'::bpchar)) Now if you look at the first set of figures, it's estimating 2 rows rather than the 4797 you're actually getting. That's probably why it's chosen to join then filter rather than the other way around. I'd suggest the following: 1. VACUUM FULL on the table in question if you haven't done so since the last update/reload. If you aren't doing this after every bulk upload, you probably should be. 2. VACUUM ANALYSE/ANALYSE the table. 3. Check the tuning document I mentioned and make sure your settings are at least reasonable. They don't have to be perfect - that last 10% takes forever, but if they are badly wrong it can cripple you. 4. PG should now have up-to-date stats and a reasonable set of config settings. If it's still getting its row estimates wrong, we'll have to look at the statistics its got. If we reach the statistics tinkering stage, it might be better to wait til Monday if you can - more people on the list then. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Sat Oct 11 11:56:32 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BC00FD1B4F6 for ; Sat, 11 Oct 2003 14:56:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59030-09 for ; Sat, 11 Oct 2003 11:55:49 -0300 (ADT) Received: from easily.co.uk (unknown [213.161.76.90]) by svr1.postgresql.org (Postfix) with ESMTP id D2BACD1B505 for ; Sat, 11 Oct 2003 11:55:39 -0300 (ADT) Received: from [82.33.0.91] (account f4vo5dsy5djd HELO chuckie.co.uk) by easily.co.uk (CommuniGate Pro SMTP 4.1.3) with ESMTP id 30247414; Sat, 11 Oct 2003 15:55:42 +0100 Message-ID: <3F8819EF.7010004@chuckie.co.uk> Date: Sat, 11 Oct 2003 15:55:43 +0100 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 Berkus Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <200310101338.18167.josh@agliodbs.com> In-Reply-To: <200310101338.18167.josh@agliodbs.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: 200310/393 X-Sequence-Number: 4141 Josh Berkus wrote: >>shared_buffers = 1/16th of total memory >>effective_cache_size = 80% of the supposed kernel cache. >> >> >But only if it's a dedicated DB machine. If it's not, all memory values >should be cut in half. > > > >What I would prefer would be an interactive script which would, by asking the >user simple questions and system scanning, collect all the information >necessary to set: > >max_connections >shared_buffers >sort_mem >vacuum_mem >effective_cache_size >random_page_cost >max_fsm_pages >checkpoint_segments & checkpoint_timeout >tcp_ip > >and on the OS, it should set: >shmmax & shmmall >and should offer to create a chron job which does appropriate frequency VACUUM >ANALYZE. > > I reckon do a system scan first, and parse the current PostgreSQL conf file to figure out what the settings are. Also back it up with a date and time appended to the end to make sure there is a backup before overwriting the real conf file. Then a bunch of questions. What sort of questions would need to be asked and which parameters would these questions affect? So far, and from my limited understanding of the .conf file, I reckon there should be the following Here is your config of your hardware as detected. Is this correct ? This could potentially be several questions, i.e. one for proc, mem, os, hdd etc Would affect shared_buffers, sort_mem, effective_cache_size, random_page_cost How was PostgreSQL compiled? This would be parameters such as the block size and a few other compile time parameters. If we can get to some of these read-only parameters than that would make this step easier, certainly for the new recruits amongst us. Is PostgreSQL the only thing being run on this computer? Then my previous assumptions about shared_buffers and effective_cache_size would be true. If shmmax and shmmall are too small, then: PostgreSQL requires some more shared memory to cache some tables, x Mb, do you want to increase your OS kernel parameters? Tweak shmmax and shmmall How are the clients going to connect? i.e. TCP or Unix sockets How many clients can connect to this database at once? Affects max_connections How many databases and how many tables in each database are going to be present? Affects max_fsm_pages, checkpoint_segments, checkpoint_timeout Do you want to vacuum you database regularly? Initial question for cron job It is recomended that you vacuum analyze every night, do you want to do this? It is also recomended that you vacuum full every month, do you want to do this? Thoughts? Nick From pgsql-performance-owner@postgresql.org Tue Oct 14 13:45:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 09654D1B4EF; Sat, 11 Oct 2003 17:47:22 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04174-01; Sat, 11 Oct 2003 14:46:41 -0300 (ADT) Received: from ranger.macsinracks.net (ranger.macsinracks.net [194.100.243.51]) by svr1.postgresql.org (Postfix) with ESMTP id 517FED1B51D; Sat, 11 Oct 2003 14:46:32 -0300 (ADT) Received: from [194.100.243.1] (marko.karppinen.fi [194.100.243.1]) by ranger.macsinracks.net (8.12.9/8.12.9) with ESMTP id h9BHkdhq090030; Sat, 11 Oct 2003 17:46:39 GMT (envelope-from marko@karppinen.fi) In-Reply-To: <200310081831.h98IVT919657@candle.pha.pa.us> References: <200310081831.h98IVT919657@candle.pha.pa.us> Mime-Version: 1.0 (Apple Message framework v604) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: PostgreSQL Performance , PostgreSQL-development From: Marko Karppinen Subject: Re: [HACKERS] Sun performance - Major discovery! Date: Sat, 11 Oct 2003 20:46:40 +0300 To: Bruce Momjian X-Mailer: Apple Mail (2.604) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/449 X-Sequence-Number: 4197 On 8.10.2003, at 21:31, Bruce Momjian wrote: > Well, this is really embarassing. I can't imagine why we would not set > at least -O on all platforms. Looking at the template files, I see > these have no optimization set: > > darwin Regarding Darwin optimizations, Apple has introduced a "-fast" flag in their GCC 3.3 version that they recommend when compiling code for their new G5 systems. Because of this, I foresee a lot of people defining CFLAGS="-fast" on their systems. This is problematic for PostgreSQL, however, since the -fast flag is the equivalent of: -O3 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -falign-loops=16 -falign-jumps=16 -falign-functions=16 -malign-natural -ffast-math -fstrict-aliasing -frelax-aliasing -fgcse-mem-alias -funroll-loops -floop-transpose -floop-to-memset -finline-floor -mcpu=G5 -mpowerpc64 -mpowerpc-gpopt -mtune=G5 -fsched-interblock -fload-after-store --param max-gcse-passes=3 -fno-gcse-sm -fgcse-loop-depth -funit-at-a-time -fcallgraph-inlining -fdisable-typechecking-for-spec At least the --fast-math part causes problems, seeing that PostgreSQL actually checks for the __FAST_MATH__ macro to make sure that it isn't turned on. There might be other problems with Apple's flags, but I think that the __FAST_MATH__ check should be altered. As you know, setting --fast-math in GCC is the equivalent of setting -fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math, -ffinite-math-only and -fno-signaling-nans. What really should be done, I think, is adding the opposites of these flags (-fmath-errno, -fno-unsafe-math-optimizations, -ftrapping_math, -fno-finite-math-only and -fsignaling-nans) to the command line if __FAST_MATH__ is detected. This would allow people to use CFLAGS="-fast" on their G5s, beat some Xeon speed records, and not worry about esoteric IEEE math standards. What do you guys think? GCC sets __FAST_MATH__ even if you counter a -ffast-math with the negating flags above. This means that it is not currently possible to use the -fast flag when compiling PostgreSQL at all. Instead, you have to go through all the flags Apple is setting and only pass on those that don't break pg. mk From pgsql-performance-owner@postgresql.org Sat Oct 11 16:37:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C9852D1B4FC for ; Sat, 11 Oct 2003 19:37:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14966-05 for ; Sat, 11 Oct 2003 16:36:37 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id C904ED1B531 for ; Sat, 11 Oct 2003 16:36:26 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92JT9T>; Sat, 11 Oct 2003 12:34:30 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92JT9R; Sat, 11 Oct 2003 12:34:23 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <052001c39030$1ccc8020$6501a8c0@griffiths2> Subject: Another weird one with an UPDATE Date: Sat, 11 Oct 2003 12:44:36 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0505_01C38FF5.6D8CCF50" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/394 X-Sequence-Number: 4142 This is a multi-part message in MIME format. ------=_NextPart_000_0505_01C38FF5.6D8CCF50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am running an update-query to benchmark various databases; the postgres version is, =20 UPDATE user_account SET last_name =3D 'abc' WHERE user_account_id IN (SELECT user_account_id FROM commercial_entity, commercial_service WHERE yw_account_id IS NULL AND commercial_entity.commercial_entity_id =3D commercial_service.commercial_entity_id); =20 =20 The inner query (the select), run by itself, takes about a second. Add the outer query (the update-portion), and the query dies. The machine has been vacuum-analzyed. Here is the explain-analyze: =20 benchtest=3D# EXPLAIN ANALYZE UPDATE user_account SET last_name =3D 'abc' benchtest-# WHERE user_account_id IN (SELECT user_account_id FROM commercial_entity, commercial_service WHERE yw_account_id IS NULL benchtest(# AND commercial_entity.commercial_entity_id =3D commercial_service.commercial_entity_id); Seq Scan on user_account (cost=3D0.00..813608944.88 rows=3D36242 width=3D718) (actual time=3D15696258.98..16311130.29 rows=3D3075 loops=3D1) Filter: (subplan) SubPlan -> Materialize (cost=3D11224.77..11224.77 rows=3D86952 width=3D36) (actual time=3D0.06..106.40 rows=3D84831 loops=3D72483) -> Merge Join (cost=3D0.00..11224.77 rows=3D86952 width=3D36) (actual time=3D0.21..1845.13 rows=3D85158 loops=3D1) Merge Cond: ("outer".commercial_entity_id =3D "inner".commercial_entity_id) -> Index Scan using commercial_entity_pkey on commercial_entity (cost=3D0.00..6787.27 rows=3D77862 width=3D24) (actual time=3D0.06..469.56 rows=3D78132 loops=3D1) Filter: (yw_account_id IS NULL) -> Index Scan using comm_serv_comm_ent_id_i on commercial_service (cost=3D0.00..2952.42 rows=3D88038 width=3D12) (actual time=3D0.03..444.80 rows=3D88038 loops=3D1) Total runtime: 16332976.21 msec (10 rows) =20 Here are the relevant parts of the schema: =20 =20 =20 USER_ACCOUNT =20 Column | Type | Modifiers -------------------------------+-----------------------------+---------- ------------------- user_account_id | numeric(10,0) | not null first_name | character varying(100) | last_name | character varying(100) | Indexes: user_account_pkey primary key btree (user_account_id), usr_acc_last_name_i btree (last_name), Foreign Key constraints: $1 FOREIGN KEY (lang_id) REFERENCES lang(lang_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (user_role_id) REFERENCES user_role(user_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 =20 COMMERCIAL_ENTITY =20 Column | Type | Modifiers ---------------------------+-----------------------------+-------------- ----------------------------------------------- commercial_entity_id | numeric(10,0) | not null yw_account_id | numeric(10,0) | Indexes: commercial_entity_pkey primary key btree (commercial_entity_id), comm_ent_yw_acc_id_i btree (yw_account_id) Foreign Key constraints: $1 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (user_account_id) REFERENCES user_account(user_account_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 =20 COMMERCIAL_SERVICE=20 =20 Column | Type | Modifiers ----------------------+---------------+----------- commercial_entity_id | numeric(10,0) | not null service_type_id | numeric(10,0) | not null source_id | numeric(10,0) | not null Indexes: commercial_service_pkey primary key btree (commercial_entity_id, service_type_id), comm_serv_comm_ent_id_i btree (commercial_entity_id), comm_serv_serv_type_id_i btree (service_type_id), comm_serv_source_id_i btree (source_id) Foreign Key constraints: $1 FOREIGN KEY (commercial_entity_id) REFERENCES commercial_entity(commercial_entity_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (service_type_id) REFERENCES service_type(service_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 Here is the postgres.conf (or the variables that are not commented out): =20 tcpip_socket =3D true max_connections =3D 500 shared_buffers =3D 32768 # min max_connections*2 or 16, 8KB each wal_buffers =3D 128 # min 4, typically 8KB each sort_mem =3D 4096 # min 64, size in KB effective_cache_size =3D 50000 # typically 8KB each =20 Is it a problem with "IN"? =20 David ------=_NextPart_000_0505_01C38FF5.6D8CCF50 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am running an update-query to benchmark various databases; the= =20 postgres version is,
 
UPDATE user_account SET last_name =3D 'abc'
WHERE user_account_id&n= bsp;IN=20 (SELECT user_account_id FROM commercial_entity, commercial_service WHERE=20 yw_account_id IS NULL
AND commercial_entity.commercial_entity_id =3D=20 commercial_service.commercial_entity_id);
 
 
The inner query (the select), run by itsel= f, takes=20 about a second. Add the outer query (the update-portion), and the query die= s.=20 The machine has been vacuum-analzyed. Here is the=20 explain-analyze:
 
benchtest=3D# EXPLAIN ANALYZE UPDATE user_= account SET=20 last_name =3D 'abc'
benchtest-# WHERE user_account_id IN (SELECT=20 user_account_id FROM commercial_entity, commercial_service WHERE yw_account= _id=20 IS NULL
benchtest(# AND commercial_entity.commercial_entity_id =3D=20 commercial_service.commercial_entity_id);
 Seq Scan on user_account =20 (cost=3D0.00..813608944.88 rows=3D36242 width=3D718) (actual=20 time=3D15696258.98..16311130.29 rows=3D3075 loops=3D1)   Filter:= =20 (subplan)
   SubPlan
     -> = =20 Materialize  (cost=3D11224.77..11224.77 rows=3D86952 width=3D36) (actu= al=20 time=3D0.06..106.40 rows=3D84831=20 loops=3D72483)
         &nb= sp;=20 ->  Merge Join  (cost=3D0.00..11224.77 rows=3D86952 width=3D36= ) (actual=20 time=3D0.21..1845.13 rows=3D85158=20 loops=3D1)
          &= nbsp;     =20 Merge Cond: ("outer".commercial_entity_id =3D=20 "inner".commercial_entity_id)
       =          =20 ->  Index Scan using commercial_entity_pkey on commercial_entity&nb= sp;=20 (cost=3D0.00..6787.27 rows=3D77862 width=3D24) (actual time=3D0.06..469.56 = rows=3D78132=20 loops=3D1)
          &= nbsp;           =20 Filter: (yw_account_id IS=20 NULL)
           =      =20 ->  Index Scan using comm_serv_comm_ent_id_i on commercial_service&= nbsp;=20 (cost=3D0.00..2952.42 rows=3D88038 width=3D12) (actual time=3D0.03..44= 4.80=20 rows=3D88038 loops=3D1)
 Total runtime: 16332976.21 msec
(10=20 rows)
 
Here are the relevant parts of the=20 schema:
 
 
 
USER_ACCOUNT
 
           = =20 Column           &nb= sp;=20 |           =20 Type            = ;=20 |         =20 Modifiers
-------------------------------+-----------------------------+= -----------------------------
 user_account_id   &nb= sp;          =20 |=20 numeric(10,0)          &n= bsp;   =20 | not=20 null
 first_name        &nb= sp;          =20 | character varying(100)     =20 |
 last_name         &= nbsp;          =20 | character varying(100)      |
Indexes:=20 user_account_pkey primary key btree=20 (user_account_id),
        =20 usr_acc_last_name_i btree (last_name),
Foreign Key constraints: $1 FOREI= GN=20 KEY (lang_id) REFERENCES lang(lang_id) ON UPDATE NO ACTION ON DELETE NO=20 ACTION,
          &nbs= p;            &= nbsp;=20 $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION= ON=20 DELETE NO=20 ACTION,
          &nbs= p;            &= nbsp;=20 $3 FOREIGN KEY (user_role_id) REFERENCES user_role(user_role_id) ON UPDATE = NO=20 ACTION ON DELETE NO ACTION
 
 
 
COMMERCIAL_ENTITY
 
         =20 Column          =20 |           =20 Type            = ;=20 |            &n= bsp;            = ;=20 Modifiers
---------------------------+-----------------------------+----= ---------------------------------------------------------
 commerci= al_entity_id     =20 |=20 numeric(10,0)          &n= bsp;   =20 | not=20 null
 yw_account_id        =     =20 |=20 numeric(10,0)          &n= bsp;   =20 |
Indexes: commercial_entity_pkey primary key btree=20 (commercial_entity_id),
        = =20 comm_ent_yw_acc_id_i btree (yw_account_id)
Foreign Key constraints: $1= =20 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON= =20 DELETE NO=20 ACTION,
          &nbs= p;            &= nbsp;=20 $2 FOREIGN KEY (user_account_id) REFERENCES user_account(user_account_id) O= N=20 UPDATE NO ACTION ON DELETE NO ACTION
 
 
 
COMMERCIAL_SERVICE
 
       = =20 Column        |    = =20 Type      |=20 Modifiers
----------------------+---------------+-----------
 co= mmercial_entity_id=20 | numeric(10,0) | not=20 null
 service_type_id      | numeric(10,0)= |=20 not=20 null
 source_id        &nbs= p;  =20 | numeric(10,0) | not null
Indexes: commercial_service_pkey primary key = btree=20 (commercial_entity_id,=20 service_type_id),
        =20 comm_serv_comm_ent_id_i btree=20 (commercial_entity_id),
        = =20 comm_serv_serv_type_id_i btree=20 (service_type_id),
        =20 comm_serv_source_id_i btree (source_id)
Foreign Key constraints: $1 FORE= IGN=20 KEY (commercial_entity_id) REFERENCES commercial_entity(commercial_entity_i= d) ON=20 UPDATE NO ACTION ON DELETE NO=20 ACTION,
          &nbs= p;            &= nbsp;=20 $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION= ON=20 DELETE NO=20 ACTION,
          &nbs= p;            &= nbsp;=20 $3 FOREIGN KEY (service_type_id) REFERENCES service_type(service_type_id) O= N=20 UPDATE NO ACTION ON DELETE NO ACTION
 
 
Here is the postgres.conf (or the variable= s that=20 are not commented out):
 
tcpip_socket =3D true
max_connections = =3D=20 500
shared_buffers =3D=20 32768          # min=20 max_connections*2 or 16, 8KB each
wal_buffers =3D=20 128            =   =20 # min 4, typically 8KB each
sort_mem =3D=20 4096            = ;    =20 # min 64, size in KB
effective_cache_= size =3D=20 50000    # typically 8KB each
 
Is it a problem with "IN"?
 
David
------=_NextPart_000_0505_01C38FF5.6D8CCF50-- From pgsql-performance-owner@postgresql.org Sat Oct 11 18:28:01 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 73648D1B4F2 for ; Sat, 11 Oct 2003 21:28:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32405-04 for ; Sat, 11 Oct 2003 18:27:20 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 36F16D1B4ED for ; Sat, 11 Oct 2003 18:27:09 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92JVHC>; Sat, 11 Oct 2003 14:25:42 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92JVHA; Sat, 11 Oct 2003 14:25:39 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <05a401c3903f$a8524850$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> Subject: Re: Another weird one with an UPDATE Date: Sat, 11 Oct 2003 14:35:52 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_05A1_01C39004.F8FFABC0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/395 X-Sequence-Number: 4143 This is a multi-part message in MIME format. ------=_NextPart_000_05A1_01C39004.F8FFABC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sorry - just found the FAQ ( http://jamesthornton.com/postgres/FAQ/faq-english.html#4.22 ) on how IN is very slow. =20 So I rewrote the query: =20 \o ./data/temp.txt SELECT current_timestamp; UPDATE user_account SET last_name =3D 'abc' WHERE EXISTS (SELECT ua.user_account_id FROM user_account ua, commercial_entity ce, commercial_service cs WHERE ua.user_account_id =3D ce.user_account_id AND ce.commercial_entity_id =3D cs.commercial_entity_id); SELECT current_timestamp; \o =20 EXISTS is kind of a weird statement, and it doesn't appear to be identical (the number of rows updated was 72,000 rather than 3500). It also took 4 minutes to execute. =20 Is there any way around this other than breaking the query into two? As in: =20 pstmt1 =3D conn.preprareStatement("SELECT ua.user_account_id FROM user_account ua, commercial_entity ce, commercial_service cs WHERE ua.user_account_id =3D ce.user_account_id AND ce.commercial_entity_id =3D cs.commercial_entity_id"); rset =3D pstmt1.executeQuery(); while (rset.next()) { pstmt2 =3D conn.prepareStatement("UPDATE user_account SET last_name =3D 'abc' WHERE user_account_id =3D ?"); pstmt2.setLong(1, rset.getLong(1)); ... } =20 Unfort, that will be alot of data moved from Postgres->middle-tier (Weblogic/Resin), which is inefficient. =20 Anyone see another solution? =20 David. ----- Original Message -----=20 From: David Griffiths=20 To: pgsql-performance@postgresql.org =20=20 Sent: Saturday, October 11, 2003 12:44 PM Subject: [PERFORM] Another weird one with an UPDATE I am running an update-query to benchmark various databases; the postgres version is, =20 UPDATE user_account SET last_name =3D 'abc' WHERE user_account_id IN (SELECT user_account_id FROM commercial_entity, commercial_service WHERE yw_account_id IS NULL AND commercial_entity.commercial_entity_id =3D commercial_service.commercial_entity_id); =20 =20 The inner query (the select), run by itself, takes about a second. Add the outer query (the update-portion), and the query dies. The machine has been vacuum-analzyed. Here is the explain-analyze: =20 benchtest=3D# EXPLAIN ANALYZE UPDATE user_account SET last_name =3D 'abc' benchtest-# WHERE user_account_id IN (SELECT user_account_id FROM commercial_entity, commercial_service WHERE yw_account_id IS NULL benchtest(# AND commercial_entity.commercial_entity_id =3D commercial_service.commercial_entity_id); Seq Scan on user_account (cost=3D0.00..813608944.88 rows=3D36242 width=3D718) (actual time=3D15696258.98..16311130.29 rows=3D3075 loops=3D1) Filter: (subplan) SubPlan -> Materialize (cost=3D11224.77..11224.77 rows=3D86952 width=3D36) (actual time=3D0.06..106.40 rows=3D84831 loops=3D72483) -> Merge Join (cost=3D0.00..11224.77 rows=3D86952 width=3D36) (actual time=3D0.21..1845.13 rows=3D85158 loops=3D1) Merge Cond: ("outer".commercial_entity_id =3D "inner".commercial_entity_id) -> Index Scan using commercial_entity_pkey on commercial_entity (cost=3D0.00..6787.27 rows=3D77862 width=3D24) (actual time=3D0.06..469.56 rows=3D78132 loops=3D1) Filter: (yw_account_id IS NULL) -> Index Scan using comm_serv_comm_ent_id_i on commercial_service (cost=3D0.00..2952.42 rows=3D88038 width=3D12) (actual time=3D0.03..444.80 rows=3D88038 loops=3D1) Total runtime: 16332976.21 msec (10 rows) =20 Here are the relevant parts of the schema: =20 =20 =20 USER_ACCOUNT =20 Column | Type | Modifiers -------------------------------+-----------------------------+---------- ------------------- user_account_id | numeric(10,0) | not null first_name | character varying(100) | last_name | character varying(100) | Indexes: user_account_pkey primary key btree (user_account_id), usr_acc_last_name_i btree (last_name), Foreign Key constraints: $1 FOREIGN KEY (lang_id) REFERENCES lang(lang_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (user_role_id) REFERENCES user_role(user_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 =20 COMMERCIAL_ENTITY =20 Column | Type | Modifiers ---------------------------+-----------------------------+-------------- ----------------------------------------------- commercial_entity_id | numeric(10,0) | not null yw_account_id | numeric(10,0) | Indexes: commercial_entity_pkey primary key btree (commercial_entity_id), comm_ent_yw_acc_id_i btree (yw_account_id) Foreign Key constraints: $1 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (user_account_id) REFERENCES user_account(user_account_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 =20 COMMERCIAL_SERVICE=20 =20 Column | Type | Modifiers ----------------------+---------------+----------- commercial_entity_id | numeric(10,0) | not null service_type_id | numeric(10,0) | not null source_id | numeric(10,0) | not null Indexes: commercial_service_pkey primary key btree (commercial_entity_id, service_type_id), comm_serv_comm_ent_id_i btree (commercial_entity_id), comm_serv_serv_type_id_i btree (service_type_id), comm_serv_source_id_i btree (source_id) Foreign Key constraints: $1 FOREIGN KEY (commercial_entity_id) REFERENCES commercial_entity(commercial_entity_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (service_type_id) REFERENCES service_type(service_type_id) ON UPDATE NO ACTION ON DELETE NO ACTION =20 =20 Here is the postgres.conf (or the variables that are not commented out): =20 tcpip_socket =3D true max_connections =3D 500 shared_buffers =3D 32768 # min max_connections*2 or 16, 8KB each wal_buffers =3D 128 # min 4, typically 8KB each sort_mem =3D 4096 # min 64, size in KB effective_cache_size =3D 50000 # typically 8KB each =20 Is it a problem with "IN"? =20 David ------=_NextPart_000_05A1_01C39004.F8FFABC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Sorry - just found the FAQ (http:/= /jamesthornton.com/postgres/FAQ/faq-english.html#4.22)=20 on how IN is very slow.
 
So I rewrote the query:
 
\o ./data/temp.txt
SELECT current_timestamp;
UPDATE user_account SET last_name =3D 'abc= '
WHERE=20 EXISTS (SELECT ua.user_account_id FROM user_account ua, commercial_entity c= e,=20 commercial_service cs
WHERE ua.user_account_id =3D ce.user_account_id AN= D=20 ce.commercial_entity_id =3D cs.commercial_entity_id);
SELECT current_timestamp;
\o
 
EXISTS is kind of a weird statement, and i= t doesn't=20 appear to be identical (the number of rows updated was 72,000 rather than 3= 500).=20 It also took 4 minutes to execute.
 
Is there any way around this other than br= eaking=20 the query into two? As in:
 
pstmt1 =3D conn.preprareStatement("SELECT= =20 ua.user_account_id FROM user_account ua, commercial_entity ce,=20 commercial_service cs
WHERE ua.user_account_id =3D ce.user_account_id AN= D=20 ce.commercial_entity_id =3D cs.commercial_entity_id");
rset =3D pstmt1.executeQuery();
while (rset.next())
{
    pstmt2 =3D=20 conn.prepareStatement("UPDATE user_account SET last_name =3D 'abc' WHERE=20 user_account_id =3D ?");
    pstmt2.setLong(1,=20 rset.getLong(1));
    ...
}
 
Unfort, that will be alot of data moved fr= om=20 Postgres->middle-tier (Weblogic/Resin), which is inefficient.
 
Anyone see another solution?
 
David.
----- Original Message -----
Fro= m:=20 Davi= d=20 Griffiths
To: pgsql-performance@postgresql.org= =20
Sent: Saturday, October 11, 2003 1= 2:44=20 PM
Subject: [PERFORM] Another weird o= ne with=20 an UPDATE

I am running an update-query to benchmark various databases; th= e=20 postgres version is,
 
UPDATE user_account SET last_name =3D 'abc'
WHERE=20 user_account_id IN (SELECT user_account_id FROM commercial_entity,= =20 commercial_service WHERE yw_account_id IS NULL
AND=20 commercial_entity.commercial_entity_id =3D=20 commercial_service.commercial_entity_id);
 
 
The inner query (the select), run by its= elf,=20 takes about a second. Add the outer query (the update-portion), and the q= uery=20 dies. The machine has been vacuum-analzyed. Here is the=20 explain-analyze:
 
benchtest=3D# EXPLAIN ANALYZE UPDATE use= r_account=20 SET last_name =3D 'abc'
benchtest-# WHERE user_account_id IN (SELECT= =20 user_account_id FROM commercial_entity, commercial_service WHERE yw_accou= nt_id=20 IS NULL
benchtest(# AND commercial_entity.commercial_entity_id =3D=20 commercial_service.commercial_entity_id);
 Seq Scan on user_account =20 (cost=3D0.00..813608944.88 rows=3D36242 width=3D718) (actual=20 time=3D15696258.98..16311130.29 rows=3D3075 loops=3D1)   Filter= :=20 (subplan)
   SubPlan
     -> = =20 Materialize  (cost=3D11224.77..11224.77 rows=3D86952 width=3D36) (ac= tual=20 time=3D0.06..106.40 rows=3D84831=20 loops=3D72483)
         &= nbsp;=20 ->  Merge Join  (cost=3D0.00..11224.77 rows=3D86952 width=3D= 36) (actual=20 time=3D0.21..1845.13 rows=3D85158=20 loops=3D1)
          = ;      =20 Merge Cond: ("outer".commercial_entity_id =3D=20 "inner".commercial_entity_id)
      &nbs= p;         =20 ->  Index Scan using commercial_entity_pkey on commercial_entity&= nbsp;=20 (cost=3D0.00..6787.27 rows=3D77862 width=3D24) (actual time=3D0.06..469.5= 6 rows=3D78132=20 loops=3D1)
          = ;            = =20 Filter: (yw_account_id IS=20 NULL)
          &nbs= p;     =20 ->  Index Scan using comm_serv_comm_ent_id_i on=20 commercial_service  (cost=3D0.00..2952.42 rows=3D88038 width=3D= 12) (actual=20 time=3D0.03..444.80 rows=3D88038 loops=3D1)
 Total runtime: 16332= 976.21=20 msec
(10 rows)
 
Here are the relevant parts of the=20 schema:
 
 
 
USER_ACCOUNT
 
          &nbs= p;=20 Column           &= nbsp;=20 |           =20 Type           &nb= sp;=20 |         =20 Modifiers
-------------------------------+----------------------------= -+-----------------------------
 user_account_id   &= nbsp;          =20 |=20 numeric(10,0)          =     =20 | not=20 null
 first_name        &= nbsp;          =20 | character varying(100)     =20 |
 last_name         = ;           =20 | character varying(100)      |
Indexes:=20 user_account_pkey primary key btree=20 (user_account_id),
        =20 usr_acc_last_name_i btree (last_name),
Foreign Key constraints: $1 FOR= EIGN=20 KEY (lang_id) REFERENCES lang(lang_id) ON UPDATE NO ACTION ON DELETE NO= =20 ACTION,
          &n= bsp;            = ; =20 $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTI= ON ON=20 DELETE NO=20 ACTION,
          &n= bsp;            = ; =20 $3 FOREIGN KEY (user_role_id) REFERENCES user_role(user_role_id) ON UPDAT= E NO=20 ACTION ON DELETE NO ACTION
 
 
 
COMMERCIAL_ENTITY
 
         =20 Column          =20 |           =20 Type           &nb= sp;=20 |            =             &nb= sp;=20 Modifiers
---------------------------+-----------------------------+--= -----------------------------------------------------------
 commer= cial_entity_id     =20 |=20 numeric(10,0)          =     =20 | not=20 null
 yw_account_id       &nbs= p;    =20 |=20 numeric(10,0)          =     =20 |
Indexes: commercial_entity_pkey primary key btree=20 (commercial_entity_id),
       &nbs= p;=20 comm_ent_yw_acc_id_i btree (yw_account_id)
Foreign Key constraints: $1= =20 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION = ON=20 DELETE NO=20 ACTION,
          &n= bsp;            = ; =20 $2 FOREIGN KEY (user_account_id) REFERENCES user_account(user_account_id)= ON=20 UPDATE NO ACTION ON DELETE NO ACTION
 
 
 
COMMERCIAL_SERVICE
 
      &nbs= p;=20 Column        |    = ;=20 Type      |=20 Modifiers
----------------------+---------------+-----------
 = commercial_entity_id=20 | numeric(10,0) | not=20 null
 service_type_id      | numeric(10,= 0) |=20 not=20 null
 source_id        &n= bsp;  =20 | numeric(10,0) | not null
Indexes: commercial_service_pkey primary ke= y=20 btree (commercial_entity_id,=20 service_type_id),
        =20 comm_serv_comm_ent_id_i btree=20 (commercial_entity_id),
       &nbs= p;=20 comm_serv_serv_type_id_i btree=20 (service_type_id),
        =20 comm_serv_source_id_i btree (source_id)
Foreign Key constraints: $1 FO= REIGN=20 KEY (commercial_entity_id) REFERENCES commercial_entity(commercial_entity= _id)=20 ON UPDATE NO ACTION ON DELETE NO=20 ACTION,
          &n= bsp;            = ; =20 $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTI= ON ON=20 DELETE NO=20 ACTION,
          &n= bsp;            = ; =20 $3 FOREIGN KEY (service_type_id) REFERENCES service_type(service_type_id)= ON=20 UPDATE NO ACTION ON DELETE NO ACTION
 
 
Here is the postgres.conf (or the variab= les that=20 are not commented out):
 
tcpip_socket =3D true
max_connections= =3D=20 500
shared_buffers =3D=20 32768          # min=20 max_connections*2 or 16, 8KB each
wal_buffers =3D=20 128           &nbs= p;  =20 # min 4, typically 8KB each
sort_mem =3D=20 4096           &nb= sp;    =20 # min 64, size in KB
effective_cach= e_size =3D=20 50000    # typically 8KB each
 
Is it a problem with "IN"?
 
David
------=_NextPart_000_05A1_01C39004.F8FFABC0-- From pgsql-performance-owner@postgresql.org Sat Oct 11 19:35:33 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5993ED1B4FC for ; Sat, 11 Oct 2003 22:35:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40412-09 for ; Sat, 11 Oct 2003 19:34:55 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 7B703D1B4F2 for ; Sat, 11 Oct 2003 19:34:44 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id DF3FB351EF; Sat, 11 Oct 2003 15:34:52 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id DD85C34D58; Sat, 11 Oct 2003 15:34:52 -0700 (PDT) Date: Sat, 11 Oct 2003 15:34:52 -0700 (PDT) From: Stephan Szabo To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Another weird one with an UPDATE In-Reply-To: <05a401c3903f$a8524850$6501a8c0@griffiths2> Message-ID: <20031011153251.F57866@megazone.bigpanda.com> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/396 X-Sequence-Number: 4144 On Sat, 11 Oct 2003, David Griffiths wrote: > Sorry - just found the FAQ ( > http://jamesthornton.com/postgres/FAQ/faq-english.html#4.22 > ) on how > IN is very slow. > > So I rewrote the query: > > \o ./data/temp.txt > SELECT current_timestamp; > UPDATE user_account SET last_name = 'abc' > WHERE EXISTS (SELECT ua.user_account_id FROM user_account ua, > commercial_entity ce, commercial_service cs > WHERE ua.user_account_id = ce.user_account_id AND > ce.commercial_entity_id = cs.commercial_entity_id); > SELECT current_timestamp; I don't think that's the query you want. You're not binding the subselect to the outer values of user_account. I think you want something like: UPDATE user_account SET last_name = 'abc' WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs WHERE user_account.user_account_id = ce.user_account_id AND ce.commercial_entity_id = cs.commercial_entity_id); From pgsql-performance-owner@postgresql.org Sat Oct 11 23:44:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D8177D1B52A for ; Sun, 12 Oct 2003 02:44:40 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 82312-02 for ; Sat, 11 Oct 2003 23:44:06 -0300 (ADT) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 6A12AD1B50C for ; Sat, 11 Oct 2003 23:43:53 -0300 (ADT) Received: from [203.221.127.100] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1A8WCo-0001Rp-00; Sun, 12 Oct 2003 12:43:39 +1000 Message-ID: <3F88BFD7.1020808@familyhealth.com.au> Date: Sun, 12 Oct 2003 10:43:35 +0800 From: Christopher Kings-Lynne 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: Nick Barr Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <200310101338.18167.josh@agliodbs.com> <3F8819EF.7010004@chuckie.co.uk> In-Reply-To: <3F8819EF.7010004@chuckie.co.uk> 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: 200310/397 X-Sequence-Number: 4145 > If shmmax and shmmall are too small, then: > > PostgreSQL requires some more shared memory to cache some tables, x Mb, > do you want to increase your OS kernel parameters? > > Tweak shmmax and shmmall Note that this still requires a kernel recompile on FreeBSD :( Chris From pgsql-performance-owner@postgresql.org Sun Oct 12 02:27:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ED362D1B505 for ; Sun, 12 Oct 2003 05:27:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83011-08 for ; Sun, 12 Oct 2003 02:27:03 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 85AD3D1B508 for ; Sun, 12 Oct 2003 02:26:49 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92JZYV>; Sat, 11 Oct 2003 22:25:26 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92JZY4; Sat, 11 Oct 2003 22:25:24 -0700 From: David Griffiths To: Stephan Szabo Cc: pgsql-performance@postgresql.org Message-ID: <06d701c39082$ae32aa10$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> Subject: Re: Another weird one with an UPDATE Date: Sat, 11 Oct 2003 22:35:39 -0700 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 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/398 X-Sequence-Number: 4146 Thanks - that worked. David ----- Original Message ----- From: "Stephan Szabo" To: "David Griffiths" Cc: Sent: Saturday, October 11, 2003 3:34 PM Subject: Re: [PERFORM] Another weird one with an UPDATE > On Sat, 11 Oct 2003, David Griffiths wrote: > > > Sorry - just found the FAQ ( > > http://jamesthornton.com/postgres/FAQ/faq-english.html#4.22 > > ) on how > > IN is very slow. > > > > So I rewrote the query: > > > > \o ./data/temp.txt > > SELECT current_timestamp; > > UPDATE user_account SET last_name = 'abc' > > WHERE EXISTS (SELECT ua.user_account_id FROM user_account ua, > > commercial_entity ce, commercial_service cs > > WHERE ua.user_account_id = ce.user_account_id AND > > ce.commercial_entity_id = cs.commercial_entity_id); > > SELECT current_timestamp; > > I don't think that's the query you want. You're not binding the subselect > to the outer values of user_account. > > I think you want something like: > UPDATE user_account SET last_name = 'abc' > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id = cs.commercial_entity_id); From pgsql-performance-owner@postgresql.org Sun Oct 12 16:28:54 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ACD34D1B4FD for ; Sun, 12 Oct 2003 19:28:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 16442-10 for ; Sun, 12 Oct 2003 16:28:22 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 4E217D1B513 for ; Sun, 12 Oct 2003 16:28:04 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1A8ltD-0004qJ-00 for ; Sun, 12 Oct 2003 15:28:27 -0400 Received: by dba2 (Postfix, from userid 1019) id A394ECCC2; Sun, 12 Oct 2003 15:28:27 -0400 (EDT) Date: Sun, 12 Oct 2003 15:28:27 -0400 From: Andrew Sullivan To: PgSQL Performance ML Subject: Re: Index/Foreign Key Question Message-ID: <20031012192827.GC20538@libertyrms.info> Mail-Followup-To: Andrew Sullivan , PgSQL Performance ML References: <006a01c38f72$25461720$1100000a@busbydev> <1065821515.16433.10.camel@haggis> <009c01c38f76$02150230$1100000a@busbydev> <1065837672.16433.23.camel@haggis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1065837672.16433.23.camel@haggis> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/399 X-Sequence-Number: 4147 On Fri, Oct 10, 2003 at 09:01:12PM -0500, Ron Johnson wrote: > > > Does PostgreSQL only pick one index per table on the select statements? > > That's it's preference. As far as I know, that's all it can do. Do you know something different? 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 Sun Oct 12 16:40:50 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7C16BD1B58E for ; Sun, 12 Oct 2003 19:40:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 32587-05 for ; Sun, 12 Oct 2003 16:40:16 -0300 (ADT) 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 2D761D1B554 for ; Sun, 12 Oct 2003 16:39:13 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9CJdQuH015952; Sun, 12 Oct 2003 22:39:27 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9CJdPgW015950; Sun, 12 Oct 2003 22:39:25 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Index/Foreign Key Question From: Hannu Krosing To: Andrew Sullivan Cc: PgSQL Performance ML In-Reply-To: <20031012192827.GC20538@libertyrms.info> References: <006a01c38f72$25461720$1100000a@busbydev> <1065821515.16433.10.camel@haggis> <009c01c38f76$02150230$1100000a@busbydev> <1065837672.16433.23.camel@haggis> <20031012192827.GC20538@libertyrms.info> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1065987564.15342.2.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 12 Oct 2003 22:39:25 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/400 X-Sequence-Number: 4148 Andrew Sullivan kirjutas P, 12.10.2003 kell 22:28: > On Fri, Oct 10, 2003 at 09:01:12PM -0500, Ron Johnson wrote: > > > > > Does PostgreSQL only pick one index per table on the select statements? > > > > That's it's preference. > > As far as I know, that's all it can do. Do you know something > different? Tom has mentioned the possibility of using bitmaps as a an intermadiate step, this would make star joins much faster as we could AND all index info and actually examine onlu tuples that mach all indexes. None of it is done by now, AFAIK. ------- Hannu From pgsql-performance-owner@postgresql.org Sun Oct 12 17:33:40 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 97AA4D1B4F4 for ; Sun, 12 Oct 2003 20:33:38 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 33449-06 for ; Sun, 12 Oct 2003 17:33:06 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4CBC9D1B4EB for ; Sun, 12 Oct 2003 17:32:48 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3759461; Sun, 12 Oct 2003 13:33:46 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Nick Barr Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Sun, 12 Oct 2003 13:30:45 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101338.18167.josh@agliodbs.com> <3F8819EF.7010004@chuckie.co.uk> In-Reply-To: <3F8819EF.7010004@chuckie.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310121330.45115.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/401 X-Sequence-Number: 4149 Nick, > I reckon do a system scan first, and parse the current PostgreSQL conf > file to figure out what the settings are. Also back it up with a date > and time appended to the end to make sure there is a backup before > overwriting the real conf file. Then a bunch of questions. What sort of > questions would need to be asked and which parameters would these > questions affect? So far, and from my limited understanding of the .conf > file, I reckon there should be the following Hmmm ... but I do think that there should be a file to store the user's previous answers. That way, the script can easily be re-run to fix config issues. > Here is your config of your hardware as detected. Is this correct ? > > This could potentially be several questions, i.e. one for proc, mem, > os, hdd etc > Would affect shared_buffers, sort_mem, effective_cache_size, > random_page_cost Actually, I think this would break down into: -- Are Proc & Mem correct? If not, type in correct values -- Is OS correct? If not, select from list -- Your HDD: is it: 1) IDE 2) Fast multi-disk SCSI or low-end RAID 3) Medium-to-high-end RAID Other things, we don't care about. > How was PostgreSQL compiled? > > This would be parameters such as the block size and a few other > compile time parameters. If we can get to some of these read-only > parameters than that would make this step easier, certainly for the new > recruits amongst us. Actually, from my perspective, we shouldn't bother with this; if an admin knows enough to set an alternate blaock size for PG, then they know enough to tweak the Conf file by hand. I think we should just issue a warning that this script: 1) does not work for anyone who is using non-default block sizes, 2) may not work well for anyone using unusual locales, optimization flags, or other non-default compile options except for language interfaces. 3) cannot produce good settings for embedded systems; 4) will not work well for systems which are extremely low on disk space, memory, or other resouces. Basically, the script only really needs to work for the people who are installing PostgreSQL with the default options or from RPM on regular server or workstation machines with plenty of disk space for normal database purposes. People who have more complicated setups can read the darned documentation and tune the conf file by hand. > Is PostgreSQL the only thing being run on this computer? First, becuase it affects a couple of other variables: What kind of database server are you expecting to run? A) Web Server (many small fast queries from many users, and not much update activity) B) Online Transaction Processing (OLTP) database (many small updates constantly from many users; think "accounting application"). C) Online Analytical Reporting (OLAP) database (a few large and complicated read-only queries aggregating large quantites of data for display) D) Data Transformation tool (loading large amounts of data to process, transform, and output to other software) E) Mixed-Use Database Server (a little of all of the above) F) Workstation (installing this database on a user machine which also has a desktop, does word processing, etc.) If the user answers anything but (F), then we ask: Will you be running any other signficant software on this server, such as a web server, a Java runtime engine, or a reporting application? (yes|no) If yes, then: How much memory do you expect this other software, in total, to regularly use while PostgreSQL is in use? (# in MB; should offer default of 50% of the RAM scanned). > How are the clients going to connect? > > i.e. TCP or Unix sockets We should warn them that they will still need to configure pg_hba.conf. > How many clients can connect to this database at once? > > Affects max_connections Should add a parenthetical comment that for applications which use pooled connections, or intermittent connection, such as Web applications, the number of concurrent connections is often much lower than the number of concurrent users. > How many databases and how many tables in each database are going to be > present? > > Affects max_fsm_pages, checkpoint_segments, checkpoint_timeout Also need to ask if they have an idea of the total size of all databases, in MB or GB, which has a stronger relationship to those variables. Also, this will give us a chance to check the free space on the PGDATA partition, and kick the user out with a warning if there is not at least 2xExpected Size available. > Do you want to vacuum you database regularly? > > Initial question for cron job > > It is recomended that you vacuum analyze every night, do you want to do > this? > It is also recomended that you vacuum full every month, do you want to > do this? Depends on size/type of database. For large OLTP databases, I recommend vacuum as often as every 5 mintues, analyze every hour, and Vacuum Full + Reindex once a week. For a workstation database, your frequencies are probably OK. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Oct 12 17:34:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2534FD1B4F4 for ; Sun, 12 Oct 2003 20:34:33 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34806-06 for ; Sun, 12 Oct 2003 17:34:02 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 098B8D1B503 for ; Sun, 12 Oct 2003 17:33:44 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3759464; Sun, 12 Oct 2003 13:34:44 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Christopher Kings-Lynne , Nick Barr Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Sun, 12 Oct 2003 13:31:42 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> In-Reply-To: <3F88BFD7.1020808@familyhealth.com.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310121331.42693.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/402 X-Sequence-Number: 4150 Chris, > > PostgreSQL requires some more shared memory to cache some tables, x Mb, > > do you want to increase your OS kernel parameters? > > > > Tweak shmmax and shmmall > > Note that this still requires a kernel recompile on FreeBSD :( Not our fault, now is it? This would mean that we wouldn't be able to script for FreeBSD. Bug the FreeBSD developers. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sun Oct 12 20:29:27 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2B0D3D1B4E1 for ; Sun, 12 Oct 2003 23:29:26 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 61090-07 for ; Sun, 12 Oct 2003 20:28:56 -0300 (ADT) Received: from smtp.noos.fr (nan-smtp-12.noos.net [212.198.2.83]) by svr1.postgresql.org (Postfix) with ESMTP id D62F9D1B4EF for ; Sun, 12 Oct 2003 20:28:36 -0300 (ADT) Received: (qmail 11591654 invoked by uid 0); 12 Oct 2003 23:29:00 -0000 Received: from unknown (HELO bigfoot.com) ([212.198.37.110]) (envelope-sender ) by 212.198.2.83 (qmail-ldap-1.03) with SMTP for ; 12 Oct 2003 23:29:00 -0000 Message-ID: <3F89C798.4090402@bigfoot.com> Date: Sun, 12 Oct 2003 23:28:56 +0200 From: Gaetano Mendola 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@postgresql.org" Cc: Andriy Tkachuk Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql References: <3F858FCE.3040907@bigfoot.com> <20031010101408.G35607-100000@pool.imt.com.ua> In-Reply-To: <20031010101408.G35607-100000@pool.imt.com.ua> 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: 200310/404 X-Sequence-Number: 4152 Andriy Tkachuk wrote: > On Thu, 9 Oct 2003, Gaetano Mendola wrote: >>Andriy Tkachuk wrote: >>>On Wed, 8 Oct 2003, Tom Lane wrote: >>>>Andriy Tkachuk writes: >>>>>At second. calc_total() is immutable function: >>>>>but it seems that it's not cached in one session: >>>> >>>>It's not supposed to be. >>> >>> >>>but it's written id doc: >>> >>> IMMUTABLE indicates that the function always returns the same >>> result when given the same argument values; that is, it does not >>> do database lookups or otherwise use information not directly >>> present in its parameter list. If this option is given, any call >>> of the function with all-constant arguments can be immediately >>> replaced with the function value. >> >>The doc say "can be" not must and will be. > > > ok, but on what it depends on? For example in: select * from T where f_immutable ( 4 ) = T.id; in this case f_immutable will be evaluated once. select * from T where f_immutable ( T.id ) = X; here f_immutable will be avaluated for each different T.id. Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Sun Oct 12 18:34:11 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A0F6BD1B506 for ; Sun, 12 Oct 2003 21:34:10 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52120-03 for ; Sun, 12 Oct 2003 18:33:40 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 786FAD1B4E1 for ; Sun, 12 Oct 2003 18:33:21 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3759642; Sun, 12 Oct 2003 14:34:21 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Chris Faulkner" , "Pgsql-Performance" Subject: Re: [SQL] sql performance and cache Date: Sun, 12 Oct 2003 14:31:19 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310121431.19796.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/403 X-Sequence-Number: 4151 Chris, People: (Dropped SQL list because we're cross-posting unnecessarily) > I am not sure I agree with you. I have done similar things with Oracle and > found that the second query will execute much more quickly than the first. > It could be made to work in at least two scenarios Actually, PostgreSQL often DOES cache data, it just uses the Kernel cache rather than any memory application built into Postgres, and it caches the underlying data, not the final query results. Base data for query sets gets cached in RAM after a query, and the second query often *does* run much faster. For example, I was running some queries against the TPC-R OSDL database, and the first time I ran the queries they took about 11 seconds each, the second time (for each query) it was about 0.5 seconds because the data hadn't changed and the underlying rowsets were in memory. I think it's likely that your machine has *already* cached the data in memory, which is why you don't see improvement on the second run. The slow execution time is the result of bad planner decisions and others are helping you adjust that. Now, regarding caching final query results in memory: This seems like a lot of effort for very little return to me. Doing so would require that all underlying data stay the same, and on a complex query would require an immense infrastructure of data-change tracking to verify. If you want a data snapshot, ignoring the possibility of changes, there are already ways to do this: a) use a temp table; b) use your middleware to cache the query results Now, if someone were to present us with an implementation which effectively built and automated form of option (b) above into a optional PG plug-in, I wouldn't vote against it. But I couldn't see voting for putting it on the TODO list, either. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Sun Oct 12 19:11:01 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3ED6FD1B513 for ; Sun, 12 Oct 2003 22:11:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52860-02 for ; Sun, 12 Oct 2003 19:10:29 -0300 (ADT) Received: from lakemtao01.cox.net (lakemtao01.cox.net [68.1.17.244]) by svr1.postgresql.org (Postfix) with ESMTP id 2D428D1B4FF for ; Sun, 12 Oct 2003 19:10:10 -0300 (ADT) 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 <20031012221033.VHZP7826.lakemtao01.cox.net@lhosts> for ; Sun, 12 Oct 2003 18:10:33 -0400 Subject: Re: [PERFORM] go for a script! / ex: PostgreSQL vs. MySQL From: Ron Johnson To: PgSQL General ML In-Reply-To: <200310121331.42693.josh@agliodbs.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.josh@agliodbs.com> Content-Type: text/plain Message-Id: <1065996634.16433.115.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Sun, 12 Oct 2003 17:10:34 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/582 X-Sequence-Number: 50655 On Sun, 2003-10-12 at 15:31, Josh Berkus wrote: > Chris, > > > > PostgreSQL requires some more shared memory to cache some tables, x Mb, > > > do you want to increase your OS kernel parameters? > > > > > > Tweak shmmax and shmmall > > > > Note that this still requires a kernel recompile on FreeBSD :( > > Not our fault, now is it? This would mean that we wouldn't be able to script > for FreeBSD. Bug the FreeBSD developers. Or use a good OS, instead. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "Oh, great altar of passive entertainment, bestow upon me thy discordant images at such speed as to render linear thought impossible" Calvin, regarding TV From pgsql-performance-owner@postgresql.org Tue Oct 14 13:45:57 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0CBB5D1B4E9 for ; Sun, 12 Oct 2003 22:48:13 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 52196-09 for ; Sun, 12 Oct 2003 19:47:42 -0300 (ADT) Received: from jagor.srce.hr (jagor.srce.hr [161.53.2.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3DF4CD1B4E1 for ; Sun, 12 Oct 2003 19:47:22 -0300 (ADT) Received: from flatline (cmung3747.cmu.carnet.hr [193.198.142.191]) by jagor.srce.hr (8.12.10/8.12.10) with SMTP id h9CMliiM013315 for ; Mon, 13 Oct 2003 00:47:45 +0200 (MEST) Message-ID: <00af01c39112$d9ac4350$bf8ec6c1@flatline> From: "Ivan Voras" To: References: <20031012213527.BB2B61CB4664@svr4.postgresql.org> Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Mon, 13 Oct 2003 00:47:38 +0200 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-milter at jagor.srce.hr X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/451 X-Sequence-Number: 4199 > Date: Sun, 12 Oct 2003 13:30:45 -0700 > From: Josh Berkus > To: Nick Barr > Cc: pgsql-performance@postgresql.org > Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL > Message-ID: <200310121330.45115.josh@agliodbs.com> > >> This would be parameters such as the block size and a few other >> compile time parameters. If we can get to some of these read-only >> parameters than that would make this step easier, certainly for the new >> recruits amongst us. > > Actually, from my perspective, we shouldn't bother with this; if an admin > knows enough to set an alternate blaock size for PG, then they know > enough to tweak the Conf file by hand. I think we should just issue a > warning that this script: > 1) does not work for anyone who is using non-default block sizes, There was some talk, either on this list or freebsd-performance about setting the default block size for PostgreSQL running on FreeBSD to be 16k because of performance reasons. That is: *default* for the port, user is not asked. So an automagical method to scale non-default block sizes is a very needed thing. > 2) may not work well for anyone using unusual locales, optimization > flags, or other non-default compile options except for language > interfaces. Depends on what you consider 'unusual'? I hope not things like iso8859-x (or, to be exact, European languages) :) -- Logic is a systematic method of coming to the wrong conclusion with confidence. From pgsql-performance-owner@postgresql.org Sun Oct 12 22:25:48 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CF777D1B4F4 for ; Mon, 13 Oct 2003 01:25:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 77898-09 for ; Sun, 12 Oct 2003 22:25:16 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 6F548D1B53B for ; Sun, 12 Oct 2003 22:24:56 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92K1ZL>; Sun, 12 Oct 2003 18:23:41 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92K1ZK; Sun, 12 Oct 2003 18:23:37 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <080d01c3912a$1356dea0$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> Subject: Re: Another weird one with an UPDATE Date: Sun, 12 Oct 2003 18:33:54 -0700 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 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/405 X-Sequence-Number: 4153 [snip] > I think you want something like: > UPDATE user_account SET last_name = 'abc' > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id = cs.commercial_entity_id); Unfort, this is still taking a long time. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ------- Seq Scan on user_account (cost=0.00..748990.51 rows=36242 width=716) (actual time=10262.50..26568.03 rows=3771 loops=1) Filter: (subplan) SubPlan -> Nested Loop (cost=0.00..11.47 rows=1 width=24) (actual time=0.24..0.24 rows=0 loops=72483) -> Index Scan using comm_ent_usr_acc_id_i on commercial_entity ce (cost=0.00..4.12 rows=1 width=12) (actual time=0.05..0.05 rows=0 loops=72483) Index Cond: ($0 = user_account_id) -> Index Scan using comm_serv_comm_ent_id_i on commercial_service cs (cost=0.00..7.32 rows=3 width=12) (actual time=1.72..1.72 rows=0 loops=7990) Index Cond: ("outer".commercial_entity_id = cs.commercial_entity_id) Total runtime: 239585.09 msec (9 rows) Anyone have any thoughts? David From pgsql-performance-owner@postgresql.org Sun Oct 12 22:39:08 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 933FAD1B540 for ; Mon, 13 Oct 2003 01:39:06 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 79802-06 for ; Sun, 12 Oct 2003 22:38:36 -0300 (ADT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 53FADD1B543 for ; Sun, 12 Oct 2003 22:38:16 -0300 (ADT) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.5) with ESMTP-TLS id 423219; Sun, 12 Oct 2003 18:37:47 -0700 Message-ID: <3F8A01CE.2040003@joeconway.com> Date: Sun, 12 Oct 2003 18:37:18 -0700 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: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Another weird one with an UPDATE References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> In-Reply-To: <080d01c3912a$1356dea0$6501a8c0@griffiths2> 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: 200310/406 X-Sequence-Number: 4154 David Griffiths wrote: >>I think you want something like: >>UPDATE user_account SET last_name = 'abc' >> WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs >> WHERE user_account.user_account_id = ce.user_account_id AND >> ce.commercial_entity_id = cs.commercial_entity_id); > > Unfort, this is still taking a long time. > ------- > Seq Scan on user_account (cost=0.00..748990.51 rows=36242 width=716) Do you have an index on user_account.user_account_id? Joe From pgsql-performance-owner@postgresql.org Sun Oct 12 22:49:07 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E2F05D1B527 for ; Mon, 13 Oct 2003 01:49:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 78411-10 for ; Sun, 12 Oct 2003 22:48:34 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 1A615D1B4F4 for ; Sun, 12 Oct 2003 22:48:14 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id DF9C5353FC; Sun, 12 Oct 2003 18:48:24 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id DE7AB353F5; Sun, 12 Oct 2003 18:48:24 -0700 (PDT) Date: Sun, 12 Oct 2003 18:48:24 -0700 (PDT) From: Stephan Szabo To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Another weird one with an UPDATE In-Reply-To: <080d01c3912a$1356dea0$6501a8c0@griffiths2> Message-ID: <20031012184536.N5307@megazone.bigpanda.com> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/407 X-Sequence-Number: 4155 On Sun, 12 Oct 2003, David Griffiths wrote: > [snip] > > > I think you want something like: > > UPDATE user_account SET last_name = 'abc' > > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > > WHERE user_account.user_account_id = ce.user_account_id AND > > ce.commercial_entity_id = cs.commercial_entity_id); > > Unfort, this is still taking a long time. Hmm, does UPDATE user_account SET last_name='abc' FROM commercial_entity ce, commercial_service cs WHERE user_account.user_account_id = ce.user_account_id AND ce.commercial_entity_id=cs.commercial_entity_id; give the right results... That might end up being faster. From pgsql-performance-owner@postgresql.org Mon Oct 13 03:10:47 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8EE2BD1B505 for ; Mon, 13 Oct 2003 06:10:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 19222-07 for ; Mon, 13 Oct 2003 03:09:55 -0300 (ADT) Received: from mail.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) by svr1.postgresql.org (Postfix) with ESMTP id 1ABACD1B4FC for ; Mon, 13 Oct 2003 03:09:51 -0300 (ADT) Received: (qmail 12663 invoked by uid 507); 13 Oct 2003 06:13:47 -0000 Received: from unknown (HELO t1.unisoftbg.com) (pginfo%t1.unisoftbg.com@194.12.229.193) by 0 with SMTP; 13 Oct 2003 06:13:47 -0000 Message-ID: <3F8A31A6.94849F1A@t1.unisoftbg.com> Date: Mon, 13 Oct 2003 07:01:26 +0200 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Josh Berkus Cc: Nick Barr , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101338.18167.josh@agliodbs.com> <3F8819EF.7010004@chuckie.co.uk> <200310121330.45115.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/408 X-Sequence-Number: 4156 Hi, Josh Berkus wrote: > Nick, > > > I reckon do a system scan first, and parse the current PostgreSQL conf > > file to figure out what the settings are. Also back it up with a date > > and time appended to the end to make sure there is a backup before > > overwriting the real conf file. Then a bunch of questions. What sort of > > questions would need to be asked and which parameters would these > > questions affect? So far, and from my limited understanding of the .conf > > file, I reckon there should be the following > > Hmmm ... but I do think that there should be a file to store the user's > previous answers. That way, the script can easily be re-run to fix config > issues. > > > Here is your config of your hardware as detected. Is this correct ? > > > > This could potentially be several questions, i.e. one for proc, mem, > > os, hdd etc > > Would affect shared_buffers, sort_mem, effective_cache_size, > > random_page_cost > > Actually, I think this would break down into: > -- Are Proc & Mem correct? If not, type in correct values > -- Is OS correct? If not, select from list > -- Your HDD: is it: > 1) IDE > 2) Fast multi-disk SCSI or low-end RAID > 3) Medium-to-high-end RAID > > Other things, we don't care about. > > > How was PostgreSQL compiled? > > > > This would be parameters such as the block size and a few other > > compile time parameters. If we can get to some of these read-only > > parameters than that would make this step easier, certainly for the new > > recruits amongst us. > > Actually, from my perspective, we shouldn't bother with this; if an admin > knows enough to set an alternate blaock size for PG, then they know enough to > tweak the Conf file by hand. I think we should just issue a warning that > this script: > 1) does not work for anyone who is using non-default block sizes, > 2) may not work well for anyone using unusual locales, optimization flags, or > other non-default compile options except for language interfaces. > 3) cannot produce good settings for embedded systems; > 4) will not work well for systems which are extremely low on disk space, > memory, or other resouces. > Basically, the script only really needs to work for the people who are > installing PostgreSQL with the default options or from RPM on regular server > or workstation machines with plenty of disk space for normal database > purposes. People who have more complicated setups can read the darned > documentation and tune the conf file by hand. > > > Is PostgreSQL the only thing being run on this computer? > > First, becuase it affects a couple of other variables: > > What kind of database server are you expecting to run? > A) Web Server (many small fast queries from many users, and not much update > activity) > B) Online Transaction Processing (OLTP) database (many small updates > constantly from many users; think "accounting application"). > C) Online Analytical Reporting (OLAP) database (a few large and complicated > read-only queries aggregating large quantites of data for display) > D) Data Transformation tool (loading large amounts of data to process, > transform, and output to other software) > E) Mixed-Use Database Server (a little of all of the above) > F) Workstation (installing this database on a user machine which also has a > desktop, does word processing, etc.) > > If the user answers anything but (F), then we ask: > > Will you be running any other signficant software on this server, such as a > web server, a Java runtime engine, or a reporting application? (yes|no) > > If yes, then: > > How much memory do you expect this other software, in total, to regularly use > while PostgreSQL is in use? (# in MB; should offer default of 50% of the RAM > scanned). > > > How are the clients going to connect? > > > > i.e. TCP or Unix sockets > > We should warn them that they will still need to configure pg_hba.conf. > > > How many clients can connect to this database at once? > > > > Affects max_connections > > Should add a parenthetical comment that for applications which use pooled > connections, or intermittent connection, such as Web applications, the number > of concurrent connections is often much lower than the number of concurrent > users. > > > How many databases and how many tables in each database are going to be > > present? > > > > Affects max_fsm_pages, checkpoint_segments, checkpoint_timeout > > Also need to ask if they have an idea of the total size of all databases, in > MB or GB, which has a stronger relationship to those variables. > Why not to make a cron script that will detect this size fot hil self?In many cases we do not have a good idea how many records(size) will be in data base. > Also, this will give us a chance to check the free space on the PGDATA > partition, and kick the user out with a warning if there is not at least > 2xExpected Size available. > > > Do you want to vacuum you database regularly? > > > > Initial question for cron job > > > > It is recomended that you vacuum analyze every night, do you want to do > > this? > > It is also recomended that you vacuum full every month, do you want to > > do this? > > Depends on size/type of database. For large OLTP databases, I recommend > vacuum as often as every 5 mintues, analyze every hour, and Vacuum Full + > Reindex once a week. For a workstation database, your frequencies are > probably OK. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > regards,ivan. > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Mon Oct 13 03:13:51 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 46C7BD1B503 for ; Mon, 13 Oct 2003 06:13:50 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37780-01 for ; Mon, 13 Oct 2003 03:13:01 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id C0903D1B4FC for ; Mon, 13 Oct 2003 03:12:59 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92KHVB>; Sun, 12 Oct 2003 23:11:17 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92KH48; Sun, 12 Oct 2003 23:11:08 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <098a01c39152$3e231c20$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> <3F8A01CE.2040003@joeconway.com> Subject: Re: Another weird one with an UPDATE Date: Sun, 12 Oct 2003 23:21:24 -0700 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 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/409 X-Sequence-Number: 4157 Yes, the query operates only on indexed columns (all numeric(10)'s). Column | Type | Modifiers -------------------------------+-----------------------------+-------------- --------------- user_account_id | numeric(10,0) | not null [snip] Indexes: user_account_pkey primary key btree (user_account_id), Foreign Key constraints: $1 FOREIGN KEY (lang_id) REFERENCES lang(lang_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $2 FOREIGN KEY (source_id) REFERENCES source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, $3 FOREIGN KEY (user_role_id) REFERENCES user_role(user_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION David ----- Original Message ----- From: "Joe Conway" To: "David Griffiths" Cc: Sent: Sunday, October 12, 2003 6:37 PM Subject: Re: [PERFORM] Another weird one with an UPDATE > David Griffiths wrote: > >>I think you want something like: > >>UPDATE user_account SET last_name = 'abc' > >> WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > >> WHERE user_account.user_account_id = ce.user_account_id AND > >> ce.commercial_entity_id = cs.commercial_entity_id); > > > > Unfort, this is still taking a long time. > > ------- > > Seq Scan on user_account (cost=0.00..748990.51 rows=36242 width=716) > > Do you have an index on user_account.user_account_id? > > Joe From pgsql-performance-owner@postgresql.org Mon Oct 13 03:16:31 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 71923D1B4E3 for ; Mon, 13 Oct 2003 06:16:30 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 30483-05 for ; Mon, 13 Oct 2003 03:15:41 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 40762D1B502 for ; Mon, 13 Oct 2003 03:15:40 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92KHVS>; Sun, 12 Oct 2003 23:13:37 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92KHVQ; Sun, 12 Oct 2003 23:13:29 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <098b01c39152$921632e0$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> <20031012184536.N5307@megazone.bigpanda.com> Subject: Re: Another weird one with an UPDATE Date: Sun, 12 Oct 2003 23:23:33 -0700 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 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/410 X-Sequence-Number: 4158 It's a slight improvement, but that could be other things as well. I'd read that how you tune Postgres will determine how the optimizer works on a query (sequential scan vs index scan). I am going to post all I've done with tuning tommorow, and see if I've done anything dumb. I've found some contradictory advice, and I'm still a bit hazy on how/why Postgres trusts the OS to do caching. I'll post it all tommorow. ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- ---------------- Merge Join (cost=11819.21..15258.55 rows=12007 width=752) (actual time=4107.64..5587.81 rows=20880 loops=1) Merge Cond: ("outer".commercial_entity_id = "inner".commercial_entity_id) -> Index Scan using comm_serv_comm_ent_id_i on commercial_service cs (cost=0.00..3015.53 rows=88038 width=12) (actual time=0.05..487.23 rows=88038 loops=1) -> Sort (cost=11819.21..11846.08 rows=10752 width=740) (actual time=3509.07..3955.15 rows=25098 loops=1) Sort Key: ce.commercial_entity_id -> Merge Join (cost=0.00..9065.23 rows=10752 width=740) (actual time=0.18..2762.13 rows=7990 loops=1) Merge Cond: ("outer".user_account_id = "inner".user_account_id) -> Index Scan using user_account_pkey on user_account (cost=0.00..8010.39 rows=72483 width=716) (actual time=0.05..2220.86 rows=72483 loops=1) -> Index Scan using comm_ent_usr_acc_id_i on commercial_entity ce (cost=0.00..4787.69 rows=78834 width=24) (actual time=0.02..55.64 rows=7991 loops=1) Total runtime: 226239.77 msec (10 rows) David ----- Original Message ----- From: "Stephan Szabo" To: "David Griffiths" Cc: Sent: Sunday, October 12, 2003 6:48 PM Subject: Re: [PERFORM] Another weird one with an UPDATE > On Sun, 12 Oct 2003, David Griffiths wrote: > > > [snip] > > > > > I think you want something like: > > > UPDATE user_account SET last_name = 'abc' > > > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs > > > WHERE user_account.user_account_id = ce.user_account_id AND > > > ce.commercial_entity_id = cs.commercial_entity_id); > > > > Unfort, this is still taking a long time. > > Hmm, does > UPDATE user_account SET last_name='abc' > FROM commercial_entity ce, commercial_service cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id=cs.commercial_entity_id; > give the right results... That might end up being faster. From pgsql-performance-owner@postgresql.org Mon Oct 13 04:36:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A4FA6D1B4FC for ; Mon, 13 Oct 2003 07:36:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37671-09 for ; Mon, 13 Oct 2003 04:35:49 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id 29C8FD1B4E3 for ; Mon, 13 Oct 2003 04:34:46 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h9D7WD4r051849; Mon, 13 Oct 2003 10:32:17 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h9D7W3pr051842; Mon, 13 Oct 2003 10:32:04 +0300 (EEST) (envelope-from ant@imt.com.ua) Date: Mon, 13 Oct 2003 10:32:03 +0300 (EEST) From: Andriy Tkachuk To: Gaetano Mendola Cc: "pgsql-performance@postgresql.org" Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql In-Reply-To: <3F89C798.4090402@bigfoot.com> Message-ID: <20031013101614.A51447-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/411 X-Sequence-Number: 4159 Oh, Gaetano, didn't you see in my first letter of this topic that args are the same in session (they are constant)? The first paragraf of my first letter of this topic was: < Hi folks. I notice that immutable flag does nothing when i invoke < my plpgsql function within one session with same args. ^^^^^^^^^^^^^^ ... ok, mabe i should say "constant args" as in doc. Anyway, thank you for attention and willing to help. regards, andriy tkachuk (http://imt.com.ua) On Sun, 12 Oct 2003, Gaetano Mendola wrote: > Andriy Tkachuk wrote: > > > On Thu, 9 Oct 2003, Gaetano Mendola wrote: > >>Andriy Tkachuk wrote: > >>>On Wed, 8 Oct 2003, Tom Lane wrote: > >>>>Andriy Tkachuk writes: > >>>>>At second. calc_total() is immutable function: > >>>>>but it seems that it's not cached in one session: > >>>> > >>>>It's not supposed to be. > >>> > >>> > >>>but it's written id doc: > >>> > >>> IMMUTABLE indicates that the function always returns the same > >>> result when given the same argument values; that is, it does not > >>> do database lookups or otherwise use information not directly > >>> present in its parameter list. If this option is given, any call > >>> of the function with all-constant arguments can be immediately > >>> replaced with the function value. > >> > >>The doc say "can be" not must and will be. > > > > > > ok, but on what it depends on? > > For example in: > > select * from T where f_immutable ( 4 ) = T.id; > > > in this case f_immutable will be evaluated once. > > > > select * from T where f_immutable ( T.id ) = X; > > here f_immutable will be avaluated for each different T.id. > > Regards > Gaetano Mendola From pgsql-performance-owner@postgresql.org Mon Oct 13 05:54:26 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E8123D1B4FF for ; Mon, 13 Oct 2003 08:54:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 49050-07 for ; Mon, 13 Oct 2003 05:53:36 -0300 (ADT) Received: from pool.imt.com.ua (office.imt.com.ua [212.109.53.33]) by svr1.postgresql.org (Postfix) with ESMTP id 4ABD7D1B4E1 for ; Mon, 13 Oct 2003 05:53:30 -0300 (ADT) Received: from pool.imt.com.ua (localhost [127.0.0.1]) by pool.imt.com.ua (8.12.8p2/8.12.8) with ESMTP id h9D8rM4r052930; Mon, 13 Oct 2003 11:53:22 +0300 (EEST) (envelope-from ant@imt.com.ua) Received: from localhost (ant@localhost) by pool.imt.com.ua (8.12.8p2/8.12.8/Submit) with ESMTP id h9D8rDeG052927; Mon, 13 Oct 2003 11:53:19 +0300 (EEST) (envelope-from ant@imt.com.ua) Date: Mon, 13 Oct 2003 11:53:12 +0300 (EEST) From: Andriy Tkachuk To: Bill Moran Cc: johnnnnnn , Subject: Re: One or more processor ? In-Reply-To: <3F86EBD0.3050609@potentialtech.com> Message-ID: <20031013115204.S51447-100000@pool.imt.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/412 X-Sequence-Number: 4160 On Fri, 10 Oct 2003, Bill Moran wrote: > johnnnnnn wrote: > > On Fri, Oct 10, 2003 at 12:42:04PM -0400, Bill Moran wrote: > > > >>4) It simply isn't practical to expect a single query to > >> execute on multiple processors simultaneously. > >> > >>Do you know of any RDBMS that actually will execute a single query > >>on multiple processors? > > > > Yes, DB2 will do this if configured correctly. It's very useful for > > large, complicated queries that have multiple subplans. > > I expected there would be someone who did (although I didn't know for > sure). > > Is DB2 the only one that can do that? Oracle, i think, on partitioned tables. regards, andriy http://www.imt.com.ua From pgsql-performance-owner@postgresql.org Mon Oct 13 06:05:41 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E5A82D1B4E1 for ; Mon, 13 Oct 2003 09:05:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59322-01 for ; Mon, 13 Oct 2003 06:04:51 -0300 (ADT) Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) by svr1.postgresql.org (Postfix) with ESMTP id EF8A5D1B519 for ; Mon, 13 Oct 2003 06:04:48 -0300 (ADT) Received: from ALGOL.sollentuna.se (janus-en.sollentuna.se [195.84.163.194]) by mx-2.sollentuna.net (Postfix) with ESMTP id 9B53C3405F; Mon, 13 Oct 2003 12:04:39 +0200 (CEST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Subject: Re: One or more processor ? Date: Mon, 13 Oct 2003 11:04:44 +0200 Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE1E1877@algol.sollentuna.se> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] One or more processor ? Thread-Index: AcORZ6khXi3VK6N9S1q2WyGpYSeaoAAAQqsQ From: "Magnus Hagander" To: "Andriy Tkachuk" , "Bill Moran" Cc: "johnnnnnn" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/413 X-Sequence-Number: 4161 Actually, even Microsoft SQL Server will do this for you (you can even chose if it shoudl split it up on all processors or a maximum number). Will do it on any types of queries, as long as they're big enough (you can tweak the cost limit, but the general idea is only process CPU-expensive queries that way) //Magnus > -----Original Message----- > From: Andriy Tkachuk [mailto:ant@imt.com.ua]=20 > Sent: Monday, October 13, 2003 10:53 AM > To: Bill Moran > Cc: johnnnnnn; pgsql-performance@postgresql.org > Subject: Re: [PERFORM] One or more processor ? >=20 >=20 > On Fri, 10 Oct 2003, Bill Moran wrote: >=20 > > johnnnnnn wrote: > > > On Fri, Oct 10, 2003 at 12:42:04PM -0400, Bill Moran wrote: > > > > > >>4) It simply isn't practical to expect a single query to > > >> execute on multiple processors simultaneously. > > >> > > >>Do you know of any RDBMS that actually will execute a=20 > single query=20 > > >>on multiple processors? > > > > > > Yes, DB2 will do this if configured correctly. It's very=20 > useful for=20 > > > large, complicated queries that have multiple subplans. > > > > I expected there would be someone who did (although I=20 > didn't know for=20 > > sure). > > > > Is DB2 the only one that can do that? >=20 > Oracle, i think, on partitioned tables. >=20 > regards, andriy >=20 http://www.imt.com.ua ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Mon Oct 13 06:11:35 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A9C2BD1B4FE for ; Mon, 13 Oct 2003 09:11:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 55970-07 for ; Mon, 13 Oct 2003 06:10:46 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id DC6BFD1B4E1 for ; Mon, 13 Oct 2003 06:10:43 -0300 (ADT) Received: from [192.168.10.43] ([192.168.10.43]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9D9DIr32160 for ; Mon, 13 Oct 2003 04:13:18 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: Date: Mon, 13 Oct 2003 04:12:27 -0500 To: pgsql-performance@postgresql.org From: Seum-Lim Gan Subject: Performance, vacuum and reclaiming space, fsm Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/414 X-Sequence-Number: 4162 Hi, I did a search in the discussion lists and found several pointers about setting the max_fsm_relations and pages. I have a table that keeps being updated and noticed that after a few days, the disk usage has growned to from just over 150 MB to like 2 GB ! I followed the recommendations from the various search of the archives, changed the max_fsm_relations, pages, keep doing vacuum like every minute while the table of interest in being updated. I kept watching the disk space usage and still noticed that it continues to increase. Looks like vacuum has no effect. I did vacuum tablename and don't intend to use the full option since it locks the table. I have 7.3.3 running in Solaris 9. Any recommendation ? Thanks. Gan -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Oct 13 06:23:37 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C8682D1B503 for ; Mon, 13 Oct 2003 09:23:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48581-10 for ; Mon, 13 Oct 2003 06:23:09 -0300 (ADT) Received: from smtp.blueyonder.co.uk (82-34-96-210.cable.ubr06.gill.blueyonder.co.uk [82.34.96.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3DC10D1B4F0 for ; Mon, 13 Oct 2003 06:23:06 -0300 (ADT) Received: from reddragon.localdomain ([127.0.0.1] helo=localhost) by smtp.blueyonder.co.uk with esmtp (Exim 4.10) id 1A8yux-0001vY-00; Mon, 13 Oct 2003 10:23:07 +0100 Date: Mon, 13 Oct 2003 10:23:07 +0100 (BST) From: Peter Childs X-X-Sender: peter@RedDragon.Childs To: Seum-Lim Gan Cc: pgsql-performance@postgresql.org Subject: Re: Performance, vacuum and reclaiming space, fsm In-Reply-To: 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: 200310/415 X-Sequence-Number: 4163 On Mon, 13 Oct 2003, Seum-Lim Gan wrote: > Hi, > > I did a search in the discussion lists and found several > pointers about setting the max_fsm_relations and pages. > > I have a table that keeps being updated and noticed > that after a few days, the disk usage has growned to > from just over 150 MB to like 2 GB ! > > I followed the recommendations from the various search > of the archives, changed the max_fsm_relations, pages, > keep doing vacuum like every minute while the > table of interest in being updated. I kept > watching the disk space usage and still noticed that > it continues to increase. > > Looks like vacuum has no effect. > > I did vacuum tablename and don't intend to use > the full option since it locks the table. > > I have 7.3.3 running in Solaris 9. > > Any recommendation ? > > Thanks. > > Gan > Try auto_vacuum (its in the 7.4beta4 contrib directory) I find it very useful. Often you find that every minute in fact can be a little too often. My table updates every couple of seconds but is vacuumed (automatically) every hmm hour. If you have lots of overlapping vacumms and or editing connections records may be held on to by one vacuum so the next can't do its job. Always ensure that there is only one vacuum process. (You can't do this easily with cron!) I'm still using 7.3.2. 7.3.3 is sposed to have some big bugs and 7.3.4 was produced within 24 hours.(must upgrade at some point) Oh yes Index have problems (I think this is fix in later versions...) so you might want to try reindex. They are all worth a try its a brief summary of what been on preform for weeks and weeks now. Peter Childs From pgsql-performance-owner@postgresql.org Mon Oct 13 06:26:17 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 79B16D1B4F4 for ; Mon, 13 Oct 2003 09:26:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 65662-03 for ; Mon, 13 Oct 2003 06:25:28 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 48489D1B505 for ; Mon, 13 Oct 2003 06:25:24 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9D9Vawp028981 for ; Mon, 13 Oct 2003 15:01:36 +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 h9D9VZwc028955; Mon, 13 Oct 2003 15:01:35 +0530 Message-ID: <3F8A6F82.6030300@persistent.co.in> Date: Mon, 13 Oct 2003 14:55:22 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Seum-Lim Gan Cc: pgsql-performance@postgresql.org Subject: Re: Performance, vacuum and reclaiming space, fsm 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: 200310/416 X-Sequence-Number: 4164 Seum-Lim Gan wrote: > I have a table that keeps being updated and noticed > that after a few days, the disk usage has growned to > from just over 150 MB to like 2 GB ! Hmm... You have quite a lot of wasted space there.. > > I followed the recommendations from the various search > of the archives, changed the max_fsm_relations, pages, > keep doing vacuum like every minute while the > table of interest in being updated. I kept > watching the disk space usage and still noticed that > it continues to increase. That will help if your table is in good shape. Otherwise it will have little effect particularly after such amount of wasted space. > Looks like vacuum has no effect. Its not that. > I did vacuum tablename and don't intend to use > the full option since it locks the table. You got to do that. simple vacuum keeps a running instance of server clean. But once dead tuples spill to disk, nothing but vacumm full can reclaim that space. And don't forget, you got to reindex the indexes as well. Once your table is in good shape, you can tune max_fsm_* and vacuum once a minute. That will keep it good.. > I have 7.3.3 running in Solaris 9. > > Any recommendation ? HTH Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 13 07:28:19 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3C149D1B4F0 for ; Mon, 13 Oct 2003 10:28:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67331-06 for ; Mon, 13 Oct 2003 07:27:28 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 99700D1B4E1 for ; Mon, 13 Oct 2003 07:27:24 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9DAXdSg023601 for ; Mon, 13 Oct 2003 16:03:39 +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 h9DAXawc023545; Mon, 13 Oct 2003 16:03:38 +0530 Message-ID: <3F8A7E0B.8040202@persistent.co.in> Date: Mon, 13 Oct 2003 15:57:23 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Another weird one with an UPDATE References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> <20031012184536.N5307@megazone.bigpanda.com> <098b01c39152$921632e0$6501a8c0@griffiths2> In-Reply-To: <098b01c39152$921632e0$6501a8c0@griffiths2> 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: 200310/417 X-Sequence-Number: 4165 David Griffiths wrote: > It's a slight improvement, but that could be other things as well. > > I'd read that how you tune Postgres will determine how the optimizer works > on a query (sequential scan vs index scan). I am going to post all I've done > with tuning tommorow, and see if I've done anything dumb. I've found some > contradictory advice, and I'm still a bit hazy on how/why Postgres trusts > the OS to do caching. I'll post it all tommorow. > > ---------------------------------------------------------------------------- > ---------------------------------------------------------------------------- > ---------------- > Merge Join (cost=11819.21..15258.55 rows=12007 width=752) (actual > time=4107.64..5587.81 rows=20880 loops=1) > Merge Cond: ("outer".commercial_entity_id = "inner".commercial_entity_id) > -> Index Scan using comm_serv_comm_ent_id_i on commercial_service cs > (cost=0.00..3015.53 rows=88038 width=12) (actual time=0.05..487.23 > rows=88038 loops=1) > -> Sort (cost=11819.21..11846.08 rows=10752 width=740) (actual > time=3509.07..3955.15 rows=25098 loops=1) > Sort Key: ce.commercial_entity_id I think this is the problem. Is there an index on ce.commercial_entity_id? > -> Merge Join (cost=0.00..9065.23 rows=10752 width=740) (actual > time=0.18..2762.13 rows=7990 loops=1) > Merge Cond: ("outer".user_account_id = > "inner".user_account_id) > -> Index Scan using user_account_pkey on user_account > (cost=0.00..8010.39 rows=72483 width=716) (actual time=0.05..2220.86 > rows=72483 loops=1) > -> Index Scan using comm_ent_usr_acc_id_i on > commercial_entity ce (cost=0.00..4787.69 rows=78834 width=24) (actual > time=0.02..55.64 rows=7991 loops=1) In this case of comparing account ids, its using two index scans. In the entity field though, it chooses a sort. I think there is an index missing. The costs are also shot up as well. > Total runtime: 226239.77 msec Standard performance question. What was the last time these tables/database were vacuumed. Have you tuned postgresql.conf correctly? HTH Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 13 10:36:19 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0141FD1B4E5 for ; Mon, 13 Oct 2003 13:36:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04208-02 for ; Mon, 13 Oct 2003 10:35:31 -0300 (ADT) Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) by svr1.postgresql.org (Postfix) with ESMTP id 24029D1B4E3 for ; Mon, 13 Oct 2003 10:35:28 -0300 (ADT) Received: by yertle.kcilink.com (Postfix, from userid 100) id 282E62178C; Mon, 13 Oct 2003 09:35:17 -0400 (EDT) From: Vivek Khera MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16266.43541.10798.861464@yertle.int.kciLink.com> Date: Mon, 13 Oct 2003 09:35:17 -0400 To: Bruce Momjian Cc: pgsql-performance@postgresql.org Subject: Re: further testing on IDE drives In-Reply-To: <200310102122.h9ALMvo12903@candle.pha.pa.us> References: <200310102122.h9ALMvo12903@candle.pha.pa.us> X-Mailer: VM 7.14 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/418 X-Sequence-Number: 4166 >>>>> "BM" == Bruce Momjian writes: BM> COPY only does fsync on COPY completion, so I am not sure there are BM> enough fsync's there to make a difference. Perhaps then it is part of the indexing that takes so much time with the WAL. When I applied Marc's WAL disabling patch, it shaved nearly 50 minutes off of a 4-hour restore. I sent to Tom the logs from the restores since he was interested in figuring out where the time was saved. From pgsql-performance-owner@postgresql.org Mon Oct 13 10:51:09 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id D8F20D1B4FF for ; Mon, 13 Oct 2003 13:51:07 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 04993-04 for ; Mon, 13 Oct 2003 10:50:21 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id 8E204D1B51B for ; Mon, 13 Oct 2003 10:50:17 -0300 (ADT) Received: from [192.168.10.43] ([192.168.10.43]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9DDr3r00397 for ; Mon, 13 Oct 2003 08:53:03 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: In-Reply-To: <3F8A6F82.6030300@persistent.co.in> References: <3F8A6F82.6030300@persistent.co.in> Date: Mon, 13 Oct 2003 08:52:05 -0500 To: pgsql-performance@postgresql.org From: Seum-Lim Gan Subject: Re: Performance, vacuum and reclaiming space, fsm Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/420 X-Sequence-Number: 4168 I am not sure I can do the full vacuum. If my system is doing updates in realtime and needs to be ok 24 hours and 7 days a week non-stop, once I do vacuum full, even on that table, that table will get locked out and any quiery or updates that come in will timeout. Any suggestion on what to do besides shutting down to do full vacuum ? Peter Child also mentions there is indexing bugs. Is this fixed in 7.3.4 ? I did notice after the database grew in disk usage, its performance greatly decreases ! Gan >Seum-Lim Gan wrote: >>I have a table that keeps being updated and noticed >>that after a few days, the disk usage has growned to >>from just over 150 MB to like 2 GB ! > >Hmm... You have quite a lot of wasted space there.. >> >>I followed the recommendations from the various search >>of the archives, changed the max_fsm_relations, pages, >>keep doing vacuum like every minute while the >>table of interest in being updated. I kept >>watching the disk space usage and still noticed that >>it continues to increase. > >That will help if your table is in good shape. Otherwise it will >have little effect particularly after such amount of wasted space. > >>Looks like vacuum has no effect. > >Its not that. > >>I did vacuum tablename and don't intend to use >>the full option since it locks the table. > >You got to do that. simple vacuum keeps a running instance of server >clean. But once dead tuples spill to disk, nothing but vacumm full >can reclaim that space. > >And don't forget, you got to reindex the indexes as well. > >Once your table is in good shape, you can tune max_fsm_* and vacuum >once a minute. That will keep it good.. > >>I have 7.3.3 running in Solaris 9. >> >>Any recommendation ? > > HTH > > Shridhar -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Oct 13 11:05:22 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DA3D2D1B503 for ; Mon, 13 Oct 2003 14:05:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07158-03 for ; Mon, 13 Oct 2003 11:04:34 -0300 (ADT) Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) by svr1.postgresql.org (Postfix) with ESMTP id 0A97AD1B511 for ; Mon, 13 Oct 2003 11:04:31 -0300 (ADT) Received: by yertle.kcilink.com (Postfix, from userid 100) id 982DA2178C; Mon, 13 Oct 2003 10:04:35 -0400 (EDT) From: Vivek Khera MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16266.45299.517752.465494@yertle.int.kciLink.com> Date: Mon, 13 Oct 2003 10:04:35 -0400 To: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL In-Reply-To: <20031011092308.GA39942@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <3F87932B.4050507@familyhealth.com.au> <20031011092308.GA39942@perrin.nxad.com> X-Mailer: VM 7.14 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/421 X-Sequence-Number: 4169 >>>>> "SC" == Sean Chittenden writes: >> echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" >> >> I've used it for my dedicated servers. Is this calculation correct? SC> Yes, or it's real close at least. vfs.hibufspace is the amount of SC> kernel space that's used for caching IO operations (minus the I'm just curious if anyone has a tip to increase the amount of memory FreeBSD will use for the cache? It appears to me that even on my 2Gb box, lots of memory is 'free' that could be used for the cache (bumping up shared buffers is another option...) yet the disk is being highly utilized according to systat. From pgsql-performance-owner@postgresql.org Mon Oct 13 11:05:59 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6B5B8D1B503 for ; Mon, 13 Oct 2003 14:05:58 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 07554-01 for ; Mon, 13 Oct 2003 11:05:12 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 50287D1B4E5 for ; Mon, 13 Oct 2003 11:05:07 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9DEBPcx011089 for ; Mon, 13 Oct 2003 19:41:25 +0530 Received: from daithan.intranet.pspl.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 h9DEBOwc011063; Mon, 13 Oct 2003 19:41:24 +0530 From: Shridhar Daithankar To: Seum-Lim Gan Subject: Re: Performance, vacuum and reclaiming space, fsm Date: Mon, 13 Oct 2003 19:37:14 +0530 User-Agent: KMail/1.5.2 References: <3F8A6F82.6030300@persistent.co.in> 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: <200310131937.14785.shridhar_daithankar@persistent.co.in> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/422 X-Sequence-Number: 4170 On Monday 13 October 2003 19:22, Seum-Lim Gan wrote: > I am not sure I can do the full vacuum. > If my system is doing updates in realtime and needs to be > ok 24 hours and 7 days a week non-stop, once I do > vacuum full, even on that table, that table will > get locked out and any quiery or updates that come in > will timeout. If you have 150MB type of data as you said last time, you could take a pg_dump of database, drop the database and recreate it. By all chances it will take less time than compacting a database from 2GB to 150MB. It does involve downtime but can't help it. Thats closet you can get. > Any suggestion on what to do besides shutting down to > do full vacuum ? Drop the indexes and recreate them. While creating the index, all the updates will be blocked anyways. > Peter Child also mentions there is indexing bugs. > Is this fixed in 7.3.4 ? I did notice after the database No. It is fixed in 7.4 and 7.4 is in beta still.. > grew in disk usage, its performance greatly decreases ! Obviously that is due to unnecessary IO it has to do. Thing is your database has reached a state that is really bad for it's operation. I strongly encourage you to recreate the database from backup, from scratch, tune postgresql properly and run autovacuum daemon from 7.4 source dir. Besides that you would need to reindex nightly or per 5-6 hour depending upon rate of insertion. Check http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html for performance tuning starter tips.. HTH Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 13 11:13:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6D1F9D1B4FF for ; Mon, 13 Oct 2003 14:13:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03829-09 for ; Mon, 13 Oct 2003 11:12:52 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id DDC73D1B514 for ; Mon, 13 Oct 2003 11:12:46 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9DEJ6AP013610 for ; Mon, 13 Oct 2003 19:49:06 +0530 Received: from daithan.intranet.pspl.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 h9DEJ5wc013583; Mon, 13 Oct 2003 19:49:05 +0530 From: Shridhar Daithankar To: Vivek Khera , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Mon, 13 Oct 2003 19:44:55 +0530 User-Agent: KMail/1.5.2 References: <007901c38f2b$0b585590$2802a8c0@webbased10> <20031011092308.GA39942@perrin.nxad.com> <16266.45299.517752.465494@yertle.int.kciLink.com> In-Reply-To: <16266.45299.517752.465494@yertle.int.kciLink.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310131944.55273.shridhar_daithankar@persistent.co.in> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/423 X-Sequence-Number: 4171 On Monday 13 October 2003 19:34, Vivek Khera wrote: > >>>>> "SC" == Sean Chittenden writes: > >> > >> echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" > >> > >> I've used it for my dedicated servers. Is this calculation correct? > > SC> Yes, or it's real close at least. vfs.hibufspace is the amount of > SC> kernel space that's used for caching IO operations (minus the > > I'm just curious if anyone has a tip to increase the amount of memory > FreeBSD will use for the cache? It appears to me that even on my 2Gb > box, lots of memory is 'free' that could be used for the cache > (bumping up shared buffers is another option...) yet the disk is being > highly utilized according to systat. Is this of any help?..reverse video sucks though.. especially spec'ed person like me.. http://unix.derkeiler.com/Mailing-Lists/FreeBSD/performance/2003-07/0073.html Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 13 10:39:15 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7A5E4D1B4E3 for ; Mon, 13 Oct 2003 13:39:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03836-02 for ; Mon, 13 Oct 2003 10:38:29 -0300 (ADT) Received: from correo (correo.qoslabs.com [157.238.87.78]) by svr1.postgresql.org (Postfix) with ESMTP id 29736D1B50D for ; Mon, 13 Oct 2003 10:38:25 -0300 (ADT) Received: from ingridma (customer-148-233-235-189.uninet.net.mx [148.233.235.189]) by correo-01.qoslabs.com (iPlanet Messaging Server 5.2 HotFix 1.09 (built Jan 7 2003)) with ESMTP id <0HMP000OD77UZZ@correo-01.qoslabs.com> for pgsql-performance@postgresql.org; Mon, 13 Oct 2003 09:38:27 -0400 (EDT) Date: Mon, 13 Oct 2003 08:38:25 -0600 From: ingrim Subject: unsuscribe mailing list In-reply-to: <16263.8497.95525.673249@yertle.int.kciLink.com> To: pgsql-performance@postgresql.org Message-id: <002601c39197$ac832170$7d64a8c0@ingridma> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Mailer: Microsoft Outlook, Build 10.0.3416 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/419 X-Sequence-Number: 4167 -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Vivek Khera Sent: Viernes, 10 de Octubre de 2003 03:14 p.m. To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] go for a script! / ex: PostgreSQL vs. MySQL >>>>> "JB" == Josh Berkus writes: JB> Vivek, NB> shared_buffers = 1/16th of total memory NB> effective_cache_size = 80% of the supposed kernel cache. >> >> Please take into account the blocksize compiled into PG, too... JB> We can;t change the blocksize in a script that only does the .conf JB> file. Or are you suggesting something else? when you compute optimal shared buffers and effective cache size, these are in terms of blocksize. so if I have 16k block size, you can't compute based on default 8k blocksize. at worst, it would have to be a parameter you pass to the tuning script. ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings From pgsql-performance-owner@postgresql.org Mon Oct 13 12:06:38 2003 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BE198D1B4E3 for ; Mon, 13 Oct 2003 15:06:36 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 17572-04 for ; Mon, 13 Oct 2003 12:05:51 -0300 (ADT) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 671DAD1B4E5 for ; Mon, 13 Oct 2003 12:05:46 -0300 (ADT) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.5) with ESMTP-TLS id 424127; Mon, 13 Oct 2003 08:04:55 -0700 Message-ID: <3F8ABEFB.4010107@joeconway.com> Date: Mon, 13 Oct 2003 08:04:27 -0700 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: David Griffiths Cc: pgsql-performance@postgresql.org Subject: Re: Another weird one with an UPDATE References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> <3F8A01CE.2040003@joeconway.com> <098a01c39152$3e231c20$6501a8c0@griffiths2> In-Reply-To: <098a01c39152$3e231c20$6501a8c0@griffiths2> 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: 200310/424 X-Sequence-Number: 4172 David Griffiths wrote: > Yes, the query operates only on indexed columns (all numeric(10)'s). > > Column | Type | > Modifiers > -------------------------------+-----------------------------+-------------- > --------------- > user_account_id | numeric(10,0) | not null > [snip] > Indexes: user_account_pkey primary key btree (user_account_id), > Foreign Key constraints: $1 FOREIGN KEY (lang_id) REFERENCES lang(lang_id) > ON UPDATE NO ACTION ON DELETE NO ACTION, > $2 FOREIGN KEY (source_id) REFERENCES > source(source_id) ON UPDATE NO ACTION ON DELETE NO ACTION, > $3 FOREIGN KEY (user_role_id) REFERENCES > user_role(user_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION And what about commercial_entity.user_account_id. Is it indexed and what is its data type (i.e. does it match numeric(10,0))? Also, have you run VACUUM ANALYZE lately? Joe From pgsql-performance-owner@postgresql.org Mon Oct 13 16:45: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 1355FD1B515 for ; Mon, 13 Oct 2003 19:45: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 16108-06 for ; Mon, 13 Oct 2003 16:44:45 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 6F891D1B532 for ; Mon, 13 Oct 2003 16:44:46 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 071D03E38 for ; Mon, 13 Oct 2003 11:37:57 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 29537-03 for ; Mon, 13 Oct 2003 11:37:56 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 53F793E37 for ; Mon, 13 Oct 2003 11:37:56 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9DFbsRR032502 for pgsql-performance@postgresql.org; Mon, 13 Oct 2003 11:37:54 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Mon, 13 Oct 2003 11:37:53 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 18 Message-ID: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <200310101338.18167.josh@agliodbs.com> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066059474 42314 216.194.193.105 (13 Oct 2003 15:37:54 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 13 Oct 2003 15:37:54 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:11lRV14VEcLMURmf1f84jcjwB2c= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/431 X-Sequence-Number: 4179 >>>>> "CK" == Christopher Kings-Lynne writes: >> If shmmax and shmmall are too small, then: >> PostgreSQL requires some more shared memory to cache some tables, x >> Mb, do you want to increase your OS kernel parameters? >> Tweak shmmax and shmmall CK> Note that this still requires a kernel recompile on FreeBSD :( According to whom? sysctl is your friend. Some sysctl settings may require reboot, but I don't think the SHM ones do. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 13 16:11: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 06EB5D1B546 for ; Mon, 13 Oct 2003 19:11: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 00251-10 for ; Mon, 13 Oct 2003 16:11:26 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 56B7CD1B50E for ; Mon, 13 Oct 2003 16:11:27 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id A9BB73E44 for ; Mon, 13 Oct 2003 11:39:04 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 29537-03-2 for ; Mon, 13 Oct 2003 11:39:04 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 2DE053E37 for ; Mon, 13 Oct 2003 11:39:04 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9DFd4Hw035509 for pgsql-performance@postgresql.org; Mon, 13 Oct 2003 11:39:04 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Mon, 13 Oct 2003 11:39:03 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 21 Message-ID: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.josh@agliodbs.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066059544 42314 216.194.193.105 (13 Oct 2003 15:39:04 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 13 Oct 2003 15:39:04 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:YOW28BMekEybdBmRG8aNs3qONsk= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/429 X-Sequence-Number: 4177 >>>>> "JB" == Josh Berkus writes: JB> Chris, >> > PostgreSQL requires some more shared memory to cache some tables, x Mb, >> > do you want to increase your OS kernel parameters? >> > >> > Tweak shmmax and shmmall >> >> Note that this still requires a kernel recompile on FreeBSD :( JB> Not our fault, now is it? This would mean that we wouldn't be JB> able to script for FreeBSD. Bug the FreeBSD developers. "I read it on the net so it must be true" applies here. You /can/ set these values via sysctl calls. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 13 16:54: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 E6FD0D1B4FE for ; Mon, 13 Oct 2003 19:54: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 25032-01 for ; Mon, 13 Oct 2003 16:54:00 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 257F4D1B515 for ; Mon, 13 Oct 2003 16:54:01 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 034C93E60 for ; Mon, 13 Oct 2003 11:52:50 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 74350-05 for ; Mon, 13 Oct 2003 11:52:49 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 448543E45 for ; Mon, 13 Oct 2003 11:52:49 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9DFqjUJ003727 for pgsql-performance@postgresql.org; Mon, 13 Oct 2003 11:52:45 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Performance, vacuum and reclaiming space, fsm Date: Mon, 13 Oct 2003 11:52:44 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 51 Message-ID: References: <3F8A6F82.6030300@persistent.co.in> <200310131937.14785.shridhar_daithankar@persistent.co.in> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066060365 42314 216.194.193.105 (13 Oct 2003 15:52:45 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 13 Oct 2003 15:52:45 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:yTwS4qMnztVzr9+wyxa6DkgbeR8= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/432 X-Sequence-Number: 4180 >>>>> "SD" == Shridhar Daithankar writes: SD> If you have 150MB type of data as you said last time, you could SD> take a pg_dump of database, drop the database and recreate it. By SD> all chances it will take less time than compacting a database from SD> 2GB to 150MB. That's it? That's not so big of a disk footprint. SD> Drop the indexes and recreate them. While creating the index, all SD> the updates will be blocked anyways. Be *very careful* doing this, especially with UNIQUE indexes on a live system! My recommendation is to get a list of all indexes on your system with \di in psql, then running "reindex index XXXX" per index. Be sure to bump sort_mem beforehand. Here's a script I ran over the weekend (during early morning low-usage time) on my system: SET sort_mem = 131072; SELECT NOW(); SELECT relname,relpages FROM pg_class WHERE relname LIKE 'user_list%' ORDER BY relname; SELECT NOW(); REINDEX INDEX user_list_pkey ; SELECT NOW(); REINDEX INDEX user_list_XXX ; SELECT NOW(); REINDEX INDEX user_list_YYY ; SELECT NOW(); SELECT relname,relpages FROM pg_class WHERE relname LIKE 'user_list%' ORDER BY relname; The relpages used by the latter two indexes shrunk dramatically: user_list_XXX | 109655 user_list_YYY | 69837 to user_list_XXX | 57032 user_list_YYY | 30911 and disk usage went down quite a bit as well. Unfortunately, the pkey reindex failed due to a deadlock being detected, but the XXX index is most popular... This is my "hottest" table, so I reindex it about once a month. My other "hot" table takes 45 minutes per index to redo, so I try to avoid that until I *really* have to do it (about 6 months). I don't think you'll need a nightly reindex. Of course, regular vacuums throughout the day on the busy talbes help keep it from getting too fragmented. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 13 18:34: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 B4BCCD1B53F for ; Mon, 13 Oct 2003 21:34: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 43626-05 for ; Mon, 13 Oct 2003 18:33:47 -0300 (ADT) Received: from phaedrusdeinus.org (dsl092-130-239.chi1.dsl.speakeasy.net [66.92.130.239]) by svr1.postgresql.org (Postfix) with SMTP id 225E8D1B4E3 for ; Mon, 13 Oct 2003 18:33:46 -0300 (ADT) Received: (qmail 53286 invoked by uid 1001); 13 Oct 2003 16:19:59 -0000 Date: Mon, 13 Oct 2003 11:19:59 -0500 From: johnnnnnn To: pgsql-performance@postgresql.org, Chris Faulkner Subject: Re: sql performance and cache Message-ID: <20031013161959.GA29900@performics.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/434 X-Sequence-Number: 4182 On Sat, Oct 11, 2003 at 10:43:04AM +0100, Chris Faulkner wrote: > I have two very similar queries which I need to execute. They both > have exactly the same from / where conditions. When I execute the > first, it takes about 16 seconds. The second is executed almost > immediately after, it takes 13 seconds. In short, I'd like to know > why the query result isn't being cached and any ideas on how to > improve the execution. The way to do the type of caching you're talking about, if i understand you correctly, would be to create a temporary table. Specifically, create a temporary table with the results of the second query. Then run a select * on that table (with no where clause), and follow it with a select max(replace(...)) on the same table (no where clause). That guarantees two things: 1- The joins/filters are not parsed and evaluated twice, with the corresponding disk reads. 2- The data is exactly consistent between the two queries. Correct me if i misunderstood your problem. -johnnnnnnnnnn From pgsql-performance-owner@postgresql.org Mon Oct 13 15:44: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 02008D1B517 for ; Mon, 13 Oct 2003 18:44: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 00245-06 for ; Mon, 13 Oct 2003 15:44:07 -0300 (ADT) Received: from jamesr.best.vwh.net (jamesr.best.vwh.net [192.220.76.165]) by svr1.postgresql.org (Postfix) with SMTP id 10E70D1B50E for ; Mon, 13 Oct 2003 15:44:08 -0300 (ADT) Received: (qmail 63100 invoked by uid 19621); 13 Oct 2003 18:43:47 -0000 Received: from unknown (HELO ?10.0.0.210?) ([65.87.16.98]) (envelope-sender ) by 192.220.76.165 (qmail-ldap-1.03) with SMTP for ; 13 Oct 2003 18:43:47 -0000 Subject: Re: One or more processor ? From: James Rogers To: pgsql-performance@postgresql.org In-Reply-To: <20031013115204.S51447-100000@pool.imt.com.ua> References: <20031013115204.S51447-100000@pool.imt.com.ua> Content-Type: text/plain Organization: Message-Id: <1066070623.18133.15.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 13 Oct 2003 11:43:43 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/425 X-Sequence-Number: 4173 On Mon, 2003-10-13 at 01:53, Andriy Tkachuk wrote: > > >>Do you know of any RDBMS that actually will execute a single query > > >>on multiple processors? > > > > Oracle, i think, on partitioned tables. This makes a certain amount of sense. It be much easier to allow this on partitioned tables than in the general case, since partitioned tables look a lot like multiple relations hiding behind a view and one could simply run one thread per partition in parallel without any real fear of contention on the table. This is doubly useful since partitioned tables tend to be huge almost by definition. Offhand, it would seem that this would be a feature largely restricted to threaded database kernels for a couple different pragmatic reasons. Cheers, -James Rogers jamesr@best.com From pgsql-performance-owner@postgresql.org Mon Oct 13 15: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 1AA84D1B517 for ; Mon, 13 Oct 2003 18:56: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 00229-08 for ; Mon, 13 Oct 2003 15:55:53 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id 1E8E6D1B532 for ; Mon, 13 Oct 2003 15:55:54 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92KQX0>; Mon, 13 Oct 2003 11:54:07 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92KQX8; Mon, 13 Oct 2003 11:53:58 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <012b01c391bc$d06e6200$6501a8c0@griffiths2> References: <052001c39030$1ccc8020$6501a8c0@griffiths2> <05a401c3903f$a8524850$6501a8c0@griffiths2> <20031011153251.F57866@megazone.bigpanda.com> <080d01c3912a$1356dea0$6501a8c0@griffiths2> <3F8A01CE.2040003@joeconway.com> <098a01c39152$3e231c20$6501a8c0@griffiths2> <3F8ABEFB.4010107@joeconway.com> Subject: Re: Another weird one with an UPDATE Date: Mon, 13 Oct 2003 12:04:18 -0700 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 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/426 X-Sequence-Number: 4174 > And what about commercial_entity.user_account_id. Is it indexed and what > is its data type (i.e. does it match numeric(10,0))? Yup - all columns in the statement are indexed, and they are all numeric(10,0). > Also, have you run VACUUM ANALYZE lately? Yup - just before the last run. Will get together my tuning data now. David From pgsql-performance-owner@postgresql.org Mon Oct 13 16:05: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 2FC72D1B532 for ; Mon, 13 Oct 2003 19:05: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 15626-06 for ; Mon, 13 Oct 2003 16:04:47 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 63B27D1B515 for ; Mon, 13 Oct 2003 16:04:48 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id C98032106E; Mon, 13 Oct 2003 12:04:46 -0700 (PDT) Date: Mon, 13 Oct 2003 12:04:46 -0700 From: Sean Chittenden To: Vivek Khera Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031013190446.GA72842@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <3F87932B.4050507@familyhealth.com.au> <20031011092308.GA39942@perrin.nxad.com> <16266.45299.517752.465494@yertle.int.kciLink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16266.45299.517752.465494@yertle.int.kciLink.com> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/427 X-Sequence-Number: 4175 > >> echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" > >> > >> I've used it for my dedicated servers. Is this calculation correct? > > SC> Yes, or it's real close at least. vfs.hibufspace is the amount > of SC> kernel space that's used for caching IO operations (minus the > > I'm just curious if anyone has a tip to increase the amount of > memory FreeBSD will use for the cache? Recompile your kernel with BKVASIZE set to 4 times its current value and double your nbuf size. According to Bruce Evans: "Actually there is a way: the vfs_maxbufspace gives the amount of space reserved for buffer kva (= nbuf * BKVASIZE). nbuf is easy to recover from this, and the buffer kva space may be what is wanted anyway." [snip] "I've never found setting nbuf useful, however. I want most parametrized sizes including nbuf to scale with resource sizes, and it's only with RAM sizes of similar sizes to the total virtual address size that its hard to get things to fit. I haven't hit this problem myself since my largest machine has only 1GB. I use an nbuf of something like twice the default one, and a BKVASIZE of 4 times the default. vfs.maxbufspace ends up at 445MB on the machine with 1GB, so it is maxed out now." YMMV. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Oct 13 16:10: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 23F66D1B517 for ; Mon, 13 Oct 2003 19:10: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 14772-07 for ; Mon, 13 Oct 2003 16:10:21 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 7B3EFD1B50E for ; Mon, 13 Oct 2003 16:10:22 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 4AB082106B; Mon, 13 Oct 2003 12:10:23 -0700 (PDT) Date: Mon, 13 Oct 2003 12:10:23 -0700 From: Sean Chittenden To: Josh Berkus Cc: Christopher Kings-Lynne , Nick Barr , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031013191023.GB72842@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310121331.42693.josh@agliodbs.com> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/428 X-Sequence-Number: 4176 > > > PostgreSQL requires some more shared memory to cache some > > > tables, x Mb, do you want to increase your OS kernel parameters? > > > > > > Tweak shmmax and shmmall > > > > Note that this still requires a kernel recompile on FreeBSD :( > > Not our fault, now is it? This would mean that we wouldn't be able > to script for FreeBSD. Bug the FreeBSD developers. And if you do so, you're going to hear that shm* is an antiquated interface that's dated, slow, inefficient and shouldn't be used. :) Every few months one of the uber core BSD hackers threatens to rewrite that part of PG because high up in the BSD camp, it's common belief that shm* is a source of performance loss for PostgreSQL. One of these days it'll happen, probably with mmap() mmap()'ing MAP_SHARED files stored in a $PGDATA/data/shared dir as mmap() is by far and away the fastest shared memory mechanism and certainly is very widely deployed (I would be surprised if any of the supported PG platforms didn't have mmap()). -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Mon Oct 13 16:35: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 DFDCCD1B536 for ; Mon, 13 Oct 2003 19:35: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 16265-06 for ; Mon, 13 Oct 2003 16:35:11 -0300 (ADT) Received: from boats_exch01.boats.com (h209-17-182-106.gtconnect.net [209.17.182.106]) by svr1.postgresql.org (Postfix) with ESMTP id B07AAD1B50E for ; Mon, 13 Oct 2003 16:35:11 -0300 (ADT) Received: by BOATS_EXCH01 with Internet Mail Service (5.5.2653.19) id <4S92KRKY>; Mon, 13 Oct 2003 12:33:26 -0700 Received: from GRIFFITHS2 ([192.168.12.192]) by boats_exch01.boats.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id 4S92KRKV; Mon, 13 Oct 2003 12:33:12 -0700 From: David Griffiths To: pgsql-performance@postgresql.org Message-ID: <039801c391c2$4b83d600$6501a8c0@griffiths2> Subject: Any issues with my tuning... Date: Mon, 13 Oct 2003 12:43:32 -0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0395_01C39187.9C4B7830" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4922.1500 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/430 X-Sequence-Number: 4178 This is a multi-part message in MIME format. ------=_NextPart_000_0395_01C39187.9C4B7830 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've been having performance issues with Postgres (sequential scans vs index scans in an update statement). I've read that optimizer will change it's plan based on the resources it thinks are available. In addition, I've read alot of conflicting info on various parameters, so I'd like to sort those out as well. =20 Here's the query I've been having problems with: =20 UPDATE user_account SET last_name=3D'abc' FROM commercial_entity ce, commercial_service cs WHERE user_account.user_account_id =3D ce.user_account_id AND ce.commercial_entity_id=3Dcs.commercial_entity_id; =20 or=20 =20 UPDATE user_account SET last_name =3D 'abc' WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service cs WHERE user_account.user_account_id =3D ce.user_account_id AND ce.commercial_entity_id =3D cs.commercial_entity_id); =20 Both are about the same. All columns are indexed; all column-types are the same (numeric(10,0)). A vacuum analyze was run just before the last attempt at running the above statement. =20 =20 MACHINE STATS --------------------------- The machine is a dual-Pentium 3 933mhz, 2 gig of RAM, RAID 5 (3xWestern Digital 80 gig drives with 8-meg buffers on 3Ware), Red Hat 9.0 =20 =20 POSTGRES TUNING INFO --------------------------------------- =20 Here are part of the contents of my sysctl.conf file (note that I've played with values as low as 600000 with no difference) kernel.shmmax=3D1400000000 kernel.shmall=3D1400000000 Here's the uncommented-lines from the postgresql.conf file (not the default one in the /usr/local/pgsql directory - I've initialzed the database on a different mount point with more space): =20 tcpip_socket =3D true max_connections =3D 500 shared_buffers =3D 96000 # min max_connections*2 or 16, 8KB each wal_buffers =3D 64 # min 4, typically 8KB each sort_mem =3D 2048 # min 64, size in KB effective_cache_size =3D 6000 # typically 8KB each LC_MESSAGES =3D 'en_US.UTF-8' LC_MONETARY =3D 'en_US.UTF-8' LC_NUMERIC =3D 'en_US.UTF-8' LC_TIME =3D 'en_US.UTF-8' Note that I've played with all these values; shared_buffers has been as low as 5000, and effective_cache_size has been as high as 50000. Sort mem has varied between 1024 bytes and 4096 bytes. wal_buffers have been between 16 and 128. =20 =20 INFO FROM THE MACHINE ----------------------------------------- Here are the vmstat numbers while running the query. =20 procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 0 1 2 261940 11624 110072 1334896 12 0 12 748 177 101 2 4 95 0 1 1 261940 11628 110124 1334836 0 0 0 1103 170 59 2 1 97 0 3 1 261928 11616 110180 1334808 3 0 6 1156 169 67 2 2 96 0 2 1 261892 11628 110212 1334636 7 0 7 1035 186 100 2 2 96 0 1 1 261796 11616 110272 1334688 18 0 18 932 169 79 2 1 97 0 1 1 261780 11560 110356 1334964 3 0 3 4155 192 118 2 7 92 0 1 1 261772 11620 110400 1334956 2 0 2 939 162 63 3 0 97 0 1 3 261744 11636 110440 1334872 6 0 9 1871 171 104 3 2 95 0 0 0 261744 13488 110472 1332244 0 0 0 922 195 1271 3 2 94 0 0 0 261744 13436 110492 1332244 0 0 0 24 115 47 0 1 99 0 0 0 261744 13436 110492 1332244 0 0 0 6 109 36 0 5 95 0 0 0 261744 13436 110492 1332244 0 0 0 6 123 63 0 0 100 0 0 0 261744 13436 110492 1332244 0 0 0 6 109 38 0 0 100 0 0 0 261744 13436 110492 1332244 0 0 0 6 112 39 0 1 99 I'm not overly familiar with Linux, but the swap in-out seems low, as does the io in-out. Have I allocated too much memory? Regardless, it doesn't explain why the optimizer would decide to do a sequential scan.=20 =20 Here's the explain-analyze: =20 Merge Join (cost=3D11819.21..15258.55 rows=3D12007 width=3D752) (actual time=3D4107.64..5587.81 rows=3D20880 loops=3D1) Merge Cond: ("outer".commercial_entity_id =3D "inner".commercial_entity_id) -> Index Scan using comm_serv_comm_ent_id_i on commercial_service cs (cost=3D0.00..3015.53 rows=3D88038 width=3D12) (actual time=3D0.05..487.23 rows=3D88038 loops=3D1) -> Sort (cost=3D11819.21..11846.08 rows=3D10752 width=3D740) (actual time=3D3509.07..3955.15 rows=3D25098 loops=3D1) Sort Key: ce.commercial_entity_id -> Merge Join (cost=3D0.00..9065.23 rows=3D10752 width=3D740) (actual time=3D0.18..2762.13 rows=3D7990 loops=3D1) Merge Cond: ("outer".user_account_id =3D "inner".user_account_id) -> Index Scan using user_account_pkey on user_account (cost=3D0.00..8010.39 rows=3D72483 width=3D716) (actual time=3D0.05..2220.86 rows=3D72483 loops=3D1) -> Index Scan using comm_ent_usr_acc_id_i on commercial_entity ce (cost=3D0.00..4787.69 rows=3D78834 width=3D24) (actual time=3D0.02..55.64 rows=3D7991 loops=3D1) Total runtime: 226239.77 msec (10 rows) =20 ------------------------------------------------------------ =20 Tied up in all this is my inability to grasp what shared_buffers do =20 =46rom " http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html ": =20 "shbufShared buffers defines a block of memory that PostgreSQL will use to hold requests that are awaiting attention from the kernel buffer and CPU." and "The shared buffers parameter assumes that OS is going to cache a lot of files and hence it is generally very low compared with system RAM." =20 =46rom " http://www.lyris.com/lm_help/6.0/tuning_postgresql.html " =20 "Increase the buffer size. Postgres uses a shared memory segment among its subthreads to buffer data in memory. The default is 512k, which is inadequate. On many of our installs, we've bumped it to ~16M, which is still small. If you can spare enough memory to fit your whole database in memory, do so." =20 Our database (in Oracle) is just over 4 gig in size; obviously, this won't comfortably fit in memory (though we do have an Opteron machine inbound for next week with 4-gig of RAM and SCSI hard-drives). The more of it we can fit in memory the better. =20 What about changing these costs - the doc at http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html doesn't go into a lot of detail. I was thinking that maybe the optimizer decided it was faster to do a sequential scan rather than an index scan based on an analysis of the cost using these values. =20 #random_page_cost =3D 4 # units are one sequential page fetch cost #cpu_tuple_cost =3D 0.01 # (same) #cpu_index_tuple_cost =3D 0.001 # (same) #cpu_operator_cost =3D 0.0025 # (same) =20 David ------=_NextPart_000_0395_01C39187.9C4B7830 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I've been having performance issues with P= ostgres=20 (sequential scans vs index scans in an update statement). I've read that=20 optimizer will change it's plan based on the resources it thinks are availa= ble.=20 In addition, I've read alot of conflicting info on various parameters, so I= 'd=20 like to sort those out as well.
 
Here's the query I've been having problems= =20 with:
 
UPDATE user_account SET last_name=3D'abc'<= BR>FROM=20 commercial_entity ce, commercial_service cs
WHERE=20 user_account.user_account_id =3D ce.user_account_id=20 AND
ce.commercial_entity_id=3Dcs.commercial_entity_id;
 
or
 
UPDATE user_account SET last_name =3D=20 'abc'
 WHERE EXISTS (SELECT 1 FROM commercial_entity ce,=20 commercial_service cs
 WHERE user_account.user_account_id =3D=20 ce.user_account_id AND
 ce.commercial_entity_id =3D=20 cs.commercial_entity_id);
 
Both are about the same.
All columns are indexed; all column-types = are the=20 same (numeric(10,0)). A vacuum analyze was run just before the last attempt= at=20 running the above statement.
 
 
MACHINE STATS
---------------------------
The machine is a dual-Pentium 3 933mhz, 2 = gig of=20 RAM, RAID 5 (3xWestern Digital 80 gig drives with 8-meg buffers on 3Ware), = Red=20 Hat 9.0
 
 
POSTGRES TUNING INFO
---------------------------------------
 
Here are part of the contents of my sysctl= .conf=20 file (note that I've played with values as low as 600000 with no=20 difference)
kernel.shmmax=3D1400000000
kernel.shmall=3D1400000000
Here's the uncommented-lines from the=20 postgresql.conf file (not the default one in the /usr/local/pgsql directory= -=20 I've initialzed the database on a different mount point with more=20 space):
 
tcpip_socket =3D true
max_connections = =3D=20 500
shared_buffers =3D=20 96000          # min=20 max_connections*2 or 16, 8KB each
wal_buffers =3D=20 64            &= nbsp;  =20 # min 4, typically 8KB each
sort_mem =3D=20 2048            = ;    =20 # min 64, size in KB
effective_cache_= size =3D=20 6000     # typically 8KB each
LC_MESSAGES =3D=20 'en_US.UTF-8'
LC_MONETARY =3D 'en_US.UTF-8'
LC_NUMERIC =3D=20 'en_US.UTF-8'
LC_TIME =3D 'en_US.UTF-8'
Note that I've played with all these value= s;=20 shared_buffers has been as low as 5000, and effective_cache_size has been a= s=20 high as 50000. Sort mem has varied between 1024 bytes and 4096 bytes.=20 wal_buffers have been between 16 and 128.
 
 
INFO FROM THE MACHINE
-----------------------------------------
Here are the vmstat numbers while running = the=20 query.
 
  =20 procs           &nbs= p;         =20 memory     =20 swap         =20 io     system     =20 cpu
 r  b  w   swpd   free  = ;=20 buff  cache   si   so   =20 bi    bo   in    cs us sy=20 id
 0  1  2 261940  11624 110072 1334896  = =20 12    0    12   748 =20 177   101  2  4 95
 0  1  1 261940&nb= sp;=20 11628 110124 1334836    0   =20 0     0  1103  170    59 = =20 2  1 97
 0  3  1 261928  11616 110180=20 1334808    3    0     6&n= bsp;=20 1156  169    67  2  2 96
 0  2&n= bsp;=20 1 261892  11628 110212 1334636    7   = =20 0     7  1035  186   100  2&nb= sp; 2=20 96
 0  1  1 261796  11616 110272 1334688  = =20 18    0    18   932 =20 169    79  2  1 97
 0  1  1=20 261780  11560 110356 1334964    3   =20 0     3  4155  192   118  2&nb= sp; 7=20 92
 0  1  1 261772  11620 110400=20 1334956    2    0    =20 2   939  162    63  3  0=20 97
 0  1  3 261744  11636 110440=20 1334872    6    0     9&n= bsp;=20 1871  171   104  3  2 95
 0  0  = 0=20 261744  13488 110472 1332244    0   =20 0     0   922  195  1271  3&nb= sp; 2=20 94
 0  0  0 261744  13436 110492=20 1332244    0    0    =20 0    24  115    47  0  1=20 99
 0  0  0 261744  13436 110492=20 1332244    0    0    =20 0     6  109    36  0  5= =20 95
 0  0  0 261744  13436 110492=20 1332244    0    0    =20 0     6  123    63  0  0= =20 100
 0  0  0 261744  13436 110492=20 1332244    0    0    =20 0     6  109    38  0  0= =20 100
 0  0  0 261744  13436 110492=20 1332244    0    0    =20 0     6  112    39  0  1= =20 99
I'm not overly familiar with Linux, but th= e swap=20 in-out seems low, as does the io in-out. Have I allocated too much memory?= =20 Regardless, it doesn't explain why the optimizer would decide to do a seque= ntial=20 scan.
 
Here's the explain-analyze:
 
 Merge Join  (cost=3D11819.21..1= 5258.55=20 rows=3D12007 width=3D752) (actual time=3D4107.64..5587.81 rows=3D20880=20 loops=3D1)
   Merge Cond: ("outer".commercial_entity_id =3D=20 "inner".commercial_entity_id)
   ->  Index Scan using= =20 comm_serv_comm_ent_id_i on commercial_service cs (cost=3D0.00..3015.53 rows= =3D88038=20 width=3D12) (actual time=3D0.05..487.23 rows=3D88038 loops=3D1)
 &n= bsp;=20 ->  Sort  (cost=3D11819.21..11846.08 rows=3D10752 width=3D740)= (actual=20 time=3D3509.07..3955.15 rows=3D25098=20 loops=3D1)
         Sort Key:=20 ce.commercial_entity_id
        = =20 ->  Merge Join  (cost=3D0.00..9065.23 rows=3D10752 width=3D740= ) (actual=20 time=3D0.18..2762.13 rows=3D7990=20 loops=3D1)
          &= nbsp;   =20 Merge Cond: ("outer".user_account_id =3D=20 "inner".user_account_id)
        = ;      =20 ->  Index Scan using user_account_pkey on user_account=20 (cost=3D0.00..8010.39 rows=3D72483 width=3D716) (actual time=3D0.05..2220.8= 6 rows=3D72483=20 loops=3D1)
          &= nbsp;   =20 ->  Index Scan using comm_ent_usr_acc_id_i on commercial_entity ce&= nbsp;=20 (cost=3D0.00..4787.69 rows=3D78834 width=3D24) (actual time=3D0.02..55.64 r= ows=3D7991=20 loops=3D1)
 Total runtime: 226239.77 msec
(10 rows)
 
------------------------------------------------------------
 
Tied up in all this is my inability to gra= sp what=20 shared_buffers do
 
From "http:= //www.varlena.com/varlena/GeneralBits/Tidbits/perf.html":
 
"Shared buffers defines a = block of=20 memory that PostgreSQL will use to hold requests that are awaiting attentio= n=20 from the kernel buffer and CPU." and "The shared buffers parameter assu= mes=20 that OS is going to cache a lot of files and hence it is generally very low= =20 compared with system RAM."
 
From "http://www= .lyris.com/lm_help/6.0/tuning_postgresql.html"
 
"Increase the buffer size. Postgres uses a= shared=20 memory segment among its subthreads to buffer data in memory. The default i= s=20 512k, which is inadequate. On many of our installs, we've bumped it to ~16M= ,=20 which is still small. If you can spare enough memory to fit your whole data= base=20 in memory, do so."
 
Our database (in Oracle) is just over 4 gi= g in=20 size; obviously, this won't comfortably fit in memory (though we do have an= =20 Opteron machine inbound for next week with 4-gig of RAM and SCSI hard-drive= s).=20 The more of it we can fit in memory the better.
 
What about changing these costs - the doc = at http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.= html doesn't=20 go into a lot of detail. I was thinking that maybe the optimizer decided it= was=20 faster to do a sequential scan rather than an index scan based on an analys= is of=20 the cost using these values.
 
#random_page_cost =3D=20 4           # units are o= ne=20 sequential page fetch cost
#cpu_tuple_cost =3D=20 0.01          #=20 (same)
#cpu_index_tuple_cost =3D 0.001   #=20 (same)
#cpu_operator_cost =3D 0.0025     #=20 (same)
 
David
------=_NextPart_000_0395_01C39187.9C4B7830-- From pgsql-performance-owner@postgresql.org Mon Oct 13 17:53: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 9466AD1B508 for ; Mon, 13 Oct 2003 20:53: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 34808-03 for ; Mon, 13 Oct 2003 17:53:03 -0300 (ADT) Received: from lakemtao04.cox.net (lakemtao04.cox.net [68.1.17.241]) by svr1.postgresql.org (Postfix) with ESMTP id 4CA34D1B50D for ; Mon, 13 Oct 2003 17:53:03 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao04.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031013205305.IPZT5790.lakemtao04.cox.net@lhosts> for ; Mon, 13 Oct 2003 16:53:05 -0400 Subject: Re: Any issues with my tuning... From: Ron Johnson To: PgSQL Performance ML In-Reply-To: <039801c391c2$4b83d600$6501a8c0@griffiths2> References: <039801c391c2$4b83d600$6501a8c0@griffiths2> Content-Type: text/plain Message-Id: <1066078384.12390.26.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Mon, 13 Oct 2003 15:53:04 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/433 X-Sequence-Number: 4181 On Mon, 2003-10-13 at 14:43, David Griffiths wrote: > I've been having performance issues with Postgres (sequential scans vs > index scans in an update statement). I've read that optimizer will > change it's plan based on the resources it thinks are available. In > addition, I've read alot of conflicting info on various parameters, so > I'd like to sort those out as well. > > Here's the query I've been having problems with: > > UPDATE user_account SET last_name='abc' > FROM commercial_entity ce, commercial_service cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id=cs.commercial_entity_id; > > or > > UPDATE user_account SET last_name = 'abc' > WHERE EXISTS (SELECT 1 FROM commercial_entity ce, commercial_service > cs > WHERE user_account.user_account_id = ce.user_account_id AND > ce.commercial_entity_id = cs.commercial_entity_id); > > Both are about the same. > > All columns are indexed; all column-types are the same > (numeric(10,0)). A vacuum analyze was run just before the last attempt > at running the above statement. First thing is to change ce.user_account_id, ce.commercial_entity_id, and cs.commercial_entity_id from numeric(10,0) to INTEGER. PG uses them much more efficiently than it does NUMERIC, since it's a simple scalar type. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA LUKE: Is Perl better than Python? YODA: No... no... no. Quicker, easier, more seductive. LUKE: But how will I know why Python is better than Perl? YODA: You will know. When your code you try to read six months from now. From pgsql-performance-owner@postgresql.org Mon Oct 13 18:35: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 57F4FD1B510 for ; Mon, 13 Oct 2003 21:35: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 42774-06 for ; Mon, 13 Oct 2003 18:34:36 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id BD928D1B53C for ; Mon, 13 Oct 2003 18:34:35 -0300 (ADT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3763672; Mon, 13 Oct 2003 14:34:59 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: David Griffiths , pgsql-performance@postgresql.org Subject: Re: Any issues with my tuning... Date: Mon, 13 Oct 2003 14:32:17 -0700 User-Agent: KMail/1.4.3 References: <039801c391c2$4b83d600$6501a8c0@griffiths2> In-Reply-To: <039801c391c2$4b83d600$6501a8c0@griffiths2> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310131432.17735.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/435 X-Sequence-Number: 4183 David, > shared_buffers =3D 96000 # min max_connections*2 or 16, 8KB each This seems a little high to me, even for 2gb RAM. What % of your availabl= e=20 RAM does it work out to? > effective_cache_size =3D 6000 # typically 8KB each This is very, very low. Given your hardware, I'd set it to 1.5GB. > Note that I've played with all these values; shared_buffers has been as > low as 5000, and effective_cache_size has been as high as 50000. Sort > mem has varied between 1024 bytes and 4096 bytes. wal_buffers have been > between 16 and 128. If large updates are slow, increasing checkpoint_segments has the largest= =20 effect on this. > Tied up in all this is my inability to grasp what shared_buffers do >=20=20 > From " http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > ": >=20=20 > "shbufShared buffers defines a block of memory that PostgreSQL will use > to hold requests that are awaiting attention from the kernel buffer and > CPU." and "The shared buffers parameter assumes that OS is going to > cache a lot of files and hence it is generally very low compared with > system RAM." This is correct. Optimal levels among the people on this list who have=20 bothered to do profiling have ranged btw. 6% and 12% of available RAM, but= =20 never higher. > From " http://www.lyris.com/lm_help/6.0/tuning_postgresql.html > " >=20=20 > "Increase the buffer size. Postgres uses a shared memory segment among > its subthreads to buffer data in memory. The default is 512k, which is > inadequate. On many of our installs, we've bumped it to ~16M, which is > still small. If you can spare enough memory to fit your whole database > in memory, do so." This is absolutely incorrect. They are confusing shared_buffers with the= =20 kernel cache, or perhaps confusing PostgreSQL configuration with Oracle=20 configuration. I have contacted Lyris and advised them to update the manual. > Our database (in Oracle) is just over 4 gig in size; obviously, this > won't comfortably fit in memory (though we do have an Opteron machine > inbound for next week with 4-gig of RAM and SCSI hard-drives). The more > of it we can fit in memory the better. This is done through increasing the effective_cache_size, which encourages = the=20 planner to use data kept in the kernel cache. > What about changing these costs - the doc at > http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html > l> doesn't go into a lot of detail. I was thinking that maybe the > optimizer decided it was faster to do a sequential scan rather than an > index scan based on an analysis of the cost using these values. >=20=20 > #random_page_cost =3D 4 # units are one sequential page fetch > cost > #cpu_tuple_cost =3D 0.01 # (same) > #cpu_index_tuple_cost =3D 0.001 # (same) > #cpu_operator_cost =3D 0.0025 # (same) That's because nobody to date has done tests on the effect of tinkering wit= h=20 these values on different machines and setups. We would welcome your=20 results. On high-end machines, random_page_cost almost inevatibly needs to be lowere= d=20 to 2 or even 1.5 to encourage the use of indexes. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 13 19:25: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 96059D1B515 for ; Mon, 13 Oct 2003 22:25: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 45542-09 for ; Mon, 13 Oct 2003 19:25:05 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 93559D1B4E9 for ; Mon, 13 Oct 2003 19:25:04 -0300 (ADT) 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 h9DMP4hn001254; Mon, 13 Oct 2003 18:25:04 -0400 (EDT) To: Bruce Momjian Cc: Neil Conway , Jeff , PostgreSQL Performance , PostgreSQL Hackers Subject: Re: [HACKERS] Sun performance - Major discovery! In-reply-to: <200310090319.h993JpM10523@candle.pha.pa.us> References: <200310090319.h993JpM10523@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Wed, 08 Oct 2003 23:19:51 -0400" Date: Mon, 13 Oct 2003 18:25:04 -0400 Message-ID: <1253.1066083904@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/436 X-Sequence-Number: 4184 Bruce Momjian writes: > OK, patch attached and applied. It centralizes the optimization > defaults into configure.in, rather than having CFLAGS= in the template > files. I think there's a problem here: > + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc > + if test x"$CFLAGS" = x""; then > + CFLAGS="-O" > + fi > if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then > CFLAGS="$CFLAGS -g" > fi since this will cause "configure --enable-debug" to default to selecting CFLAGS="-O -g" for non-gcc compilers. On a lot of compilers that combination does not work, and will generate tons of useless warnings. I think it might be better to do if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then CFLAGS="$CFLAGS -g" + else + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc + if test x"$CFLAGS" = x""; then + CFLAGS="-O" + fi fi regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 13 20:48: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 CEC97D1B53B for ; Mon, 13 Oct 2003 23:48: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 63864-02 for ; Mon, 13 Oct 2003 20:48:18 -0300 (ADT) Received: from ensim.wwd-hosting.net (ensim.wwd-hosting.net [207.44.132.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6FAE4D1B4FE for ; Mon, 13 Oct 2003 20:48:16 -0300 (ADT) Received: from picklematrix.net ([0.0.0.0]) (authenticated (0 bits)) by ensim.wwd-hosting.net (8.11.6/8.11.6) with ESMTP id h9DNmIh02223 for ; Mon, 13 Oct 2003 19:48:18 -0400 Date: Mon, 13 Oct 2003 13:48:15 -1000 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; delsp=yes; charset=ISO-8859-1; format=flowed Subject: ways to force index use? From: Seth Ladd To: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/437 X-Sequence-Number: 4185 Hello, Thanks to all the previous suggestions for my previous question. I've=20= =20 done a lot more research and playing around since then, and luckily I=20=20 think I have a better understanding of postgresql. I still have some queries that don't use an index, and I was wondering=20= =20 if there were some other tricks to try out? My system: RH9, PG 7.3.4, IDE, 1 gig RAM, celeron 1.7 My Table Columns (all bigints): start, stop, step1, step2, step3 My Indexes: btree(start), btree(stop), btree(start, stop) Size of table: 16212 rows Params: shared_buffers =3D 128, effective_cache_size =3D 8192 The Query: explain analyze select * from path where start =3D 653873 or=20= =20 start =3D 649967 or stop =3D 653873 or stop =3D 649967 The Result: Seq=A0Scan=A0on=A0"path"=A0=A0(cost=3D0.00..450.22=A0rows=3D878=A0width=3D4= 8)=A0(actual=A0time=3D0=20 .08..40.50=A0rows=3D1562=A0loops=3D1) =A0Filter:=A0(("start"=A0=3D=A0653873)=A0OR=A0("start"=A0=3D=A0649967)=A0OR= =A0(stop=A0=3D=A0653873)=A0OR=20 =A0(stop=A0=3D=A0649967)) Total runtime: 42.41 msec Does anyone have a suggestion on how to get that query to use an index?=20= =20 Is it even possible? I did run vacuum analyze right before this test. I'm only beginning to customize the parameters in postgresql.conf=20=20 (mainly from tips from this list). Thanks very much! Seth From pgsql-performance-owner@postgresql.org Mon Oct 13 20:58: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 A4206D1B53D for ; Mon, 13 Oct 2003 23:57: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 63036-06 for ; Mon, 13 Oct 2003 20:57:27 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id BC183D1B553 for ; Mon, 13 Oct 2003 20:57:26 -0300 (ADT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3764319; Mon, 13 Oct 2003 16:58:07 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Seth Ladd , pgsql-performance@postgresql.org Subject: Re: ways to force index use? Date: Mon, 13 Oct 2003 16:55:25 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310131655.25022.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/438 X-Sequence-Number: 4186 Seth, > The Query: explain analyze select * from path where start =3D 653873 or= =20=20 > start =3D 649967 or stop =3D 653873 or stop =3D 649967 you need to cast all those numbers to BIGINT: select * from path where start =3D 653873::BIGINT or=20=20 start =3D 649967::BIGINT or stop =3D 653873::BIGINT or stop =3D 649967::BIG= INT Then an index on start or stop should be used by the planner. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 13 21:12: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 2B3A7D1B549 for ; Tue, 14 Oct 2003 00:12: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 63758-10 for ; Mon, 13 Oct 2003 21:12:04 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id A2151D1B53C for ; Mon, 13 Oct 2003 21:12:03 -0300 (ADT) 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 h9E0C1Nw059141 for ; Tue, 14 Oct 2003 00:12:02 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9E04PUO058348 for pgsql-performance@postgresql.org; Tue, 14 Oct 2003 00:04:25 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Mon, 13 Oct 2003 19:58:36 -0400 Organization: cbbrowne Computing Inc Lines: 32 Message-ID: References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.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.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:RfhRNoUAXEmhobW0mo33/HLJX9E= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/441 X-Sequence-Number: 4189 Centuries ago, Nostradamus foresaw when khera@kcilink.com (Vivek Khera) would write: >>>>>> "JB" == Josh Berkus writes: > > JB> Chris, >>> > PostgreSQL requires some more shared memory to cache some tables, x Mb, >>> > do you want to increase your OS kernel parameters? >>> > >>> > Tweak shmmax and shmmall >>> >>> Note that this still requires a kernel recompile on FreeBSD :( > > JB> Not our fault, now is it? This would mean that we wouldn't be > JB> able to script for FreeBSD. Bug the FreeBSD developers. > > "I read it on the net so it must be true" applies here. You /can/ set > these values via sysctl calls. Yes, indeed, sysctl can tweak these values fairly adequately. Now, numbers of semaphors are not as readily tweaked; I wound up limited, the other day, when I tried setting values for... kern.ipc.semmns kern.ipc.semmni -- let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];; http://www.ntlug.org/~cbbrowne/x.html "So, when you typed in the date, it exploded into a sheet of blue flame and burned the entire admin wing to the ground? Yes, that's a known bug. We'll be fixing it in the next release. Until then, try not to use European date format, and keep an extinguisher handy." -- slam@pobox.com (Tequila Rapide) From pgsql-performance-owner@postgresql.org Mon Oct 13 21:02: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 96587D1B538 for ; Tue, 14 Oct 2003 00:02: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 64193-06 for ; Mon, 13 Oct 2003 21:01:54 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 864E1D1B4EF for ; Mon, 13 Oct 2003 21:01:53 -0300 (ADT) 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 h9E01thn003744; Mon, 13 Oct 2003 20:01:55 -0400 (EDT) To: Seth Ladd Cc: pgsql-performance@postgresql.org Subject: Re: ways to force index use? In-reply-to: References: Comments: In-reply-to Seth Ladd message dated "Mon, 13 Oct 2003 13:48:15 -1000" Date: Mon, 13 Oct 2003 20:01:55 -0400 Message-ID: <3743.1066089715@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/439 X-Sequence-Number: 4187 Seth Ladd writes: > My Table Columns (all bigints): start, stop, step1, step2, step3 ^^^^^^^^^^^ > The Query: explain analyze select * from path where start = 653873 or > start = 649967 or stop = 653873 or stop = 649967 > Does anyone have a suggestion on how to get that query to use an index? Coerce the constants to bigint, for starters. However, a query that is selecting almost 10% of the table, as your example is, probably *shouldn't* be using an index. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 13 21:12: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 03DBAD1B547 for ; Tue, 14 Oct 2003 00:12: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 72095-02 for ; Mon, 13 Oct 2003 21:12:03 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 04149D1B538 for ; Mon, 13 Oct 2003 21:12:02 -0300 (ADT) 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 h9E0Bthn003817; Mon, 13 Oct 2003 20:11:55 -0400 (EDT) To: Sean Chittenden Cc: Josh Berkus , Christopher Kings-Lynne , Nick Barr , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL In-reply-to: <20031013191023.GB72842@perrin.nxad.com> References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.josh@agliodbs.com> <20031013191023.GB72842@perrin.nxad.com> Comments: In-reply-to Sean Chittenden message dated "Mon, 13 Oct 2003 12:10:23 -0700" Date: Mon, 13 Oct 2003 20:11:55 -0400 Message-ID: <3816.1066090315@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/440 X-Sequence-Number: 4188 Sean Chittenden writes: > Every few months one of the uber core BSD hackers threatens to rewrite > that part of PG because high up in the BSD camp, it's common belief > that shm* is a source of performance loss for PostgreSQL. They're full of it. RAM is RAM, no? Once you've got the memory mapped into your address space, it's hard to believe that it matters how you got hold of it. In any case, mmap doesn't have the semantics we need. See past discussions. regards, tom lane From pgsql-hackers-owner@postgresql.org Mon Oct 13 21:21:16 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 57387D1B53B for ; Tue, 14 Oct 2003 00:21: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 66182-07 for ; Mon, 13 Oct 2003 21:20:46 -0300 (ADT) Received: from smtp.noos.fr (nan-smtp-15.noos.net [212.198.2.123]) by svr1.postgresql.org (Postfix) with ESMTP id 6AD90D1B544 for ; Mon, 13 Oct 2003 21:20:44 -0300 (ADT) Received: (qmail 13298 invoked by uid 0); 14 Oct 2003 00:20:46 -0000 Received: from unknown (HELO bigfoot.com) ([::ffff:212.198.37.110]) (envelope-sender ) by ::ffff:212.198.2.123 (qmail-ldap-1.03) with SMTP for ; 14 Oct 2003 00:20:46 -0000 Message-ID: <3F8B4158.2030600@bigfoot.com> Date: Tue, 14 Oct 2003 02:20:40 +0200 From: Gaetano Mendola 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-hackers@postgresql.org" Cc: Tom Lane Subject: Re: ways to force index use? References: <3743.1066089715@sss.pgh.pa.us> In-Reply-To: <3743.1066089715@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: 200310/629 X-Sequence-Number: 45311 Tom Lane wrote: > Seth Ladd writes: > >>My Table Columns (all bigints): start, stop, step1, step2, step3 > > ^^^^^^^^^^^ > > >>The Query: explain analyze select * from path where start = 653873 or >>start = 649967 or stop = 653873 or stop = 649967 > > >>Does anyone have a suggestion on how to get that query to use an index? > > > Coerce the constants to bigint, for starters. However, a query that is > selecting almost 10% of the table, as your example is, probably > *shouldn't* be using an index. I think that for 10% is still better and Index scan. There is around a way to calculate this elbow ? Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Mon Oct 13 21: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 D6E66D1B4E3; Tue, 14 Oct 2003 00:49: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 74100-09; Mon, 13 Oct 2003 21:48:41 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 11FADD1B543; Mon, 13 Oct 2003 21:48:38 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9E0mDe09671; Mon, 13 Oct 2003 20:48:13 -0400 (EDT) From: Bruce Momjian Message-Id: <200310140048.h9E0mDe09671@candle.pha.pa.us> Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: <1253.1066083904@sss.pgh.pa.us> To: Tom Lane Date: Mon, 13 Oct 2003 20:48:13 -0400 (EDT) Cc: Neil Conway , Jeff , PostgreSQL Performance , PostgreSQL Hackers X-Mailer: ELM [version 2.4ME+ PL106 (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: 200310/442 X-Sequence-Number: 4190 Done as you suggested. --------------------------------------------------------------------------- Tom Lane wrote: > Bruce Momjian writes: > > OK, patch attached and applied. It centralizes the optimization > > defaults into configure.in, rather than having CFLAGS= in the template > > files. > > I think there's a problem here: > > > + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc > > + if test x"$CFLAGS" = x""; then > > + CFLAGS="-O" > > + fi > > if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then > > CFLAGS="$CFLAGS -g" > > fi > > since this will cause "configure --enable-debug" to default to selecting > CFLAGS="-O -g" for non-gcc compilers. On a lot of compilers that > combination does not work, and will generate tons of useless warnings. > I think it might be better to do > > if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then > CFLAGS="$CFLAGS -g" > + else > + # configure sets CFLAGS to -O2 for gcc, so this is only for non-gcc > + if test x"$CFLAGS" = x""; then > + CFLAGS="-O" > + fi > fi > > regards, tom lane > -- 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 Oct 13 22:28: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 9C53DD1B54E for ; Tue, 14 Oct 2003 01:28: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 76266-10 for ; Mon, 13 Oct 2003 22:28:14 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 45B8AD1B524 for ; Mon, 13 Oct 2003 22:27:59 -0300 (ADT) 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 h9E1RdhI096190; Tue, 14 Oct 2003 09:27:41 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3F8B5194.1000106@familyhealth.com.au> Date: Tue, 14 Oct 2003 09:29:56 +0800 From: Christopher Kings-Lynne 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: Vivek Khera Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <200310101034.52073.josh@agliodbs.com> <3F86F5BB.90605@chuckie.co.uk> <200310101338.18167.josh@agliodbs.com> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> 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: 200310/443 X-Sequence-Number: 4191 >>>If shmmax and shmmall are too small, then: >>>PostgreSQL requires some more shared memory to cache some tables, x >>>Mb, do you want to increase your OS kernel parameters? >>>Tweak shmmax and shmmall > > > CK> Note that this still requires a kernel recompile on FreeBSD :( > > According to whom? sysctl is your friend. Some sysctl settings may > require reboot, but I don't think the SHM ones do. Hmmm...you may be right - I can't prove it now... houston# sysctl -w kern.ipc.shmmax=99999999999 kern.ipc.shmmax: 33554432 -> 2147483647 Hrm. Ok. Maybe they've changed that in some recent version :) Chris From pgsql-performance-owner@postgresql.org Mon Oct 13 22:42: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 A07ECD1B50D for ; Tue, 14 Oct 2003 01:41: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 77023-06 for ; Mon, 13 Oct 2003 22:41:30 -0300 (ADT) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id E0995D1B53E for ; Mon, 13 Oct 2003 22:41:17 -0300 (ADT) 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 h9E1fBhI001223; Tue, 14 Oct 2003 09:41:12 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3F8B54C1.5090206@familyhealth.com.au> Date: Tue, 14 Oct 2003 09:43:29 +0800 From: Christopher Kings-Lynne 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: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL References: <007901c38f2b$0b585590$2802a8c0@webbased10> <3F8819EF.7010004@chuckie.co.uk> <3F88BFD7.1020808@familyhealth.com.au> <200310121331.42693.josh@agliodbs.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: 200310/444 X-Sequence-Number: 4192 > > Yes, indeed, sysctl can tweak these values fairly adequately. > > Now, numbers of semaphors are not as readily tweaked; I wound up > limited, the other day, when I tried setting values for... > > kern.ipc.semmns > kern.ipc.semmni Same. Maybe that was the option I was thinking was read-only: houston# sysctl kern.ipc.semmns kern.ipc.semmns: 60 houston# sysctl -w kern.ipc.semmns=70 sysctl: oid 'kern.ipc.semmns' is read only houston# sysctl kern.ipc.semmni kern.ipc.semmni: 10 houston# sysctl -w kern.ipc.semmni=30 sysctl: oid 'kern.ipc.semmni' is read only I like how they use oids :P Chris From pgsql-performance-owner@postgresql.org Tue Oct 14 05:18: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 C7AEDD1B54B for ; Tue, 14 Oct 2003 08:18: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 35016-10 for ; Tue, 14 Oct 2003 05:18:09 -0300 (ADT) Received: from ensim.wwd-hosting.net (ensim.wwd-hosting.net [207.44.132.72]) by svr1.postgresql.org (Postfix) with ESMTP id 5FDD9D1B51B for ; Tue, 14 Oct 2003 05:18:06 -0300 (ADT) Received: from picklematrix.net ([0.0.0.0]) (authenticated (0 bits)) by ensim.wwd-hosting.net (8.11.6/8.11.6) with ESMTP id h9E8I6L17089 for ; Tue, 14 Oct 2003 04:18:07 -0400 Date: Mon, 13 Oct 2003 22:18:06 -1000 Subject: Re: ways to force index use? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Seth Ladd To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: <127627572842.20031014092427@pierro.dds.nl> Message-Id: X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/445 X-Sequence-Number: 4193 On Monday, Oct 13, 2003, at 21:24 Pacific/Honolulu, mila wrote: > Seth, > >> My system: RH9, PG 7.3.4, IDE, 1 gig RAM, celeron 1.7 > ... >> Size of table: 16212 rows >> Params: shared_buffers = 128, effective_cache_size = 8192 > > Just in case, > the "shared_buffers" value looks a bit far too small for your system. > I think you should raise it to at least 1024, or so. > > Effective cache size could be (at least) doubled, too ==> this might > help forcing the index use. Thanks! I'm just beginning to play with these numbers. I'll definitely try them out. I can't wait to try out the script that will help set these parameters! :) Seth From pgsql-performance-owner@postgresql.org Tue Oct 14 13:45: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 E2E2ED1B532 for ; Tue, 14 Oct 2003 15:14: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 13238-03 for ; Tue, 14 Oct 2003 12:13:55 -0300 (ADT) Received: from mail.gmx.net (imap.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 171ABD1B533 for ; Tue, 14 Oct 2003 12:13:54 -0300 (ADT) Received: (qmail 9226 invoked by uid 65534); 14 Oct 2003 15:13:52 -0000 Received: from dsl-082-082-161-199.arcor-ip.net (EHLO dsl-082-082-161-199.arcor-ip.net) (82.82.161.199) by mail.gmx.net (mp023) with SMTP; 14 Oct 2003 17:13:52 +0200 X-Authenticated: #495269 Date: Tue, 14 Oct 2003 17:13:52 +0200 (CEST) From: Peter Eisentraut X-X-Sender: peter@peter.localdomain To: Marko Karppinen Cc: Bruce Momjian , PostgreSQL Performance , PostgreSQL-development Subject: Re: [HACKERS] Sun performance - Major discovery! In-Reply-To: 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: 200310/448 X-Sequence-Number: 4196 Marko Karppinen writes: > GCC sets __FAST_MATH__ even if you counter a -ffast-math with the > negating flags above. This means that it is not currently possible to > use the -fast flag when compiling PostgreSQL at all. Instead, you have > to go through all the flags Apple is setting and only pass on those > that don't break pg. That sounds perfectly reasonable to me. Why should we develop elaborate workarounds for compiler flags that are known to create broken code? I also want to point out that I'm getting kind of tired of developing more and more workarounds for sloppy Apple engineering. -- Peter Eisentraut peter_e@gmx.net From pgsql-performance-owner@postgresql.org Tue Oct 14 13:14: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 53631D1B573; Tue, 14 Oct 2003 16: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 33005-05; Tue, 14 Oct 2003 13:14:22 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id CD82BD1B55E; Tue, 14 Oct 2003 13:14:21 -0300 (ADT) 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 h9EGEJhn009946; Tue, 14 Oct 2003 12:14:19 -0400 (EDT) To: "Chris Faulkner" Cc: "Pgsql-Performance" , "Pgsql-Sql" Subject: Re: [SQL] sql performance and cache In-reply-to: References: Comments: In-reply-to "Chris Faulkner" message dated "Sat, 11 Oct 2003 10:43:04 +0100" Date: Tue, 14 Oct 2003 12:14:19 -0400 Message-ID: <9945.1066148059@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/446 X-Sequence-Number: 4194 "Chris Faulkner" writes: > I am seeing this message in my logs. > "bt_fixroot: not valid old root page" That's not good. I'd suggest reindexing that index. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 15:38:55 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 9A09ED1C9E7; Tue, 14 Oct 2003 16:59: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 42483-01; Tue, 14 Oct 2003 13:59:17 -0300 (ADT) Received: from mta3.snet.net (mta3.snet.net [204.60.203.69]) by svr1.postgresql.org (Postfix) with ESMTP id 0F468D1CA86; Tue, 14 Oct 2003 13:52:49 -0300 (ADT) Received: from [192.168.1.203] (167.95.252.64.snet.net [64.252.95.167]) by mta3.snet.net (8.12.3/8.12.3/SNET-smtp-1.2/D-1.1.1.1/O-1.1.1.1) with ESMTP id h9EGqeIJ002426; Tue, 14 Oct 2003 12:52:41 -0400 (EDT) Date: Tue, 14 Oct 2003 12:48:06 -0400 (EDT) From: Wei Weng X-X-Sender: wweng@localhost.localdomain To: Christopher Kings-Lynne Cc: Chris Faulkner , Pgsql-Performance , Pgsql-Sql Subject: Re: [SQL] sql performance and cache In-Reply-To: <3F87D764.8030306@familyhealth.com.au> Message-ID: References: <3F87D764.8030306@familyhealth.com.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/464 X-Sequence-Number: 4212 On Sat, 11 Oct 2003, Christopher Kings-Lynne wrote: > > > I have two very similar queries which I need to execute. They both have > > exactly the same from / where conditions. When I execute the first, it takes > > about 16 seconds. The second is executed almost immediately after, it takes > > 13 seconds. In short, I'd like to know why the query result isn't being > > cached and any ideas on how to improve the execution. > > > > > OK - so I could execute the query once, and get the maximum size of the > > array and the result set in one. I know what I am doing is less than optimal > > but I had expected the query results to be cached. So the second execution > > would be very quick. So why aren't they ? I have increased my cache size - > > shared_buffers is 2000 and I have doubled the default max_fsm... settings > > (although I am not sure what they do). sort_mem is 8192. > > PostgreSQL does not have, and has never had a query cache - so nothing > you do is going to make that second query faster. > > Perhaps you are confusing it with the MySQL query cache? > > Chris > Is there plan on developing one (query cache)? Thanks Wei From pgsql-performance-owner@postgresql.org Tue Oct 14 14:00: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 02FCFD1CA88; Tue, 14 Oct 2003 17:00: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 44209-01; Tue, 14 Oct 2003 13:59:52 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C5C86D1CA03; Tue, 14 Oct 2003 13:53:12 -0300 (ADT) 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 h9EGqvhn010569; Tue, 14 Oct 2003 12:52:57 -0400 (EDT) To: Marko Karppinen Cc: Bruce Momjian , PostgreSQL Performance , PostgreSQL-development Subject: Re: [HACKERS] Sun performance - Major discovery! In-reply-to: References: <200310081831.h98IVT919657@candle.pha.pa.us> Comments: In-reply-to Marko Karppinen message dated "Sat, 11 Oct 2003 20:46:40 +0300" Date: Tue, 14 Oct 2003 12:52:57 -0400 Message-ID: <10568.1066150377@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/455 X-Sequence-Number: 4203 Marko Karppinen writes: > At least the --fast-math part causes problems, seeing that PostgreSQL > actually checks for the __FAST_MATH__ macro to make sure that it isn't > turned on. There might be other problems with Apple's flags, but I > think that the __FAST_MATH__ check should be altered. Removing the check is not acceptable --- we spent far too much time fighting bug reports that turned out to trace to -ffast-math. See for example http://archives.postgresql.org/pgsql-bugs/2002-09/msg00169.php > As you know, setting --fast-math in GCC is the equivalent of setting > -fno-math-errno, -funsafe-math-optimizations, -fno-trapping-math, > -ffinite-math-only and -fno-signaling-nans. I suspect that -funsafe-math-optimizations is the only one of those that really affects the datetime code, but I would be quite worried about the side-effects of any of them on the float8 arithmetic routines. Also I think the behavior of -ffast-math has changed over time; in the gcc 2.95.3 manual I see none of the above and only the description `-ffast-math' This option allows GCC to violate some ANSI or IEEE rules and/or specifications in the interest of optimizing code for speed. For example, it allows the compiler to assume arguments to the `sqrt' function are non-negative numbers and that no floating-point values are NaNs. Since we certainly do use NaNs, it would be very bad to allow -ffast-math in gcc 2.95. gcc 3.2 has some but not all of the sub-flags you list above, so apparently the behavior changed again as of gcc 3.3. This means that relaxing the check would require (a) finding out which of the sub-flags break our code and which don't; (b) finding out how the answer to (a) has varied with gcc release; and (c) finding out how we can test whether a given sub-flag is set --- are there #defines for each of them in gcc 3? This does not sound real practical to me... > This would allow people to use CFLAGS="-fast" on their G5s, beat some > Xeon speed records, and not worry about esoteric IEEE math standards. In the words of the sage, "I can make this code *arbitrarily* fast ... if it doesn't have to give the right answer." Those "esoteric" standards make the difference between printing 5:00:00 and printing 4:59:60. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 15:38: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 27E88D1CA54 for ; Tue, 14 Oct 2003 17:01: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 41417-07 for ; Tue, 14 Oct 2003 14:00:54 -0300 (ADT) Received: from ctg-msnex01.staff.berbee.com (msn-office1.binc.net [64.73.12.254]) by svr1.postgresql.org (Postfix) with ESMTP id 8B8DBD1B54C for ; Tue, 14 Oct 2003 13:54:19 -0300 (ADT) Received: from localhost ([172.30.254.220] RDNS failed) by ctg-msnex01.staff.berbee.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 14 Oct 2003 11:54:17 -0500 From: "Jeremy M. Guthrie" Reply-To: jeremy.guthrie@berbee.com Organization: Berbee Information Networks To: "pgsql-performance@postgresql.org" Subject: free space map usage Date: Tue, 14 Oct 2003 11:54:16 -0500 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_4oCj/ynRbBzCRgL" Message-Id: <200310141154.17227.jeremy.guthrie@berbee.com> X-OriginalArrivalTime: 14 Oct 2003 16:54:18.0062 (UTC) FILETIME=[CE8B0EE0:01C39273] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/463 X-Sequence-Number: 4211 --Boundary-00=_4oCj/ynRbBzCRgL Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Is there any way to determine how much of the free space map is currently i= n=20 use?(ie. where and what it is tracking?) I vacuum on a regular basis but I= =20 never hold in terms of disk space usage. I jacked up the free space map=20 pages but this doesn't appear to be working. shared_buffers =3D 29400 # 2*max_connections, min 16 max_fsm_relations =3D 1000 # min 10, fsm is free space map max_fsm_pages =3D 10000000 # min 1000, fsm is free space map - --=20 Jeremy M. Guthrie Systems Engineer Berbee 5520 Research Park Dr. Madison, WI 53711 Phone: 608-298-1061 Berbee...Decade 1. 1993-2003 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/jCo4qtjaBHGZBeURAj9EAKCL+tiioPO5K1YM1sn62yS0L1Ry5QCfVifq 22s22gFNFHAHquS+iiUZO6s=3D =3DAQ2Y -----END PGP SIGNATURE----- --Boundary-00=_4oCj/ynRbBzCRgL Content-Type: image/png; name="archive.png" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="archive.png" iVBORw0KGgoAAAANSUhEUgAAAeAAAACACAIAAABcNS0sAAAABGdBTUEAALGP C/xhBQAAADh0RVh0U29mdHdhcmUAWFYgVmVyc2lvbiAzLjEwYSAgUmV2OiAx Mi8yOS85NCAoUE5HIHBhdGNoIDEuMindFS5JAAAgAElEQVR4nO19Ma/kuM7l uRcK6nNwsa+y3X+xF9j6//EEvckLXrBxf1k9oAO/CgzMBrKoQx5K5dvT3TPd Y6NguGRaIo9kkaYo6WX9sqIAG/pR8MDjsl0s/VEel+3C5/1WO1f6/VbLBBuY OM8E7RYuKU3Pk5i0x3u5uOw8wzOMi/H5KA8AKZ926COdUoRyKNlf9ILyR0xS 4/nE/8T/xP/EP8P/Zf2yKnwqkgkThE/xAnptObiBPHPhzJ2zGkqFTGs955Dw coJnVRtqYgJC2mSV4VDrJ/4n/if+J/4p/q+dxYomHvUawAUXlL3LZ+2hqmYv r52xtacANF36ABGUPfGCS5eBM4G7rnxXjvmMQmQ1cYPBsSfiYhJ1BoALLkZp +tNoDDgWgcl2iHwTcU9t7i4zvJMRkif+J/4n/if+iv+rSdILtmMjpAQ1S+cH TeDKWRSSsyoEFi4RAq7d1jJYMxviQQ2GKnQiSOPoODbIDOia6Kofvb32GkKs j95Mrc64FKo/E/bE/8T/xP/EX/G/LtdX5s+EidmRtjRVFmqlV6F9Svg64KoK qiYqwOLYYDGs3bAS4/bEKPdMCM3eqqjKH+XRWyR6c3nUDx9uFq3+VPyu/42Z zddWa7VMduJ/4n/if+Kf4n9f769s+Vt9VAlZ18XC6BsHdFRV0yvD0g2LAq4q VyWmQ/gzAa6CjRPmoTPmUY6FGkFrHyxg0KJJI0NvAVFJ+u84qzmXbjhscDyf +J/4n/if+Gf4X5frKwsQlF69ZQK4WqlH8dygC4zNo1lcNXDdm/5x0PAXDTou dp0y7EDcpNDwTdTYM4YdG4Z4e0pbQNeH2GV3ytaGKTYCiiuGG9aJ/4n/if+J v8f/vt5fLMyuqy8bTGyP7cKXeKvDxIO8BBPrEJfbYGjV6o/VS7ymIhxjMojs cvY0rpXIoC3nEPPkSrXaQv8wYW5RqJqNeZ+PFXfif+J/4n/izxkuy/Lqun8y v+2arfeusioE9ClkOaAptKBJgqh2txN4n1dQmP2Lxmdlz9Y8jbLXk2rOkpTO ik4HAVxrazmwFr20jxSuyz19uxgmla/g5jvxP/E/8T/xV/zXL+vrhextO2xM wIo3cLvypI8deM/OzmLwl4chXXLomDxWCpp3KQ4XlIcV9+BvMftS8J8YrKyS BoGm6PTLxY8vM7gJlEVGKrhhlVgHpjxN5Z74n/if+J/4B/yXt6VPVHkUCpb2 PuxIEBK3S6cHACxvy7quXBnLsgC4r/cOgbf8KwGAOHGG6DvNumKLTMa/cnag 8CcJwQT5EBvSh8zfFlTpUmbgcnOfORB4/zD+VlyOT4Y/C874Y7levqyOf7r+ 6+D/hBnBH8sVrTX+lfGP9M/wx3K91Lfjr43/R9v/Xl9/efy/eft/5Q7bdIsJ z+xetjyMPGiY5W3pJbXe+b7ega7KTDHWrJZlWb+s65f1vt73x0GfIcCjPJZl Wde15mP6qo8DeLVWc17eFtXbrMyrjkL7mutk/qunKgZD01kQ5dFHcrfOTGxe BdiwvC1siQTFXstd3pan+Fd+RvgbXMpDwH95W8KAeP86a/jb27K/Ws1EYvyX ZUnx70VvWN6WFH80SwobOs8e/50HPGp95fiXjn+lUfyt9N04yvDn9m/tZ9L+ r8s1xT+0/xR/a/+V5xT/niFa+5m2//qg4u/e0GVJ8ef2X2VX/Fm6mo/iz4CY 7BF/QqNi+KT/wfP+p+MTTHVq//Z+Bfw5/+tyTfHn9l/7jT/e/4zwt7cG1jOu 67p+WfezXcjf+3rnlP7gl3X9sqKat4Cl1y51v0UZcj5Mb2Q7ASd+SXirZHeA f/ix588Hyv387cr6rvTh/MPk+t6YBJrPPwn+H83/z2r/34TmSDv8i+P/UYnq b9THAnipboeussgbEkx9NtGTjxSahF6tXTTfxbquDzyuy5XL2jNpHzXdcG69 OX8XLG/L7vpopSiHAK7L9ffff7d8Xl5e+G96fCuaf7+8/ONHlfUjaf775eV/ /pX4OetrTnPK9RPRvLy8WD/JA6fsAGmDhO0c/oI+bdhEt7FOoJvl/QsLNDYK LMtSvxrqt4wd3ZgHdkN4vQPgbxBTG/YRVLPi3hk2WHwe3/o4MT2P8/iOB4e7 cIxgc7C8At1dFVwkzpfq/XfsLOsdN3msrH83L0S9Zs8v0A1kVgnd+1P7aFzW L+vuCDaXUAgIp37fjqcq7hvSPFXvP5ifU675ccr1c9H8qnKhOdNBITHmm77g 8goKI4/+e98dd5e2d+H38U1yq9dbe0+KPhLaO9PW+QJY13V5W5Zlqa4M5rK6 zx/lsX5Zl7fFzGezr/dMNtIN7Xh5eXmKzrei+e8fWNYp1x+n+fdfjJ+zvubH r1pfQO/i2Hthw7AvwS8c4zzIxWFukd7DQqJJ4HMwJiTAhVPYoexKlyKc1zt4 ooHlbTmotc7jPM7jPP7cg33QoYuzbvC1d7jI4syC69kMajOQNwp12nZvSQ/H KTuZC0JCH4rsXhSOm6E8g8ulR9XQtCXOPMh/BKNvQnNaLj8XzSnXz0Xzq8rF cXh7f+u7wdaFoxnI81BwsqydeQuyr9PDm8POxM5M4zCUyaUrPxx0eVrQ53Ee 5/FTHMGCtiA6UDf4yt5bZzunEyXtLj1lTufd18wDhs1n3WcWNBO7G8it6F5K cUOZPQh/67Zzz4Tjw0X+Ixh9E5pfVcOfcv1cNKdcPxdN6G85Lm73QdfV7B5h jaXWFXanc5gK6Y3ZNFY6epAxnBjKBnVitgf7XaZ1nj7o8ziP8/jpjpcXWUw0 TE8veLU4YvDMxWZN99BmcmuEIIoQ/sGxeuxesci8h8xS7bZ5IU4ock5HFLvT WVZaYfmPYPRNaE4f9M9Fc8r1c9H8qnI5dwX7b1vos1jQzcvslgT0gRzgBV6f WtDw0R0hIKRx6a69nR790QP/OGQm4Xmcx3mcx1/2qBY0hxSHGLlHebxyT8od YneI+EVS6pw9XdE1zC3c86H1W1OL2/mdi+upu5/ar0aUxAyS+ybIfwSjb0Lz q2r4U66fi+aU6+ei4VG3bn22Baeuy/WVF28NcwitV3XzTYpL5Fl/duZoPJu6 YqF43InzHBnHorlBeJWsdA7h1nMOxznT6Y/TnHL9XDSnXD8XjQuzC+5lXNqC /X6WYY/2KGT5tn5wXxlPHce6zreFW8AN6GlPaqtihwCSXiibzPBzCP2OYXyc Gv6P05y+9Z+L5pTr56Jxs0BsJxcKb3u5t2Ww3ehhGj5BzpAw1DgaheyeYu9N BsSP7MsNLmb1YidkZxz0eZzHefw8R/dBy5Ae2hqfr93ni2hKd6cw2eHs7mDf QpxFQp6TkIPZxc7iJrdGcDG7R3j9PG+5n3HQ34PmlOvnovlV5fpVv+QQek5e rq4AgOvCh7ZwPbz5PDqHkOc+tSQNfw4WtE441Jho2czGGD7joM/jPM7jZzle Xl76LoBZFMfytvSp3sHVMPN1AK4/1R45dVzIJPK0Ow7hdElZ2Wzven0u2P/N aU65fi6aU66nNPgN6Qd3T7wBv01zKcA7Yj6aJ+fDy2MAv/+f39FcHCGO2dnB uPhNY2VJudhpIva/Fv4MP67IPTV4grnOGKSCtOdNyII7+7Sgz+PPPl7+7wsg 72cwX5C9z6kVggPpWlCarT6iBGlxKs6RY86Jps/PyphmO2H4L4x/76Btc23f 3aH1mcl6d3Z2luxgTrayklrQsYv3o46pbwRZh577N5qqOC3ob07z75eXa7UC Rm0utSaULLVKwiNKo83yRmVJg+n5fHrSL9zfcZ1bSRN++HrOM+czeckNQ0i6 4pyy0S7uN5JrVGW3LJ+UZt6BGs6aD8QaTfvfwM9Y/F2uIxbrXDFM2oby87TN Y1qtwYKmu6GDrkfaZ/rJ4Dq1TzfLQq8ANm+jA0WM7s5l1uOn4RldtlDcgHL5 19IfSfV/+ko/VXp4lj65O2ou+sjkGtPH5y1yzvZTk2Eiy1PKtDic+E9pTvz1 Gr8a/uzicP0nqOcswIa+5dVluyxvS92W/GK7UtF2f279uQ3g5Zh5k6p0ITq/ mZadL7KsBwc4W2R0iPpwlH5dDnfcCBSr5g3G/07DKdyC7e9NWkkoqOB+8zmE ejJrQvkJhd48A8yzPXijW3y2RwrJBXmc5VIaj8Zn5nkbUN58tiw+l4UM/zSf TTIsRDMqyBi7UXoorhF/vvlHrNC0LhRAED8p/lzouzxuZ6UJIDP9u7+l7ba2 Qy9p0v5vA/wxxjlt/7fsbmj/zLNyxe+F4o/O8z1tY6H9p/wExsI7mLb/2wD/ 8C5n+Ltj0v+0w/pA7iQ5sK1b0HW7qX3TKdqNGxwIwg6HwQbbAJZlCZuFX5dr NNXtGpfqnagcO5+4H5O0nQz3bb/FNl/+tcy0JVfJRN/OnwKRHVGhB5X8iIHQ 9NOi08yf3pqIMOd2zvOJ/4hgUuiJ/4iBXxT/MEgYekUjW96W1/ogW6APm+zH 5jMHRLcuu/s0KBi57u7K5q11vi6WmSY11u677i3rNpDdYFqlao517V0zWgz1 w5b+gGhL02mqVINGDdZBoWff6anQUtuD3dLkW1bi1vJhHZvWdLAUuES7CNob /roQz1t2a5SP8UaJ91ue7sRkq43vMoZssYLwsfMmFkcot16wNbp5WOyp2wD/ ree5y5W+aZbVbYA/Zxi+ZpQA1H60iXI+Kc6g9GBBm0TUqO7BWk/b/22AP1Mq P5D2/z7AH5R/aIdp+9e6YIbt/UpxsyO0ny0jK946DgQpzhjUi1r9TPO0/2mH 8yW0nhrNebB+WVG7xfrjJ+/rfa3Hl/7bE1tnan/j1t2AEdRrAPzg/tTq/nIO 4RZod/CQw1468Bm4tx9+G54/T+5+OpA+ohk9pfSjdM9bzuen4d3PIf3ToKxP wxKfSz3m/PndE/8T/xN/KpF/2uPtv3XNvNToCs15G5B9tmSDj9U9wpphWZZg zGskRvVgGBnIg2GOF2ZA46aXf7ZBwkrz7kds0y+UQKOUZRylQJSf3/G/BiO2 PeV4lEJKYEdKE45J5ECQa5QDgHm0A1tAowgEpvmU4b9l+SgseIYPKNt59AWA EBWQgjziGQOa9DCej7TDj0a5ZJXbozjSUtJ6T5vru8g+xweDz5Hb+N2Br9Pp +/WV7VCZn7RDlmv+XsDX6Yjzcf8TBwl9OBz3kC7OowJt/Z1OGMmdzq1Ujkfu 0XtATeE5M73/bfF2u9taY6Jb/JxJwpmHAO/l/y3DBjdPSd9zPUJ9p9liTDNp 65NS9Nak9HmLOQKCcj6RegTjif+J/4n/uGgXZodsNgn2rF73nq48lreFFwhd liW6RVp/bWfzVveNutvazZDdC23Jutpfg9bDqxa3Pe6Wlsbjsl3MN20xJBwo 8ii9UBMM8D4gQ4opi/eNbgI3Wj7hqY3+ArDRc84hMAPyQXuN2C9K5j/lu1vL J+RcfMo29n8VOrO/ElLuBsBHp4RWa5QaVRKKhvcPBmZAcqX4M9ktx78TbFKn mYD3NEohwPgud7ncjdqP4q+yK/6cMvKbM+Dq8xUY77cB/vxXI460/Wv7UZbe M4LQ/t9z/CM/Kf7h/Urx53zeB7BoWx2g5+p93jtrnSpjk/7Hjg2gxfS7ydu6 uBcLt+hWqlnBX1YMwqdDGEa4uC7X3MXR5HQui7KPK9rhpj8SLiGKQ8Oir/+8 PlHOCjS3iVQ5j9RpuP4QJcYVP7nQZ5/STzJJYTnyyJzzE/8T/xP/ZwWZBV3H 55KJ3BYH3Y1igC/qOXiKNUzPBTIDtbD7erfESrl3xy3mumqCKskDjz5IuK52 y9nvG+pT+0BiaSVSxPTOADe7oJmtLYJAfPcprAON/pZVni+rW5ob3TWFuTV+ wrMpP5weWltpNEXu8kWReGrOxC5G1h89cg9WgJa4ZVYtl2JlpfhvPp8Uf842 RHFAoNgGseRMadEOKT92odEFAaIi9aXlFok7Ti/ec/wd5W2AP4l/D19Fafu/ DfCHxzDFn5EMESNp+59/PaT8wD/C7VDxD/kgw5+zDbHSyGAPEUdp+9cIKG3/ k/6nHWY1cz9cV/Ss7oQXtkbNRAWwu4xbFxkioLuuMAI/lph7qCdr4MFXv4wB xnLDKk7VTv+X90Gn2mykKg8+9TRRj1S1jgqdGwJzTuZkTKPnEdsj/ic8n/in ZCf+J/4tUQcJY8hDI35lzzTHeWi0soUeI50QaEa0rArdt+4OiiJMBbRVUHnR ENovnLco7AS8HjQrMQxmcLHKLVlMcdCcJfPZBa1bsplOocQts1hZb9dbakHr tWrmIELJZN/krHG1zPzW5LJHtNBC+WCAZKXRePNNGEstl4BAavWHczpbzBPf 370I+kZtYkXqdRn7xFV2xZ/P6hMf4aP4E893tUa11tKvq/CU+oUDe/BfcuHM sqfth9u/fqEiYn5P6yJUMfvElUzbPJ+Z8pbBuwlNhr/7O+9/Gquu86RBwjo4 l0xl6SN+2fqfYYLfcKdtXw2mBtgQdhuBp5oNvrvPJtu4YI9/XmP1qNIeXWu7 GT07T/w6+sA2PA8jzkeCpEVD7k7oR4xNhJpcjFgNbODE/xljJ/6/BP6pBQ1x RmO3oCkSeVmW63K9LtflbalxF9hgF6Bp3+opZlVQA0LM0Xype4GH6Yg+GkTP 3OmzkqkHi+SAMHQ0SoGrCl57b5leDTSsDH2Gn9m3FZqaXahG5b/1kZtwAkTp gj8OPgfLJ7C6CWMhGkTP8FEBovw7P3xoM4VgqNfb4dmPaYUynpMvnnZ9v/lb xaNdr9W/zJkUTxPwZ65uA/yNvgz8lZZtKCsIVXpajLpBBtdoNh3zP5n9aBmO 2nPxZc0zKf4rRDkBsFF9Bfy5nUy+CA1/HcPQ9n8b4M/N4Jbj7xiY9D92kAXd 958ir0CyFsd9vV+Xq4Utj4YXa+7OCgYwivpQozu1iOmc3p0b3XscNHx9Y5AS KmByRnYxyTMtQumPsJRyOCE+IvuInxHb8+LSR078J7Kf+B9nKeVwQnxE9r8A /hzF4XpXWeDoFc2nsecC1Ljj63KFXzSO/cLmLHb9fWkOEF76butGNz+Cie2M nQ29mxjdAJqb2+m6kq18ZkrSEkc+KdauI78eHTGulq+Nq9QqYa4wHR0uxE9Q y9o65/GeJjsXXYRMfevMDPNcfDqbFSy74s/8p3URsApWiR2BHxHEZVK8rzaI b0UH/3IRwQPP/DiTpZYUfG46hrEJYyN/LrqAPR4/3OLrUftJ6yJAx9KxRR/4 4bIy/N3f0ZgB/Y1jBin/twH+nHIb4A+P8+gutw0k+B/tf9oRR+Y2Nwvkulxf 4spwLSo5TvzL9FgejIGMTIJAQvCGc22Pdg1XEx7g67ia3VxDBpqRmlWaZ+ox xWpG+fTWnPkRV0dkOcKYlvWUpY+KMGfgxB8n/mPmf0L8gwUNmfZhf/coDpDX o8ZyxOAKsXCd05mDMVp/updksdLWocPNaORAEbRpgXHX8LL7wV1wtI/9eNBC 1TANH9SXqkT2MwZVac+GGNVMRTtLU+0R1t6jUtgKQFaKnUNEhBYEH+8ZWozl n8Zl+9Kj7y+QmVzyYJSO/eZ8tkP5YWSY5wx/l6KWuGT1WS1NRSD1Cxci27Iv HshF8FOngE98vsbexOpv53vwsabtXy07JtZ3Z/MZGm+jtsqAjGarcoZp9I7P M4+SCu0/nf0Y2v9oNi//1TEM+LIgVn/K9rz/8UdwGNhfH4iX7e2dtioNUgZv PCguZh4VDCqi/xU/NTtlwAZ7sMHb0X3Q4ZjrvZG2PPJsSlOkKadKO1CmmTwt UWsnLS60whHPc8ZGcj3l+cT/xH9S0N8P/9liSbz627K8gkzgZVlqIMe+KHMW U1H1gOVoI49mEauLGTRGCUQVMfRT06rTHO9stjbb7Pagq49g/Vl68TSqLfnY xrOPSqdJdh7RuknXLgjnYB2HggLP/GxIYWs9EBiTT/3UWxbFEQoqYkkp29vY 4gj56LF58TUfpqnn4BsNDAPgtVPCudBTo9h2SJ0q/szVbYC/8jxqGEyj+FOe 9xE+XLT66PkviAaCv+ajsnD7T2cJhqLT6Av/N47xpO3/Jre0/et4ibb/2wD/ 8J5m+DsB5/1PS+HgZm2uL7xKHPudeXk5pPu3epO2msBplIVGeoAnzJS960/i qYNFnwZct+Oha3EcUYMY3xrZEXP7ItWiI0thrpOfFqrZahGpyEfK+jqCE/8T /xP/idQF8Lt6zz0EuwX9KA+L3MBoAiG6gzgEMmPr1i4kPMOtTmc2MmLvbOZ2 TQ8mfA+vBhGUFpHd8neQpbs5bHQu41XElCbUU3E0caaTEfAj6Y4YgbeJP9eu 3zOGw1nz4RyYBtSG+NgA3ikmPA6PDwS9kJLybCkmFzL8OXEST51iyMzT+XPg Oa270bofob5S/Ivko/jbUcRfqaJtsjqaERCH93chSNvYSBw7pzjDt4SDVmSG vyOe+4ULyTVhONSFsmRyMTgslGH71KKHlz3tPTDtf+wwDwGv4rn1/u3FrGZe iIOPsNOK8Rp6+sTsNbZCUDNP1Pb7hWsoSBLsERbuIOK+HjQVPVPpeoxU+hEl rIlzrftRg2JU0MR2GLHKLXIu0RGRR9me+I9YPfE/kvLr4u/WgyYpgm9geVte 91mCbUsqPbOTlwM53EgdBUrvXa2fSViPGq3Mj3T/SwHYyrYVPJq1zgt6mDDQ uJEKjWlmEGSm/bhqddYQpPJGI/WU8z21NMN18GWryt3GMdd8vvm7zLM9m47U F//IeyaRL+seYqVDY0XDMHDCom1jnEO9qAUUoNgkhjet2TS6wHN+vw3w55TJ btxGdhvgr/UFwX8jDkOdcimMc4o/yX7XmaiKUmr5BsbUnxvYg8TRcw7c5kct J5QFwZ+ycmM8oXI5nxR/Lvc2wJ9LTKOJghTzqJKn/Y8dsgCR9aWVLC6nlNrF LKP6giFL3OVmr6jKUESSG4b06oC+bJflX4tDKlzr3yMpaZ87J5tYEGlBqQkw Ur9pnnMxMx2eFDHKLaWfFHHif+L/lBN95O+Ef4yDpsx5cG5ZllcbIbQwjD2K o4VnWKC0c0azPUvWdC3Dnupk6MOUTAZ0Z7SL1gjRzY2gP9WIzU/SKU1lpXHH oL8YrCfA1xtZE2lLBaDrCyvNNl4hbKO/ujJcULxbZpWoITCJ0AiycyZC39cY geeTgdWIEbvFdYEMf+aNy9LctoHs8H9HNFxQydas0AxvA/zh6wIZ/lzR6RrN 8OXqWIi2ydSnWdzf+22AP+esMwm1LI3Q0PavbQNjGi3IUkI7ZHqWK8WfiedR JdbGUvz5qVGfEN7TDH93Pel/2qHTTepRr/dNY2ExG23Hv7oNYJ8nnsZHD2YS qmcZIZDD8hksCR0s6MTQ1gBtAJvMJEyPpyo6JUZGyXWTquJ5KU+V8EFdraUj Y3X7qiL02eOIzQlO/E/8/674TyxoLuVRHq/gHQV570Feba7N6DMvcxx29IZw nwdYYCvkLW/Ldbm6qIxmFNe7PQSbY6I5TPttqZlg8zpno+gOVlnzmNCgCQMl N76Jf7Ap1SReuEhtpT5oLav0bJ1EVovBmth8bpungacpPh9+lm+1v9FXWzIc nvqFIZZUKl3qZwwVF74MUqDMAtI3rV0ka3FsgkC692PoBdSXvXkaDKILAue3 HP+ERvGnizhmoJSbRN2klDe5q+XqbkTa/nW9DngyLStr/7MxHsYHGf5Ko0Ww aJOYdHtQI4WM+GD/A4A8Aa5PI9/DiwU71ygO20uwL2gnqqYbwnCm8dNY6bo5 rIlqz9btEBP9hp6VhWnvu3oHyHg9aCSZMGXH8ameH6nNVKke0bFHCp3fmmSS AnikFIwZ1qyeko1STvxHpeDEPyP7dfH//X+7KA7nJCB+HuWB9ctqe/3xjir7 xdoT3V2jadf73ZRyXWus3qgUtBiSui0hk+2bEALhLhd0X+934A58BuoFfsMd QL3+RCn+/NloRnc5n4zGznel+STnryvr04f5+Xq5hGcn1yfHj8r1OS1xLHuk x+DupyFNfkYuC+dzH5U1ymdO83VyfZBnaHv+FDkctsOMn5yTRpPj/0z2vN5V llFZg3zuc5qvk+ujPOu7LPhP2k8436m/4n7SzrVze4nTBQ+aw2ng8yB+w9nj cLaz3UU7ePNvUya71Ux6LHVbL/9sodwTDT9RtvrsSCumSvWgQp4U8SFzIOXw oCxP80kZnqQct7BO/I/kkzI8STnx/5Asfzb+cSbhYMjtUR6vfWRPtw0MixzR LedE5vgNC2S2qkKM1gCt4FFzYGt6eVvYv8zO5cpMXQ2VI6ZB02+MGHg2467e 0phQJVYfa8C9RjvYI5wh6HriO7b01C9sdc9yKRn/HUVfhHz0biEowow7Sncp twEb21gurawynnXGOb/n+LsHdc1oo2n8JL51SNGjaBluA0d2zdAoBZWR12lh nJmBSWRO+xvXGBnJleIPkUvxZ9k1YgTS/oMf9gjOWb0kcimZtkP4pyD+93AG vTuj1l7P83p/2v8QbzzkpoNzNIyI6AqxRZWio3m6hka45oAQy6ru3mLWd//b bgWdUzOpRjQTB55dHPRIxU1MAAjBXE+mx0hRHylixNtBlp4aHaOsnhoREwvi qRRH+DkCTko8Z/XE/yn9if+Ez4ngfwz/JIqj3cos6OIs5YvfThu2bgaAEgP3 +lRA3h6Ql7vjsGXL09wmG1BQt9qqsRzrujoLuq3msX5Za4wHqFOGN+odEFtm cYDu1kN3FVF1l8Zg+gsXp2npoax0xhTnuWXxsPA1vY1H/LnoUTw1/0333IMD 5K4WNKgJKs9FpC4DfuyvPThZt4HLyvB3IIxmplG9PLGgU54h9MVbUlr1EHy4 iEBjR5GztUMjSDPUqJuQA/MD92CsvrAeRdr+dYakgqDRMvAcbpkFLTwnexIy t1ZfKf6cJ0fmpO8XnlnQaPWe8nyw/2mHm88hO7tecOlduMYXJ5EQUS4AACAA SURBVEvTITp/+Ww5hJjlZLmm7G+i3ESXBmZC+m5BG4jwZJP89TigBmNimkP6 V3lL85nzMClxpN4/ajg8FWqSfuKvOZz4j3gbifCL4s/rQafCWtjbqzNFQXar 7C/LiWrkskUc5gTaIy7DsM+hcYYeBrjribAASJpu4Smsx8JuKabZOCWNZwzE IXaScW/XcceH4mmsLHtko2uuS9W62qy1LGVPfW1FMgz7vAUEkMm1ZZTpGgib 8JPiz0/pl4G+mWrRa9FpvLB/5P4+wJ+FTf2wgUx51jzfPUEg21o+QQpIymQt jpbuVh/UgkB1ofhznuo31/afzg4NaIzilxmi+ThHeL+ULPAMwZ/bv349aPu/ DfBnYUfvxcH+hzO3ydVhtSIAQF9OKRi2Fnc8mv7nOntZ/ZnTefOUJAeqvLBy dO4TzzZt2V3buqNKqtmeGgXhbmjKA62Y5J/mOS9rVMSInyMSPc1hJG/69yCr I0lP/E/8//b4qw96dz/AZbi8La9oRuge69bm7K3rGlzS0QTegILQfTMQ7He2 W25taDKWzdcMDCzuza1DzQ5oe9BVA8SyY11nGlL9jKoY1bcV9OHIR8bXJbPE uSwIz1ZE8Q+OdgzRfIyNwP/WaFJ5Sca7WhzhAmIdQxjG2I/PmU/4CfUl+LsM J9YWy6W3Aku6GlkQE9nXA+dTWj4p/lz68S8eCP70YJQrbf+6HgVEitFsQ+ZN Z0gG0TaxNJUr0NdDytIG2BiP4h/aWMhH23+61jM8nvMvHpMrZTXINep/2mGf /rv7gWcSAuuXthZHfawGSETbOWDhNwysD/I1dE9u7AWPdkix47mxDOjdHk8d dlRhtvWvmgATlZtmNcn86d8jRsRBPf+03K+gmVyM+DxoRJz4H2cgvRjxeeI/ KvcraL4z/sGC7mN1NobXuspXi7t4lAf3zuCg5tJ7VdC2KaD9VnixOg7tqAtD w0dMsz1v+Xd/9Ob81JxnPSxmo9vjbNfDa+ag1lgNYrrrAWtLTfcpd9bejU9H DxnxD8SFytqyx+063ZklzWfEjNEoA569e7AmLKsUwzKGSKNcNjm/D/BHVhd6 1470a8b/7asPBvH5YhRPzTzrmhUKQupjDQ3gluPvWGK5UgyL33kkbWlbZq1r +0/bvMqV4s+Aq7WuXKmfWtq/+zLQt2Mb5AMpffQVC8Jfv2K1/acYfqj/AcBz RLbei1pXuSzLS+2UkR1sR0d7OfNNOyFJsGAXD6M4PP0w7Jp69kAWoziOqOvQ XAYi5Nmm9Hprkm36VJrzJKuRgMrGQR5G5U4kGmUyYe/E/8T/74o/W9DQXaUs 8q1a0GE9DVsrw0XkeXvZznuXDx8BQtsEQAKrrcMNIcwPnhboV39+lIfTLYhB JmZx73CgabnQ/gIBxruKsApNR+p9yj34hTkr5idoZq9OUcbr1XJWo70NWbow k5DJjIfRjg9E1i0yLcjIdDZmKntKsBGlWiUqWrB8i9BjYEF7sruuVAfBQWda alajCATONp1Rxn+P1HsRnDOyJ+smc9tQ/Ln0dH3z0P4nfmF7Np0lqLLzg/N2 KCL369G4Arf/+RgPSHbFn/9qVFIo+mn/AwB+Vym0XpG67N0HzV2eKYQ4DyW1 oBGJsUXHcRL1Ia6WWGj6bAEgMSEUef3Egk6Ngq/TzJrVEeVMUsRsR4mj1+yI bn9KmUo3f3Ze0JzsxH/E/ES0E3+9+/Pjb6vZxaWQaNYI6p6EFj5hKxbVdZnN mVAfsE4T3vMLOCO6Hrw2NMIm3yVxtdgZ5PgOIRw9DmRzW7o41WJwINNgQXPW W6lmNkVXU9iCDm2lEUeLTLMCaeZU32pZXPfKM1c/fPvYBqPwxf9Nd47wDS7x 1YZ3pgzicwNZ6tfDQC5FwFJ09FwB1+iCQLNl8d0Bz+JH85XnUF8Bf74Y7b7B earVHxptyax16e9mFrRlNdmtHIRhij9TjmZI8t/Udxza/22AP0ExtKA5MWCo XJWMZ23/6ZdBaP9h7CFt//P+BwDvRdX6QwtRq4n7VJaHLThXV232o4Xc/ScO 4myxjpQMamhb7AfdDXZxYlPzjoX0YIyDZs5TxZjeguSgx4ceVLIR/UjVjyif CqXZjq4nco3+HuT/xP/E/8TfZ8IzCV0vyh6FbkGT46PufcWWMrxbuQ87Atw7 u1tmO0vUM2+2cmkzD02G3h23v3YGG+kWLcjh1QYE2jn1JW0+Mfhq4XOoGabR DqDKSC2ycA2Jr1T6rWnd8GCgvD0TaiR7uGa/uSFQRC762w9m6anFqrIHAOFp 4PHnElPrJuCZ+mrh4MrrywgCPiPKLeNnVBeThgFvkQWGQ/tRlojyc2qxetmT uHV4GoiFCH/BckHw55RJRITWV8Cf2n/8Mkjbv7Z5bf9pJBUjUKbrxtgR+oS0 /U/6n3AUgJe1a/3bvidhjyNermibqoQF5yyXHgxHXmkM1tmoTwXNoBHN3cIn diFh0c7rTXCY1+a5BT3R/EdUawbr8HquyTWfg0YE66GRsHNxUlYxFfAI/6OC TvxP/E/8/bnvqNKmoaRuhmVZXkHmc12UuZZxX+92CxShYVYte6URjGXzX1vw ht/zG2UPzHC5FaBEa91sZIRlQNo2iaAZhg53PNOo9UJjSzWfNEqhuMS+tsOk RLUQy4AG0mi4UPbZpYWWsdXGf9ly0YIAbD6+W0FA4znlVuVS/Dlz9SGmPGf4 u+o7YEkN42q5aJ0lWASxwHN4Ubkdqiyc28haDzgjw3+T+hrJFdpYwJ85TC3E 0HTnK/mN6l3b/2hdcvob9yRM2/9tgD9f3wb4h3pP8Q/5cHra/p/2P8aq7+us p76v99aFA+ANBschz/Bra4CM5dyIzlbnYBbNfFbLmtWO2vLg4BMABcs/F35k qEUnylbvpimBOE2ZqN8jpsSk6NHfkVwjSe1xHOBw/mwqwon/if8kQz3+Nviz BZ30ri2Wo0dx7PP9sPflCCHPFKERotzAVjPHR/tpgZzbPsOwBkoDF1xCyDM2 57bmIL99fLOZzz2K0PZwYR3Fo+es/ZiGR3XDXUtMV/YCJRa/ipjdChlOZiRa hpNYVys6tbLLWK5tUK75GTe5265nq4jZs2rVjjBUoQqRjSJPglxI8HfE6Qi7 ly5ZfdAOo0x9teGtU6tN5UpnSCqGGf4uJZ0d6invwWpL23+Io0/bv7472v5v A/yNN8Vw1A5T/EmQ/iUX8Gf6kVzbMQy13hWW0buTYjXvfwDA9ZPsb6iJ+1oc dWmkupUUH+yeTizr4FaWDQydTgjRII3jNP80ztrlzF4UPJwFrbVox0jT6jHR n3M1y+kTyknRaREfynDC/JzVp/ikpcyhThNP/FNWT/z17i+Kv/qgWaPYoN1u Qa9f1n3xpNXtKYvRLoUWgJGZt+ZN7jqBokHYKE7zD4mPNr2wO0zMJQK/RUvL s5aFoJmDRrVzOvto838nvq324PO1AvCHLWjV8MgyVLmYmItLZ0P5v4nlEmTf BrMEU7lG+Bg/kFshJfV7ci1jOtOy/f0aC1ozhLf6w63ADwR/zjmd4RZES2X3 LeEevh7S9j9f0c34STHhp94H+Ov7Jfi7Qg9a0CnI2uYVfyYeRV8wmeKDseyB k+P9DwCdfb0BPEEENJPQdg4MpusoljmNSk6DoG0KDO/YzTRhMRAXf03WupGt 62pyPmj6zaH1oI+kp/p5bgWM1P6IcpL4lP4g8YRslMlTSQ/mM0LpYPqJ/4n/ hP7nxz/uqMJ9HfXAy9vyWu9dtktYAFrDNuBX3ujxztizDsT1Vt3stcaHWA8b KPfVP76stee9bOSAbmHRNexvn1bTVsizu27s0bRWOgoPXx+3LH3zialG3ei6 jKM4+ELXmtBHzNKcsDTZjTvkMyqueBo7hPhzoJnnE+6q7Io/10uaT0Agjbop /m8YMwhtYAPC2g4QrEprGyn+nBKsY8V8k68iFQrjtlE8zTwf/jJIZQ84B/xD +5m0QKNhNlIwR197nJu2VWn/w5mEnHna5kNxGg3CB9ep4v80n+P9TzsetPqz DuOtX1bwMkn2mHWXYR2luKASrawUKVeiXHvna511uFX/ArBEznlPp3IDwR3g H37bz58BfHIpR86f7Xr07CehHD37SfIZ86O5PX9K0z/94Tw/ms8cyRP/E/8T f7nLP/Ytcy8HoK/WUU1UNHeHTQF3/g2Azepk/ggZ6nsKgOadMN8FLwjCUdm9 UD8CufPT/qZRgI/yuP7r6j40bsBv6Ef64fMOfMrsI4zzyY7PN/yvT9mz/PdG ZWFAGWjSTyfjZ/Jh9T6Wnfn57cl32f2G66dMFmT5YMAPyzX5/ExlDyWO6oLr TnGWrO43XH/zt5Q48Jzm9v6ROk0lYgzTx0M71GfJgL2/S31BiN+zuphgmFYo hGdkdRd4Pt5WPc/391ZfkNz0PR3VqZWlRYzkUgJ9d/gD4lj/k0z1poDj3tFt l90JsvfOAGhPwn27QspXQ5vtboihTuI6rAse9LN7iUgK2hcGIUUSOvF6dqvZ aUWmlTGqpLRW0m5u/mx6rQ+O3roRn5MmOOoCJiJP+BmVOEJyzu2J/4TJE38t 66lEKYcTHiZM/kD8ewe9rtzdaU/7avHIj0IbytYU9Ol5+3U9NgnVoNWZ46YA b4sLai6P2smGmJBdQ2zOzW2d/rqu1+VqZZnrGcUzVvxZZ0xtQhZGvS19I7Kb rz/Wlu08jNPknNM5/qG4m5TCXMHTBIb5qdFMQjtvg9W2/CP3UQwvy8iypzRb Fu3AEm2Uj+IPwn8eDQJf7wF/4ieJCghsbyRX4JazUgwVrnQGaSh9FAe9eZoU f2LyntKEi5s8qO0/XYEvbWOKP/OmYzOQirsN8CcO3YxWzgqCoeLP18F3nDak 2wB/EJO6yiM8Yk/7H0vx0wit/6wp3YKGHObxCKvH6dp18LMEQ5Byj75oQ5bL 4szz3YmxrknENKHpojiy2evdgp6ox4kmnGjFiRI+orSZcsTJqEQle5qbJk6k npeVsqR/n9468T/xP/Fvf+Ou3gWg8OeuEnYLWobm6t+av5m6j7ZJCi9lx/MG ua/EBmw+SGNdLTiku1Oa/VtjsV38BlnctWgbHgRF6bmeGl7dhVF4vmXY8Qph QUnaOYzGFk+/ATgWp5muGc0FQTQ8kxnNfJWsen3L7pYMH/gHPUtJfDcTp/hA mEEWNxrYxsDSZBACz5u/ZczPIwc2oEh9FU+fYpiWq3s2at1p1ERgD76tKgKF yuJSmFsAHAcdmOFWl37twZeexgvD45BGywQBNTpF2/9tgD9lex/VO7fwybvD ZSHDn8k0rl+bbmr1B8qn/Y9fobM7FbbeB+5OEGQLZcRIZ+p/gz+736LlMpzp nckQxh4jD8XTtPwnVnaPg36qXVONN9e3o0w+lOFBrXuEVQzoJxmGY1TiKCXl JyU+8U8zDMeJ/98V/9QHHaZSV8pXoDuCrR+sGVmgRewuaSut3uWzX9gmEJrX mNff2KKfxZ5y81MQubKi3cQbXgAv1FxY75hvGXAa6wqPJsRSgEd/A8o4rpYL Za07YkwthUC5tXwCk6ERpBZi8Y+8e2a0fYcdVYJQ9ixbLgqy0aT4c87qs9NH eMxgk+vSaFL8icNkF/ZQKKT9BBBCfZUB28XTBALGMMPf5TnaQ5IYuKvFqhlq 29D2r19O2v5Hu7nzI/olp+1/ZNVSicPV7FiK0Ro1fE7HOewpbmOKPzeqkdV/ sP+xI8w12VrH2zq9lxC8ofMGXf/Iiy1JZw8xwzWfnoiYsytrsP9h8ixZ98Mo jnCoJjyi6rlSj2j+tNCnBCMtfUQ5P/17kCaV/Uhx84JC+on/Ef5P/FMOf3L8 +1ocfjgtLvwJvO5+YZoZyNTwswdBG2dB/A8ozrxNe17wIhtNXXRb2EIyfP8e NjnkZ3dKXogjaNQi56AJIe2PLyB7CQbNvAHqq+XijCxYkUYTtG4RAlBNb9na IFq0WmSQ0kcRLER/n/gZ7e8tAzlIkVpknE+RUfhQyiayQ2SsiekaEfxUWItD uTK5kOHPOKjVxtlyPiErlZ0TA9uWT4o/eqFJFIdWje5orrCnM2OD7BOrvxCN MhMYC1Z/xvk9fF2l7f82wB9Cg0z2gA/nr+0/tfo/1P9Q6dYHXmzhz7bGfZwM zv0pH9G+pt1ng+s5PB4d2bJ+tPXd0fRGD6QLaoPL5aHPvppdwDccqiGf3p1o zj+iY48fXMq8xMmDgaUJDkcEHDSVPJNR+ol/yueJf8rzr4K/29Wbx+FkEl+L g/bOYnDYhkwSd8tf2MZX3he8P+u3GQwWdNo7d3OeF0ilxUAsBDvY8k551kP3 cEMHYk+c74OXWi4B9w3AIF4YvppHliZzyNYW32JNPl9rIuSjJoldq6UgND3a Qdu0padywaPEPt9NkGSeFX8uXa22zT+1ef9gCk6R1eyU+ZJFO+hZI0YUhEmM sz048Z8GnBX/VC54lLj9j9Yp5vYfLMS0/avlGygx2CkmnDVqArH9x3WulTcM 8gntf/T1Gd7TFP8ge4Z/Ljs8/lQvPW6NJpRw5+n2JAyTA2tG2pO60cYjKzj7 JaE7WZjVDXHBhELTNfbI0L7+8+oQT5WeByhWj6aP9OQ8fU4zKWh096lcc2Ym zTE1HJ5KoYkH+cSJ/4n/saw+JNdPhX+6q3dgvqa/wq9Op1aw2rnOAR3S4YxZ 57n2mfTMzf6lCYp5oa0TBxA42Z8NSLFVaxdBw48sIBDE6reyIlp63Hkk0JRW VpF84LNSK0Az1N3BVZmnFlB4auLTbBefg6Uw4Xki+EY0IySD7CD84XkeiRzK UjaI8sn63SmGWuiWRQFZWSB8UvxVrkl9bR4fLXEDLF5Y8ef2fxvgH2RP8een 0kihLaMR/N3f+frUqVzwSIb3wg7Fc/Q1w2RpfQWURmuOB35G/U87Hm1On/W3 5reoBqhsK2uPfTweORSWG9eCrHq3kZrqWYTJ0ILmUjQl1dVzXTp6dqTMnxZ6 RAOP2EtV+iiHEXHKyVzqD/F84n/i/zT974q/21EFe/fFPaT9fUVxNqkGYyS9 c3X+6raB1Z61GOdg6pbm1wZAhrYR5Ca5GNEc9REt6NKAALCJxarqtGSRFUqc Rhd4MjfKXLJK2sY+Tc4q+GGLp6/XI4uDU4JPPEhnsjOBvktbZrmwgBOeA3u3 Af5Mfxvgz5nrGhGQi3SmnH957iMLiGt5FOPMaKhVG9rJ5q02xp8Ze8/xd3/T 6Atf4mwPSRNhtIM4c6hRE9r+0zoN7T/dQTzFMEWvnfN4/CDCZMcZIw4RNUFA 4yfFnymf8nyk/wEA13092lxr8yWIBT1QmKlJ24nRcsg2KnRhHvC5pb5vuEL5 lpntcQPyAoQ46JEGO6J+Q8pcNx7XrgNshwyMmB8RjzL8KBQTlkKeX/Hsif+E 53mGmueJ/0SEvzD+YSYhxIK2bvOVbeTogAbg5xlaFtF89i7pWqS6qmvZuUXc eMLW+mL2VgczeYsWNzPcsUjjT1kNQqIdlB6DEXYQPQYWmenPej2JKTaag37q 8Cx80wk0nM4papGRRJUsRjsw84X4yZ512d4G+BvNqL74KOIftCPggwx/oknW 4tgEz8lsuo1oUvyZJvhGSwbFCMPAT4o/se1m3I2a0G2Af1pffIR6CZE58Pxw exb8HfHNM5y1/1k8vp3T2bz6XqT4w9Pog9onpASgZyf9Tzts5selrZ8Bnnqy kQXtMsoWsYO4hjsr1OXbRXdSc57NItYwao10NsaidzsLi0aNg54ovXCd0hwn TtX1RKN+lDIlmD8bpDgIxeRi8uCI+MR/Qnbif5zyl8Y/Xw+afQYQC3p/mG1V Wn859oyt38Tm7tasLULZLGLL0woyjRG8HzDvdtjP2y8Vbf01B5/MtCUrsWAp gBBkNc6WgmpRBp190JQYVWsaN6o0yiqzVMaxpSxFOnrOKZvIDrplco0wDGUF HrjcTWQPXIFoUvwLJc6jStDySbElyvv7gIbJNJ9NGEv91KGKuU5ZZOZcrdE5 hltGrGvCpHU38sMGnlP8mQH9wgA9Ao+PPp7SBDKTSy1xeK7K2G/OeeoXs7b/ IxiGstL2/7T/aWzwnBKL5aidnrOgg2c5WTeudMGigez91Hw3TAUEx3uA/nKh GklilGFKC9nay7/Egh4ptIlKVOLRkenGQ/mMsj1INrqrNaXpTws6LsjozTzx P/Gf5/O3x1/joJNo6IIHHq/gPWWbZzk4fKNvegPSOTDooRfdpdIilHuPbDEe G/W5wcrO3Nwh8bJduq1tPuigwVhRM15sKQDxQUa/ZLHJog/jWgGaDwbWceAt jWQIRas1yvSm4S1/TreUMvC1ecvCxQtDKE0uDEQLOCv+zFJqbYWUSdTEPB// 9640jENNmcyCw1h2FXC0GqJlvmVWttavxvAKTbKqorb/2wB/fjD48VMQdNee ST4Q4kCj+NNTycxPxSfMNkzbfypXQHX0fnHiLcf/aP9jR8uZezaU3hm+uI0H PbsjC3rkiXaeFF55w8cyg2Zyq43cs+ItB4mf6H0mxqIFfUQHHtTYT3WsoPTk 8UlZT/l5WsqE29CMjsg7Kvej8D4lOPGfF33iP8/h58GfLeia+F/L8m9ZlwMb XuGjIPYV7GhuHq9p173AxTmp62H2bJjwsizL8rZcl2t9andh++mCSz3eFiDa 1BYbeF2uNZ+hgc/Ql8yXxARo2nKikwtpy5CDp0/WClC9Opp1xueRhcjndC84 +Hajo/lWrvGv+6oVegqAWS4hh4BDynPxHKZfD0GEdPWvQKmxt4G3NB95Z+5p Wchw1nQuK/Udh+KC7zjwb3JxKaHqQ72rUO3c5SoCr7b5QBDqi4tO279a0Nq2 n87GhMiOpNDP81mUgR9VBqC2keLPFxrho+1fo4m0/U/6H/RE80n8Y7n+19vS fRIbHuXxCg6hMweFuQ780kg87odCRjEPFaJ365e2G2zdT2tZ9v4XfobLdbna nlvLsgQfdHVl1I2960ZcRlBldMOGVitaDQxNaHCFUA5NTSnTKhnVhL4Do1d9 wh5847CjZCxpPmlLCmykPKcgqFCciO+Mvwqi+HMR4U0LACr+o7oY4a/nlOEJ PQSiEf6BpZI9hW+Ev5FN2n/IdtITKf5KM+riNwDt3T7e/rU9Y4p/yvPB9v8V +KMnml/hP1/Wf6/32k333rj2nn0rwnau3WX9a72nnXcaSrFzv/Vlva93AEYP wBGsjiZc87knflkDh1XMz8CdfsDvnwG06+n5D9F8bud7RvP5g/ncmyzflec5 TSj9oFzK83HZ/wjNZzorzQTJe5aP1sX3bj8f4nlCYyn3j+Tzx3ke4M9cfSCf CedpO/wech3hWWkGNTLLh38Afvdd3O+tq+x7EnZ11M5hBmCY+DeMX/bPVgt6 93W8LX2ncPK2VOu4ptiG31xQ3fMbm+fBCtKlOQDI3uGBxliqRWsIiuWse5DH EGzg8bagihCQJJ/P8raMpLCnDKIJ/tflukM6xt/K4meNMdttPU5kCkBtly4X J3rMXe2kK4OHamW2vVz39a74uyW/l95U3OSrgLPGJqFbSY/ywHJludL2n2IY 2n/Cj9QdN++INggf45mbGdWdlTVp/1iuF17hPXupe/vx+HP73+tC8OcSd54F /4Dhnd8LJK1IZVcMrR1O+h/OJ313rB0Op2jQO6j4M+ehR/rq/sfy/6+35T9f 1kd5/GO5AvhPY6D5oMNe2ng8fLM238XF1vw3V3LzacRGYwevRcehGi20Gbz/ LFwj6Fk12Za3JcRyuEIppvu+3kEzG/eC4Dzg67omHh5KeeBR9xEPNaRfduZj YSRB65DUncuB6C9i/Os3xBz/+3p/ij/vZIYS/fW1aOMHmUO/iY+APySWxrVU wp99X32TeI8/I7/XRboCeMPfeqiAv/HGGAb8rb1ViVL8uf33vSzG7X9d13n7 f5SHtbGAf2//dZ/7FH9q/1V7Kf7aoSv+3EprWYo/t3/jOeDP7b/irPgzkj2f gD+1f66vUf9jUk/6n9G6b9z+a5+g+Id3Z9L/GIbfpP/hvvG/3pZ/LNf/fFn/ QxX0yhSMQp+5xwsh+TVCH+aPThcUbZ2v6Sh7N6yTreONCKFyPKd8u6Dgvt73 R7gHR5+UyFIEvbq3Wu967yxJEGGV0WkOXdopvCcFly+rw0cWnOLXoD/lE78H /taOe4mAE4GWaAmgAfgf9YvHx978FfEP+DzDH6bk/tr4997tGP6XL+tPgf+H 2394v/6q+H91+0fzQQf8267ewYayCztsSJAME9bYVozlU2toXdflbVmWpX40 wQ8SVnzXL6tFaNQPEG4TVYev62phHu6F8ZuqcEvqOQjuoM0BQpszI6JnKK3N cgCt2+f0NrWGS9tezEXCGM/fGX+7xXyy7VBv2YthjSPgj/Z90ylP/E/8T/y/ Ef7/qeEPgv8eiPcYeEaCUkJzr3QvoSk68mF1DRN8QHCjpbteksWgdzL5VHGU Ax9lLNp7f0CfGIks2Xbm1j5c/kyJzHfWhO1+Uu9i6zybdCf+J/4n/if+Hv+X 4VCSBy6w2MuWwYGILE37ttqKMiBBLanLgAViMwrVnMjsxUxbT3iqhgYC4GHM mtJ1m9SxWfr61D2MuWkz+lH490EVAMg5DJh32atPmSTVcctvgn830wZ9h+LP A0GP8rguV5ZL8QlS1Fs9pb0gf277d8iHuqDxhoC/yW5SsFzfCf/OdjaeGVI6 hxRKoC0qFBRpKEXfr5+6/3npKEAUERIWXWJWMUGFBiWs2jXVmarB+E3QR8Jn iHZ/gXLYbtBlfLTxbntjq5vFELNR2hA2wH/rKDaPiXMOnbcfjn9t0Ny+NZBm F6Qd9teQ4bAcG9f+hvhHKbzpFCwX7lgD/tZbmVz7gJvVF+mbXS5K6cR/UvsP oVC1RWnd9fqiFsttMkXj2+IfBUHscbjNx7eptahgQLhwCLhIDFdfTW/dQzzV T9v/XLZL+h/bZQAABGFJREFUGyTcvKqs+WZOFpfIvnbvf4Ef93O3is+BhmUf 5McxvmFO+ipS9ohdWOZdLhq4iIUC8IuEmIwIDqNC0xSbB6pHQVQac11RDcFi BqgUQHj7sfjzm3xpQwUdQ8A92PDf5aKRFst5T/nW+BvNg3eaaOhdzCPZ8K8d 0Bz/nmjuziovHkzQoca3x/+j7b+3mQKTiCHqWBH+vR5LqzuKoOhN8dvhD3FN WFkp/iZF70bJDq09tWuQG+yvobEf5B//ZfqfR3m8stO9v35b5KlrAK+Cdv0A kXA04FvBhQwNU8vmAdZaVQzr3pHhwoinYLnuj2sLj1CLnVt7JayJF88wsLwt 9dd7N4rLsa6K1WxoQPbO9Cb+Y/G3oLeAfx2qXdt4xR5Dxi8DdWT9ZSixs/5W +PdmjUvsg3ylV1j2oC7Cv5pXdZjaQqxqnGKOPzNGXeGf2/671NSROTOiNLm4 swBl3uqrs8E9wjfCP0nZeufumkfxzJAKuS5XCweoea6ri3vbnyxOEO71fpn+ 57JdXnc6G2DdAK8lKk+mci1f59DZLqGYzhMP3YKK92E6LJLTlpR4kU+DUErX bOh6nt8uPnOe0fyhzlQ1s034WZYl5MyHKUZ+hfbXHl61/kn49zek4FEetQuz z17Fv5dl3TG+L/56q/ebG2nBMf77SgNf1nVd91Vc5vi3boL7kT+//YOwahym 7zzjX5/qnVrrBFndfg/8XZ9YHpcabpG2fyT4r2tbGeJtOdj+TdILGfi/QP/z qGtxJNoPDkenQFqzdgZFa8fcaDqgQb2AXuzWuLllc+32V8iqlgwWy9l4cM4B /y3DXW3tCnsT4RfVC5Uc9NlYn9rXGKE8De7+YlDbDUr4T8OfOpfqkQz421dC gj/6y/AgV923xd+ydYVS5pHgGP61vtit7IrbiJi+Ev5a7d/zXK/7XAGPg5PL 8Md3w5+7G1wU/968Ac7H+OSvtEcdSGT80fHvTxn++CH4/5D+57JdXladGFql FZc5n3vdqDedBlJg1oc+Oxlv8Z41l7Mv60FueOPZcU407oJYUrf93m7C6HkL eAgpD54X2/hkmkcbyakpcWY5wfiD8bdBmCoC6Kie3LlclUkdhf+2+HdZgkQg Mt9OwlTdEI/xKL2+Epo2KKpxHX9u+49RCgOe2duGLMZGo0G+Of4Bky4X1b6d uf0oz5YSaiGt057yHfBP6/oH9D8vHJDUcQQClAq0ZZ2WpLxqj6M8davHp/DY cU8J0Ijw/BbFD9KMpUgDytxXVS0uEd9DFyEadLsn/if+J/4n/in+L/dsyZhg IAyBxkBUezBjKEVwBG7kxHNv1Zmw57XWngPGuBiH9OXbq0FATGXXppykU+0+ 6BvnxP/E/8T/xD/g/xo95QAoaqemQyZiOgJ1txtl5nVyZ/INoQzPj+bS6ojQ CAM2cINgBC/e5VQzsUIfNhLIfiVy/Pe/7M7joWQSAXA8d7a9yNjI1WW7dp34 n/if+J/4C/7/H3h0VCfB2F4HAAAAB3RJTUUH0woOEDQKtcgSKgAAAABJRU5E rkJggg== --Boundary-00=_4oCj/ynRbBzCRgL-- From pgsql-performance-owner@postgresql.org Tue Oct 14 14:14: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 557D5D1B551 for ; Tue, 14 Oct 2003 17:14: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 50414-02 for ; Tue, 14 Oct 2003 14:13:54 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 0E210D1B58D for ; Tue, 14 Oct 2003 14:12:11 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3767271; Tue, 14 Oct 2003 10:12:43 -0700 Content-Type: text/plain; charset="iso-8859-2" From: Josh Berkus Organization: Aglio Database Solutions To: "Ivan Voras" , Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Date: Tue, 14 Oct 2003 10:09:26 -0700 User-Agent: KMail/1.4.3 References: <20031012213527.BB2B61CB4664@svr4.postgresql.org> <00af01c39112$d9ac4350$bf8ec6c1@flatline> In-Reply-To: <00af01c39112$d9ac4350$bf8ec6c1@flatline> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310141009.26247.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/456 X-Sequence-Number: 4204 Ivan, > There was some talk, either on this list or freebsd-performance about > setting the default block size for PostgreSQL running on FreeBSD to be 16k > because of performance reasons. That is: *default* for the port, user is > not asked. So an automagical method to scale non-default block sizes is a > very needed thing. Hmmm ... possibly. My concern is that if someone uses a very non-default value, such as 256K, then they are probably better off doing their own tuning because they've got an unusual system. However, we could easily limit it to the range of 4K to 32K. Of course, since there's no GUC var, we'd have to ask the user to confirm their block size. I'm reluctant to take this approach because if the user gets it wrong, then the settings will be *way* off ... and possibly cause PostgreSQL to be unrunnable or have "out of memory" crashes. Unless there's a way to find it in the compiled source? > > 2) may not work well for anyone using unusual locales, optimization > > flags, or other non-default compile options except for language > > interfaces. > > Depends on what you consider 'unusual'? I hope not things like iso8859-x > (or, to be exact, European languages) :) On second thought, I'm not sure what an "unusual locale" would be. Scratch that. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 14 14:16: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 986E6D1B54E for ; Tue, 14 Oct 2003 17:16: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 50906-01 for ; Tue, 14 Oct 2003 14:15:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9828CD1B542 for ; Tue, 14 Oct 2003 14:15:30 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3767292; Tue, 14 Oct 2003 10:16:08 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: psql-mail@freeuk.com, pgsql-performance@postgresql.org Subject: Re: Large Text Search Help Date: Tue, 14 Oct 2003 10:12:50 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310141012.50848.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/457 X-Sequence-Number: 4205 Mat, > 1. With tsearch2 I get very good query times up until I insert more > records. For example with 100,000 records tsearch2 returns in around 6 > seconds, with 200,000 records tsearch2 returns in just under a minute. > Is this due to the indices fitting entirely in memory with 100,000 > records? Maybe, maybe not. If you want a difinitive answer, post your EXPLAIN ANALYZE results with the original query. I assume that you have run VACUUM ANALYZE, first? Don't bother to respond until you have. > 2. As well as whole word matching i also need to be able to do > substring matching. Is the FTI module the way to approach this? Yes. > 3. I have just begun to look into distibuted queries. Is there an > existing solution for distibuting a postgresql database amongst > multiple servers, so each has the same schema but only a subset of the > total data? No, it would be ad-hoc. So far, Moore's law has prevented us from needing to devote serious effort to the above approach. > Any other helpful comments or sugestions on how to improve query times > using different hardware or software techniques would be appreciated. Read the archives of this list. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 14 14:26: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 7C1B7D1B531 for ; Tue, 14 Oct 2003 17:26: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 51359-04 for ; Tue, 14 Oct 2003 14:25:40 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 66019D1B4EF for ; Tue, 14 Oct 2003 14:25:39 -0300 (ADT) 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 h9EHPThn010953; Tue, 14 Oct 2003 13:25:29 -0400 (EDT) To: "scott.marlowe" Cc: Josh Berkus , Bruce Momjian , Postgresql Performance Subject: Re: further testing on IDE drives In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Fri, 10 Oct 2003 16:52:59 -0600" Date: Tue, 14 Oct 2003 13:25:29 -0400 Message-ID: <10952.1066152329@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/458 X-Sequence-Number: 4206 "scott.marlowe" writes: > open_sync was WAY faster at this than the other two methods. Do you not have open_datasync? That's the preferred method if available. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 14:38: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 04D2FD1B531; Tue, 14 Oct 2003 17:38: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 51330-08; Tue, 14 Oct 2003 14:37:30 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id F03A5D1B4F1; Tue, 14 Oct 2003 14:37:28 -0300 (ADT) 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 h9EHaNXk026762; Tue, 14 Oct 2003 11:36:24 -0600 (MDT) Date: Tue, 14 Oct 2003 11:26:45 -0600 (MDT) From: "scott.marlowe" To: Wei Weng Cc: Christopher Kings-Lynne , Chris Faulkner , Pgsql-Performance , Pgsql-Sql Subject: Re: [SQL] sql performance and cache In-Reply-To: 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: 200310/459 X-Sequence-Number: 4207 On Tue, 14 Oct 2003, Wei Weng wrote: > On Sat, 11 Oct 2003, Christopher Kings-Lynne wrote: > > > > > > I have two very similar queries which I need to execute. They both have > > > exactly the same from / where conditions. When I execute the first, it takes > > > about 16 seconds. The second is executed almost immediately after, it takes > > > 13 seconds. In short, I'd like to know why the query result isn't being > > > cached and any ideas on how to improve the execution. > > > > > > > > > OK - so I could execute the query once, and get the maximum size of the > > > array and the result set in one. I know what I am doing is less than optimal > > > but I had expected the query results to be cached. So the second execution > > > would be very quick. So why aren't they ? I have increased my cache size - > > > shared_buffers is 2000 and I have doubled the default max_fsm... settings > > > (although I am not sure what they do). sort_mem is 8192. > > > > PostgreSQL does not have, and has never had a query cache - so nothing > > you do is going to make that second query faster. > > > > Perhaps you are confusing it with the MySQL query cache? > > > > Chris > > > Is there plan on developing one (query cache)? Not really, Postgresql's design makes it a bit of a non-winner. From pgsql-performance-owner@postgresql.org Tue Oct 14 14:41: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 5E4B6D1B517 for ; Tue, 14 Oct 2003 17:41: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 53236-04 for ; Tue, 14 Oct 2003 14:40:38 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 4FFDDD1B531 for ; Tue, 14 Oct 2003 14:40:37 -0300 (ADT) 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 h9EHdJXk026989; Tue, 14 Oct 2003 11:39:19 -0600 (MDT) Date: Tue, 14 Oct 2003 11:29:40 -0600 (MDT) From: "scott.marlowe" To: Tom Lane Cc: Josh Berkus , Bruce Momjian , Postgresql Performance Subject: Re: further testing on IDE drives In-Reply-To: <10952.1066152329@sss.pgh.pa.us> 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: 200310/460 X-Sequence-Number: 4208 On Tue, 14 Oct 2003, Tom Lane wrote: > "scott.marlowe" writes: > > open_sync was WAY faster at this than the other two methods. > > Do you not have open_datasync? That's the preferred method if > available. Nope, when I try to start postgresql with it set to that, I get this error message: FATAL: invalid value for "wal_sync_method": "open_datasync" This is on RedHat 9, but I have the same problem on a RH 7.2 box as well. From pgsql-hackers-owner@postgresql.org Tue Oct 14 15:03:26 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 B3B37D1B540 for ; Tue, 14 Oct 2003 18:03: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 52276-10 for ; Tue, 14 Oct 2003 15:02:55 -0300 (ADT) Received: from ranger.macsinracks.net (ranger.macsinracks.net [194.100.243.51]) by svr1.postgresql.org (Postfix) with ESMTP id C1C8AD1B4EF for ; Tue, 14 Oct 2003 15:02:52 -0300 (ADT) Received: from [194.100.243.1] (marko.karppinen.fi [194.100.243.1]) by ranger.macsinracks.net (8.12.9/8.12.9) with ESMTP id h9EI2jhq094575; Tue, 14 Oct 2003 18:02:45 GMT (envelope-from marko@karppinen.fi) In-Reply-To: <10568.1066150377@sss.pgh.pa.us> References: <200310081831.h98IVT919657@candle.pha.pa.us> <10568.1066150377@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v604) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <9CF10722-FE70-11D7-81B6-000A958D89B8@karppinen.fi> Content-Transfer-Encoding: 7bit Cc: PostgreSQL-development From: Marko Karppinen Subject: Re: [PERFORM] Sun performance - Major discovery! Date: Tue, 14 Oct 2003 21:02:45 +0300 To: Peter Eisentraut , Tom Lane X-Mailer: Apple Mail (2.604) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/686 X-Sequence-Number: 45368 On 14.10.2003, at 19:52, Tom Lane wrote: > This means that relaxing the check would require (a) finding out which > of the sub-flags break our code and which don't; (b) finding out how > the > answer to (a) has varied with gcc release; and (c) finding out how we > can test whether a given sub-flag is set --- are there #defines for > each > of them in gcc 3? Okay, I can see how that makes this unpractical to implement. Thanks. The current error message is "do not put -ffast-math in CFLAGS"; does someone have an idea for a better text that doesn't imply that you actually /have/ --ffast-math in CFLAGS? It'd be good to acknowledge that it can be set implicitly, too. And on the same subject: On 14.10.2003, at 18:13, Peter Eisentraut wrote: > That sounds perfectly reasonable to me. Why should we develop > elaborate > workarounds for compiler flags that are known to create broken code? I > also want to point out that I'm getting kind of tired of developing > more > and more workarounds for sloppy Apple engineering. Peter, you are free to consider your current environment to be the peak of perfection, but that doesn't mean that the only reason for differences between your system and others' is the sloppiness of their engineering. I'm not aware of any Darwin-specific "workarounds" in the tree right now; the only thing close to that is the support for Apple's two-level namespaces feature. And while you can argue the relative merits of Apple's approach, the reason for its existence isn't sloppiness and the support for it that was implemented by Tom most certainly isn't a workaround. The fact of the matter is that Mac OS X has about ten million active users, and when one of these people is looking for an RDBMS, he's gonna go for one that compiles and works great on his system, rather worrying if his platform is optimal for running PostgreSQL. Supporting this platform well is absolutely crucial to the overall adoption of pg, and even if you consider yourself to be above such pedestrian concerns, many people who have to make the business case for putting money into PostgreSQL development most definitely think otherwise. mk From pgsql-performance-owner@postgresql.org Tue Oct 14 15:15: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 38631D1B538 for ; Tue, 14 Oct 2003 18:15: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 58881-07 for ; Tue, 14 Oct 2003 15:15:20 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 2161FD1B543 for ; Tue, 14 Oct 2003 15:15:19 -0300 (ADT) 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 h9EIFEhn011364; Tue, 14 Oct 2003 14:15:14 -0400 (EDT) To: Josh Berkus Cc: "Ivan Voras" , pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL In-reply-to: <200310141009.26247.josh@agliodbs.com> References: <20031012213527.BB2B61CB4664@svr4.postgresql.org> <00af01c39112$d9ac4350$bf8ec6c1@flatline> <200310141009.26247.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Tue, 14 Oct 2003 10:09:26 -0700" Date: Tue, 14 Oct 2003 14:15:14 -0400 Message-ID: <11363.1066155314@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/461 X-Sequence-Number: 4209 Josh Berkus writes: > Unless there's a way to find it in the compiled source? See pg_controldata. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 15:16:21 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 A8C62D1B53C for ; Tue, 14 Oct 2003 18:16: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 62576-02 for ; Tue, 14 Oct 2003 15:15:49 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 2E6AFD1B531 for ; Tue, 14 Oct 2003 15:15:47 -0300 (ADT) Received: (qmail 7525 invoked from network); 14 Oct 2003 18:16:04 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 14 Oct 2003 18:16:04 -0000 Subject: Re: sql performance and cache From: Rod Taylor To: Wei Weng Cc: Christopher Kings-Lynne , Chris Faulkner , Pgsql-Performance , Pgsql-Sql In-Reply-To: References: <3F87D764.8030306@familyhealth.com.au> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-duA7am3AW1kVGadB3EuP" Message-Id: <1066155338.63280.7.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Tue, 14 Oct 2003 14:15:39 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/462 X-Sequence-Number: 4210 --=-duA7am3AW1kVGadB3EuP Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > > Perhaps you are confusing it with the MySQL query cache? > Is there plan on developing one (query cache)? For the most part, prepared queries and cursors give you a greater advantage due to their versatility -- both of which we do have. In the cases where an actual cache is useful, the client application could do it just as easily or temp tables can be used. I suspect it would be implemented more as a caching proxy than as an actual part of PostgreSQL, should someone really want this feature. --=-duA7am3AW1kVGadB3EuP Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/jD1K6DETLow6vwwRAoGgAKCECzHB9z/hSuhN8VgiDlJR+EfWNQCdHq6b 9bwfEQ6iaf2AP6ghESSl28M= =wXK6 -----END PGP SIGNATURE----- --=-duA7am3AW1kVGadB3EuP-- From pgsql-performance-owner@postgresql.org Tue Oct 14 15:43: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 B4A3FD1B4EF for ; Tue, 14 Oct 2003 18:43: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 63532-08 for ; Tue, 14 Oct 2003 15:42:38 -0300 (ADT) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 0289ED1B4E3 for ; Tue, 14 Oct 2003 15:42:37 -0300 (ADT) Received: by perrin.nxad.com (Postfix, from userid 1001) id 4AF2721058; Tue, 14 Oct 2003 11:42:37 -0700 (PDT) Date: Tue, 14 Oct 2003 11:42:37 -0700 From: Sean Chittenden To: Ivan Voras Cc: pgsql-performance@postgresql.org Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Message-ID: <20031014184237.GA21028@perrin.nxad.com> References: <20031012213527.BB2B61CB4664@svr4.postgresql.org> <00af01c39112$d9ac4350$bf8ec6c1@flatline> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00af01c39112$d9ac4350$bf8ec6c1@flatline> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/465 X-Sequence-Number: 4213 > >> This would be parameters such as the block size and a few > >> other compile time parameters. If we can get to some of these > >> read-only parameters than that would make this step easier, > >> certainly for the new recruits amongst us. > > > > Actually, from my perspective, we shouldn't bother with this; if an admin > > knows enough to set an alternate blaock size for PG, then they know > > enough to tweak the Conf file by hand. I think we should just issue a > > warning that this script: > > 1) does not work for anyone who is using non-default block sizes, > > There was some talk, either on this list or freebsd-performance > about setting the default block size for PostgreSQL running on > FreeBSD to be 16k because of performance reasons. That is: *default* > for the port, user is not asked. Real quick, this isn't true, the block size is tunable, but does not change the default. You can set PGBLOCKSIZE to the values "16K" or "32K" to change the block size, but the default remains 8K. http://lists.freebsd.org/pipermail/freebsd-database/2003-October/000111.html -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Tue Oct 14 16:16: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 D86ACD1B4ED for ; Tue, 14 Oct 2003 19: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 66999-06 for ; Tue, 14 Oct 2003 16:16:11 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C2BC7D1B53C for ; Tue, 14 Oct 2003 16:16:09 -0300 (ADT) 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 h9EJG9hn011799; Tue, 14 Oct 2003 15:16:09 -0400 (EDT) To: jeremy.guthrie@berbee.com Cc: "pgsql-performance@postgresql.org" Subject: Re: free space map usage In-reply-to: <200310141154.17227.jeremy.guthrie@berbee.com> References: <200310141154.17227.jeremy.guthrie@berbee.com> Comments: In-reply-to "Jeremy M. Guthrie" message dated "Tue, 14 Oct 2003 11:54:16 -0500" Date: Tue, 14 Oct 2003 15:16:08 -0400 Message-ID: <11798.1066158968@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/466 X-Sequence-Number: 4214 "Jeremy M. Guthrie" writes: > Is there any way to determine how much of the free space map is currently i= > n=20 > use?(ie. where and what it is tracking?) I vacuum on a regular basis but I= > =20 > never hold in terms of disk space usage. Not in 7.3 AFAIR. In 7.4 a full-database VACUUM VERBOSE will end with the info you want: regression=# vacuum verbose; ... much cruft ... INFO: free space map: 11 relations, 144 pages stored; 272 total pages needed DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB shared memory. VACUUM regression=# This tells me I'm only using about 1% of the FSM space (272 out of 20000 page slots). > I jacked up the free space map=20 > pages but this doesn't appear to be working. You know you have to restart the postmaster to make those changes take effect, right? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 14 16:37: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 23CA6D1B4E3 for ; Tue, 14 Oct 2003 19:37: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 75970-01 for ; Tue, 14 Oct 2003 16:37:06 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 1F8DBD1B510 for ; Tue, 14 Oct 2003 16:37:05 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id E82031E2E; Tue, 14 Oct 2003 15:37:05 -0400 (EDT) Subject: Re: Any issues with my tuning... From: Neil Conway To: David Griffiths Cc: PostgreSQL Performance In-Reply-To: <039801c391c2$4b83d600$6501a8c0@griffiths2> References: <039801c391c2$4b83d600$6501a8c0@griffiths2> Content-Type: text/plain Message-Id: <1066160224.28992.3.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Tue, 14 Oct 2003 15:37:04 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/467 X-Sequence-Number: 4215 On Mon, 2003-10-13 at 15:43, David Griffiths wrote: > Here are part of the contents of my sysctl.conf file (note that I've > played with values as low as 600000 with no difference) > kernel.shmmax=1400000000 > kernel.shmall=1400000000 This is only a system-wide limit -- it either allows the shared memory allocation to proceed, or it does not. Changing it will have no other effect on the performance of PostgreSQL. > -> Index Scan using comm_ent_usr_acc_id_i on > commercial_entity ce (cost=0.00..4787.69 rows=78834 width=24) (actual > time=0.02..55.64 rows=7991 loops=1) Interesting that we get this row count estimate so completely wrong (although it may or may not have anything to do with the actual performance problem you're running into). Have you run ANALYZE on this table recently? If so, does increasing this column's statistics target (using ALTER TABLE ... ALTER COLUMN ... SET STATISTICS) improve the row count estimate? -Neil From pgsql-performance-owner@postgresql.org Wed Oct 15 11:20: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 16AFFD1B4FE for ; Tue, 14 Oct 2003 19:47: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 76479-02 for ; Tue, 14 Oct 2003 16:47:18 -0300 (ADT) Received: from ctg-msnex01.staff.berbee.com (msn-office1.binc.net [64.73.12.254]) by svr1.postgresql.org (Postfix) with ESMTP id 92994D1B4E9 for ; Tue, 14 Oct 2003 16:47:15 -0300 (ADT) Received: from localhost ([172.30.254.220] RDNS failed) by ctg-msnex01.staff.berbee.com with Microsoft SMTPSVC(5.0.2195.5329); Tue, 14 Oct 2003 14:47:06 -0500 From: "Jeremy M. Guthrie" Reply-To: jeremy.guthrie@berbee.com Organization: Berbee Information Networks To: Tom Lane Subject: Re: free space map usage Date: Tue, 14 Oct 2003 14:43:53 -0500 User-Agent: KMail/1.5.4 Cc: "pgsql-performance@postgresql.org" References: <200310141154.17227.jeremy.guthrie@berbee.com> <11798.1066158968@sss.pgh.pa.us> In-Reply-To: <11798.1066158968@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200310141447.05788.jeremy.guthrie@berbee.com> X-OriginalArrivalTime: 14 Oct 2003 19:47:06.0625 (UTC) FILETIME=[F2B03710:01C3928B] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/471 X-Sequence-Number: 4219 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 14 October 2003 02:16 pm, Tom Lane wrote: > "Jeremy M. Guthrie" writes: > > Is there any way to determine how much of the free space map is current= ly > > i=3D n=3D20 > > use?(ie. where and what it is tracking?) I vacuum on a regular basis b= ut > > I=3D =3D20 > > never hold in terms of disk space usage. > > Not in 7.3 AFAIR. In 7.4 a full-database VACUUM VERBOSE will end with > the info you want: > > regression=3D# vacuum verbose; > ... much cruft ... > INFO: free space map: 11 relations, 144 pages stored; 272 total pages > needed DETAIL: Allocated FSM size: 1000 relations + 20000 pages =3D 178 = kB > shared memory. VACUUM > regression=3D# > > This tells me I'm only using about 1% of the FSM space (272 out of 20000 > page slots). > > > I jacked up the free space map=3D20 > > pages but this doesn't appear to be working. > > You know you have to restart the postmaster to make those changes take > effect, right? Yup. I still see no effect after restart. > regards, tom lane - --=20 Jeremy M. Guthrie Systems Engineer Berbee 5520 Research Park Dr. Madison, WI 53711 Phone: 608-298-1061 Berbee...Decade 1. 1993-2003 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/jFH8qtjaBHGZBeURAkKkAJ0cDa31C4VKxlHoByFaGY3EtQwMdwCgmA5k +Z9GUE3l7LIJVl9rII7d3TU=3D =3DgkIR -----END PGP SIGNATURE----- From pgsql-hackers-owner@postgresql.org Tue Oct 14 17:42:15 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 01542D1B4FE for ; Tue, 14 Oct 2003 20:42: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 87149-03 for ; Tue, 14 Oct 2003 17:41:45 -0300 (ADT) Received: from mail.gmx.net (pop.gmx.de [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 89FAFD1B516 for ; Tue, 14 Oct 2003 17:41:42 -0300 (ADT) Received: (qmail 11778 invoked by uid 65534); 14 Oct 2003 20:41:43 -0000 Received: from dsl-082-082-161-199.arcor-ip.net (EHLO dsl-082-082-161-199.arcor-ip.net) (82.82.161.199) by mail.gmx.net (mp005) with SMTP; 14 Oct 2003 22:41:43 +0200 X-Authenticated: #495269 Date: Tue, 14 Oct 2003 22:41:41 +0200 (CEST) From: Peter Eisentraut X-X-Sender: peter@peter.localdomain To: Marko Karppinen Cc: PostgreSQL-development Subject: Re: [PERFORM] Sun performance - Major discovery! In-Reply-To: <9CF10722-FE70-11D7-81B6-000A958D89B8@karppinen.fi> 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: 200310/705 X-Sequence-Number: 45387 Marko Karppinen writes: > I'm not aware of any Darwin-specific "workarounds" in the tree > right now; the only thing close to that is the support for Apple's > two-level namespaces feature. And while you can argue the relative > merits of Apple's approach, the reason for its existence isn't > sloppiness and the support for it that was implemented by Tom > most certainly isn't a workaround. PostgreSQL is only part of the deal; in other projects, people have to fight with different kinds of problems. Let me just point out the broken precompiler, the namespace level thing (which might be a fine feature, but the way it was shoved in was not), using zsh as the default "Bourne" shell, using different file types for loadable modules and linkable shared libraries, standard system paths with spaces in them, and there may be more that I don't remember now. In my experience, the whole system just has been very unpleasant to develop portable software for since the day it appeared. You're not at fault for that, but please understand that, considering all this, the last thing I want to spend time on is improving the user response mechanics for a "don't do that then" problem. > The fact of the matter is that Mac OS X has about ten million active > users, and when one of these people is looking for an RDBMS, he's > gonna go for one that compiles and works great on his system, rather > worrying if his platform is optimal for running PostgreSQL. Supporting > this platform well is absolutely crucial to the overall adoption of pg, > and even if you consider yourself to be above such pedestrian > concerns, many people who have to make the business case for putting > money into PostgreSQL development most definitely think otherwise. Everyone shall be happy if they don't use compiler switches that are known to create broken code. -- Peter Eisentraut peter_e@gmx.net From pgsql-performance-owner@postgresql.org Tue Oct 14 19:19: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 1D4C4D1B4E9 for ; Tue, 14 Oct 2003 22:19: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 07569-01 for ; Tue, 14 Oct 2003 19:18:55 -0300 (ADT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 8A38FD1B4ED for ; Tue, 14 Oct 2003 19:18:51 -0300 (ADT) Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h9EMIWo27040; Tue, 14 Oct 2003 15:18:34 -0700 Message-Id: <200310142218.h9EMIWo27040@mail.osdl.org> Date: Tue, 14 Oct 2003 15:18:29 -0700 (PDT) From: markw@osdl.org Subject: Re: backup/restore - another area. To: threshar@torgo.978.org Cc: pgsql-performance@postgresql.org, linux-lvm@sistina.com In-Reply-To: <878ynu9ed5.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: 200310/468 X-Sequence-Number: 4216 Jeff, I'm curious to what kind of testing you've done with LVM. I'm not currently trying any backup/restore stuff, but I'm running our DBT-2 workload using LVM. I've started collecting vmstat, iostat, and readprofile data, initially running disktest to gauge the performance. For anyone curious, I have some data on a 14-disk volume here: http://developer.osdl.org/markw/lvm/results.4/log/ and a 52-disk volume here: http://developer.osdl.org/markw/lvm/results.5/data/ Mark >Jeff writes: > > Idea #1: > Use an LVM and take a snapshop - archive that. > From the way I see it. the downside is the LVM will use a lot of space > until the snapshot is removed. Also PG may be in a slightly inconsistant > state - but this should "appear" to PG the same as if the power went out. > > For restore, simply unarchive this snapshot and point postgres at it. Let > it recover and you are good to go. > > Little overhead from what I see... > I'm leaning towards this method the more I think of it. From pgsql-performance-owner@postgresql.org Wed Oct 15 07:09: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 154FAD1B54D for ; Wed, 15 Oct 2003 10:09: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 18914-02 for ; Wed, 15 Oct 2003 07:09:23 -0300 (ADT) Received: from haeb.noc.uk.easynet.net (haeb.noc.uk.easynet.net [195.40.7.191]) by svr1.postgresql.org (Postfix) with ESMTP id D937ED1B52C for ; Wed, 15 Oct 2003 07:09:19 -0300 (ADT) Received: (from haeb@localhost) by haeb.noc.uk.easynet.net (8.9.3/8.9.1) id LAA49938 for pgsql-performance@postgresql.org; Wed, 15 Oct 2003 11:09:18 +0100 (BST) (envelope-from haeb) Message-Id: <200310151009.LAA49938@haeb.noc.uk.easynet.net> Subject: Config error on emails? To: pgsql-performance@postgresql.org Date: Wed, 15 Oct 2003 11:09:17 +0100 (BST) From: Harry Broomhall Reply-To: "Harry Broomhall" X-Mailer: ELM [version 2.4ME+ PL43 (25)] 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: 200310/469 X-Sequence-Number: 4217 First - this is a test post to see if I am in fact able to post! I sent the usual subscribe email - but got no response. Then some postings from the list started to arrive. Glitch? Or something else? Regards, Harry. From pgsql-performance-owner@postgresql.org Wed Oct 15 07:28: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 D7B71D1B538 for ; Wed, 15 Oct 2003 10:28: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 18241-09 for ; Wed, 15 Oct 2003 07:28:03 -0300 (ADT) Received: from gateway.vault-id.com (unknown [203.115.192.108]) by svr1.postgresql.org (Postfix) with SMTP id CAFA1D1B4EF for ; Wed, 15 Oct 2003 07:27:54 -0300 (ADT) Received: (qmail 26160 invoked from network); 15 Oct 2003 10:08:55 -0000 Received: from unknown (HELO bytecraft.com.my) (219.93.229.26) by mail.bytecraft.com.my with SMTP; 15 Oct 2003 10:08:55 -0000 Message-ID: <3F8D208F.2020702@bytecraft.com.my> Date: Wed, 15 Oct 2003 18:25:19 +0800 From: Ang Chin Han User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruce Momjian Cc: "scott.marlowe" , Postgresql Performance Subject: Re: further testing on IDE drives References: <200310101724.h9AHOTs24892@candle.pha.pa.us> In-Reply-To: <200310101724.h9AHOTs24892@candle.pha.pa.us> X-Enigmail-Version: 0.71.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB3CABE5E4499A0406330E725" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/470 X-Sequence-Number: 4218 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB3CABE5E4499A0406330E725 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Bruce Momjian wrote: > Yes. If you were doing multiple WAL writes before transaction fsync, > you would be fsyncing every write, rather than doing two writes and > fsync'ing them both. I wonder if larger transactions would find > open_sync slower? No hard numbers, but I remember testing fsync vs open_sync something ago on 7.3.x. open_sync was blazingly fast for pgbench, but for when we switched our development database over to open_sync, things slowed to a crawl. This was some months ago, and I might be wrong, so take it with a grain of salt. It was on Red Hat 8's Linux kernel 2.4.18, I think. YMMV. Will be testing it real soon tonight, if possible. --------------enigB3CABE5E4499A0406330E725 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE/jSCUNYbTUIgzwfARAqIXAKCi1u9ej1qWQiC+z14ZcwtKiJzJFACg3QgU QO8K86peq3/1N3hGiWpqJVY= =qihu -----END PGP SIGNATURE----- --------------enigB3CABE5E4499A0406330E725-- From pgsql-admin-owner@postgresql.org Thu Oct 16 08:51:12 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B788FD1B552 for ; Thu, 16 Oct 2003 11:51: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 88908-03 for ; Thu, 16 Oct 2003 08:50:40 -0300 (ADT) Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com [24.128.241.68]) by svr1.postgresql.org (Postfix) with SMTP id 38D3BD1B54C for ; Thu, 16 Oct 2003 08:50:21 -0300 (ADT) Received: (qmail 5770 invoked from network); 16 Oct 2003 11:50:27 -0000 Received: from unknown (HELO torgo) (threshar@10.10.10.10) by 10.10.10.10 with SMTP; 16 Oct 2003 11:50:27 -0000 Date: Thu, 16 Oct 2003 07:50:27 -0400 (EDT) From: Jeff To: "markw@osdl.org" Cc: "pgsql-performance@postgresql.org" , "linux-lvm@sistina.com" , Subject: Re: [PERFORM] backup/restore - another area. In-Reply-To: <200310142218.h9EMIWo27040@mail.osdl.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: 200310/174 X-Sequence-Number: 10735 On Tue, 14 Oct 2003, markw@osdl.org wrote: > I'm curious to what kind of testing you've done with LVM. I'm not > currently trying any backup/restore stuff, but I'm running our DBT-2 > workload using LVM. I've started collecting vmstat, iostat, and > readprofile data, initially running disktest to gauge the performance. > [added -admin to this, since this is very relevant there] I was going to post this data yesterday, but I had severe inet issues. So, I tried this out with lvm2 on 2.4.21 on a 2xp2-450 with 2 disks. (I just looked at your 14 and 52 disk data. drool.) So I have a db which is about 3.2GB on disk. All backups were done to an nfs mount, but I ran a network monitor to check bandwidth usage. I note where things were io bound. backing up: pg_dump: 18m [cpu bound] pg_dump | gzip -1: 18m [cpu bound] snapshot, then tar: 4m [io bound] snapshot, then tar | gzip: 21m [cpu bound] The times for a compressed backup are a bit slower for snapshots, but this is where the snapshot method wins tacos - restore. restore: psql: 158m snapshot: 8m Yes folks, 8m. When I started PG back up it checked the WAL and got itself back online. The benefits of the pg_dump backup afaict are that the data is in a format readable to anything and is [mostly] cross-pg compatible. The downside is it seems to be quite slow and restoring it can be long and tiresome. The benefits of the snapshot are that backups are very, very quick and restore is very, very quick (It won't need to re-enable foriegn keys, no need to rebuild indexes, no need to re-vacuum analyze). The downside is this method will only work on that specific version of PG and it isn't the "cleanest" thing in the world since you are essentially simulating a power failure to PG. Luckly the WAL works like a champ. Also, these backups can be much larger since it has to include the indexes as well. but this is a price you have to pay. I did have some initial problems with snapshots & corruption but it turned out to be user-error on my part. COOL HUH? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-admin-owner@postgresql.org Fri Oct 17 16:52:36 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C58EFD1B53B; Thu, 16 Oct 2003 16:50: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 40734-07; Thu, 16 Oct 2003 13:50:07 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 99C38D1B532; Thu, 16 Oct 2003 13:50:06 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3776261; Thu, 16 Oct 2003 09:50:38 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jeff , "markw@osdl.org" Subject: Re: [PERFORM] backup/restore - another area. Date: Thu, 16 Oct 2003 09:49:59 -0700 User-Agent: KMail/1.4.3 Cc: "pgsql-performance@postgresql.org" , "linux-lvm@sistina.com" , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310160949.59442.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/206 X-Sequence-Number: 10767 Jeff, > The downside is > this method will only work on that specific version of PG and it isn't the > "cleanest" thing in the world since you are essentially simulating a power > failure to PG. Luckly the WAL works like a champ. Also, these backups can > be much larger since it has to include the indexes as well. but this is a > price you have to pay. The other downside is, of course, that the database needs to be shut down. > COOL HUH? Certainly very useful in the DBA's arsenal of backup tools. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Thu Oct 16 14:04:15 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 193AED1B545 for ; Thu, 16 Oct 2003 17:04: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 46275-01 for ; Thu, 16 Oct 2003 14:03:42 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 26009D1B532 for ; Thu, 16 Oct 2003 14:03:39 -0300 (ADT) Received: (qmail 30187 invoked from network); 16 Oct 2003 17:08:40 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 16 Oct 2003 17:08:40 -0000 Date: Thu, 16 Oct 2003 13:06:37 -0400 From: Jeff To: Josh Berkus Cc: markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. Message-Id: <20031016130637.535f633f.threshar@torgo.978.org> In-Reply-To: <200310160949.59442.josh@agliodbs.com> References: <200310160949.59442.josh@agliodbs.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: 200310/184 X-Sequence-Number: 10745 On Thu, 16 Oct 2003 09:49:59 -0700 Josh Berkus wrote: > Jeff, > > > The downside is > > this method will only work on that specific version of PG and it > > isn't the"cleanest" thing in the world since you are essentially > > simulating a power failure to PG. Luckly the WAL works like a champ. > > Also, these backups can be much larger since it has to include the > > indexes as well. but this is a price you have to pay. > > The other downside is, of course, that the database needs to be shut > down. > I left the DB up while doing this. Even had a program sitting around committing data to try and corrupt things. (Which is how I discovered I was doing the snapshot wrong) You could do pg_ctl stop; snapshot; pg_ctls tart for a "clean" image. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-admin-owner@postgresql.org Fri Oct 17 16:52:49 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0F825D1B515; Thu, 16 Oct 2003 17:10: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 42760-05; Thu, 16 Oct 2003 14:09:31 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D4359D1B54E; Thu, 16 Oct 2003 14:09:28 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3776362; Thu, 16 Oct 2003 10:10:06 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jeff Subject: Re: [PERFORM] backup/restore - another area. Date: Thu, 16 Oct 2003 10:09:27 -0700 User-Agent: KMail/1.4.3 Cc: markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org References: <200310160949.59442.josh@agliodbs.com> <20031016130637.535f633f.threshar@torgo.978.org> In-Reply-To: <20031016130637.535f633f.threshar@torgo.978.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310161009.27379.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/211 X-Sequence-Number: 10772 Jeff, > I left the DB up while doing this. > > Even had a program sitting around committing data to try and corrupt > things. (Which is how I discovered I was doing the snapshot wrong) Really? I'm unclear on the method you're using to take the snapshot, then; I seem to have missed a couple posts on this thread. Want to refresh me? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Thu Oct 16 14:35:00 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 22066D1B532 for ; Thu, 16 Oct 2003 17:35: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 49238-07 for ; Thu, 16 Oct 2003 14:34:29 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 9A402D1B548 for ; Thu, 16 Oct 2003 14:34:27 -0300 (ADT) Received: (qmail 30516 invoked from network); 16 Oct 2003 17:39:29 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 16 Oct 2003 17:39:29 -0000 Date: Thu, 16 Oct 2003 13:37:27 -0400 From: Jeff To: Josh Berkus Cc: markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. Message-Id: <20031016133727.469620f0.threshar@torgo.978.org> In-Reply-To: <200310161009.27379.josh@agliodbs.com> References: <200310160949.59442.josh@agliodbs.com> <20031016130637.535f633f.threshar@torgo.978.org> <200310161009.27379.josh@agliodbs.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: 200310/187 X-Sequence-Number: 10748 On Thu, 16 Oct 2003 10:09:27 -0700 Josh Berkus wrote: > Jeff, > > > I left the DB up while doing this. > > > > Even had a program sitting around committing data to try and corrupt > > things. (Which is how I discovered I was doing the snapshot wrong) > > Really? I'm unclear on the method you're using to take the snapshot, > then; I seem to have missed a couple posts on this thread. Want to > refresh me? > I have a 2 disk stripe LVM on /dev/postgres/pgdata/ lvcreate -L4000M -s -n pg_backup /dev/postgres/pgdata mount /dev/postgres/pg_backup /pg_backup tar cf - /pg_backup | gzip -1 > /squeegit/mb.backup umount /pg_backup; lvremove -f /dev/postgres/pg_backup; In a nutshell an LVM snapshot is an atomic operation that takes, well, a snapshot of hte FS as it was at that instant. It does not make a 2nd copy of the data. This way you can simply tar up the pgdata directory and be happy as the snapshot will not be changing due to db activity. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Thu Oct 16 18: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 F027BD1B51B for ; Thu, 16 Oct 2003 21: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 93453-03 for ; Thu, 16 Oct 2003 18:38:47 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 9CC3FD1B4F2 for ; Thu, 16 Oct 2003 18:38:41 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h9GKavqd024287; Thu, 16 Oct 2003 16:36:57 -0400 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 h9GLcVZ32092; Thu, 16 Oct 2003 17:38:31 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TD8AX8VP; Thu, 16 Oct 2003 17:38:28 -0400 Subject: Re: free space map usage From: Robert Treat To: jeremy.guthrie@berbee.com Cc: Tom Lane , "pgsql-performance@postgresql.org" In-Reply-To: <200310141447.05788.jeremy.guthrie@berbee.com> References: <200310141154.17227.jeremy.guthrie@berbee.com> <11798.1066158968@sss.pgh.pa.us> <200310141447.05788.jeremy.guthrie@berbee.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 16 Oct 2003 17:38:31 -0400 Message-Id: <1066340311.2070.1608.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/477 X-Sequence-Number: 4225 On Tue, 2003-10-14 at 15:43, Jeremy M. Guthrie wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tuesday 14 October 2003 02:16 pm, Tom Lane wrote: > > "Jeremy M. Guthrie" writes: > > > Is there any way to determine how much of the free space map is currently > > > i= n=20 > > > use?(ie. where and what it is tracking?) I vacuum on a regular basis but > > > I= =20 > > > never hold in terms of disk space usage. > > > > Not in 7.3 AFAIR. In 7.4 a full-database VACUUM VERBOSE will end with > > the info you want: > > > > regression=# vacuum verbose; > > ... much cruft ... > > INFO: free space map: 11 relations, 144 pages stored; 272 total pages > > needed DETAIL: Allocated FSM size: 1000 relations + 20000 pages = 178 kB > > shared memory. VACUUM > > regression=# > > > > This tells me I'm only using about 1% of the FSM space (272 out of 20000 > > page slots). > > > > > I jacked up the free space map=20 > > > pages but this doesn't appear to be working. > > > > You know you have to restart the postmaster to make those changes take > > effect, right? > Yup. I still see no effect after restart. > Given that you knew of no way to determine how much free space map you were using, what is your criteria for it to "appear to be working"? If it's that space keeps growing, then your probably not vacuuming frequently enough. Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-admin-owner@postgresql.org Thu Oct 16 19:36:33 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BF753D1B532 for ; Thu, 16 Oct 2003 22:36: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 02901-03 for ; Thu, 16 Oct 2003 19:36:03 -0300 (ADT) Received: from gsy_sbs_1.cisx.com (unknown [213.133.202.58]) by svr1.postgresql.org (Postfix) with ESMTP id 6A7DAD1B553 for ; Thu, 16 Oct 2003 19:35:59 -0300 (ADT) Received: from DEMOLITION ([192.168.100.22]) by gsy_sbs_1.cisx.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id 44HZCJLQ; Thu, 16 Oct 2003 23:25:44 +0100 Message-ID: <001001c39435$dbd82920$1664a8c0@DEMOLITION> From: "Donald Fraser" To: "[ADMIN]" References: <200310160949.59442.josh@agliodbs.com> <20031016130637.535f633f.threshar@torgo.978.org> Subject: Re: [PERFORM] backup/restore - another area. Date: Thu, 16 Oct 2003 23:35:48 +0100 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 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/192 X-Sequence-Number: 10753 > > Jeff, > > > > > The downside is > > > this method will only work on that specific version of PG and it > > > isn't the"cleanest" thing in the world since you are essentially > > > simulating a power failure to PG. Luckly the WAL works like a champ. > > > Also, these backups can be much larger since it has to include the > > > indexes as well. but this is a price you have to pay. > > > > The other downside is, of course, that the database needs to be shut > > down. > > > > I left the DB up while doing this. > > Even had a program sitting around committing data to try and corrupt > things. (Which is how I discovered I was doing the snapshot wrong) > > You could do pg_ctl stop; snapshot; pg_ctls tart for a "clean" image. > Since this seems to work for you, would you be kind enough to post the shell script for doing the snapshot with LVM. Regards Donald Fraser From pgsql-admin-owner@postgresql.org Fri Oct 17 08:43:39 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B0CEDD1B4EF for ; Fri, 17 Oct 2003 11:43: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 25357-05 for ; Fri, 17 Oct 2003 08:43:06 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 3156FD1B547 for ; Fri, 17 Oct 2003 08:42:57 -0300 (ADT) Received: (qmail 10177 invoked from network); 17 Oct 2003 11:48:07 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 17 Oct 2003 11:48:07 -0000 Date: Fri, 17 Oct 2003 07:45:53 -0400 From: Jeff To: "Donald Fraser" Cc: pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. Message-Id: <20031017074553.655fa2c9.threshar@torgo.978.org> In-Reply-To: <001001c39435$dbd82920$1664a8c0@DEMOLITION> References: <200310160949.59442.josh@agliodbs.com> <20031016130637.535f633f.threshar@torgo.978.org> <001001c39435$dbd82920$1664a8c0@DEMOLITION> 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: 200310/200 X-Sequence-Number: 10761 On Thu, 16 Oct 2003 23:35:48 +0100 "Donald Fraser" wrote: > > Since this seems to work for you, > would you be kind enough to post the shell script for doing the > snapshot with LVM. > Ahh, I posted it to -perform. Guess it didn't make it here. I have a 2 disk striped LVM as /dev/postgresql/pgdata Here's what I do: lvcreate -L4000M -s -n pg_backup /dev/postgres/pgdata mount /dev/postgres/pg_backup /pg_backup tar cf - /pg_backup | gzip -1 > /squeegit/mb.backup umount /pg_backup; lvremove -f/dev/postgres/pg_backup; The key is that -L that tells it how big to make htings. If your -L is smaller than the actual size of the volume you'll get corruption (as I found out). The restore is to simply take pg down, rm $PGDATA and untar mb.backup into $PGDATA, start up PG and thats it. Godo luck - be sure to test it out first! -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-admin-owner@postgresql.org Fri Oct 17 11:46:34 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 17E57D1B4E3; Fri, 17 Oct 2003 14:46: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 55246-10; Fri, 17 Oct 2003 11:45:58 -0300 (ADT) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by svr1.postgresql.org (Postfix) with ESMTP id 083C0D1B53D; Fri, 17 Oct 2003 11:45:46 -0300 (ADT) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <47P8D02P>; Fri, 17 Oct 2003 10:45:42 -0400 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC09243E@THOR.goeci.com> From: Murthy Kambhampaty To: 'Jeff' , Josh Berkus Cc: markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. Date: Fri, 17 Oct 2003 10:45:37 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C394BD.540875DA" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/201 X-Sequence-Number: 10762 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C394BD.540875DA Content-Type: text/plain; charset="iso-8859-1" There's been a lot of discussion on the ADMIN list about postgresql backups from LVM snapshots: http://marc.theaimsgroup.com/?l=postgresql-admin&w=2&r=1&s=LVM+snapshot&q=b Note that the existence of the snapshot slows the original filesystem down, so you want to minimize the duration for which the snapshot exists. A two phase rsync -- first off the "live" filesystem, second off the snapshot -- to a backup filesystem accomplishes this. If you don't have the capacity to duplicate your $PGDATA folder, you'll want to consider doing incremental backups with xfsdump. Since xfs and xfsdump has been around forever, so you can bet your data on them; of course, xfsdump requires that pgdata be hosted on an xfs volume (XFS is a fast filesystem with metadata journaling, giving fast crash recovery, so this is a good idea anyway). For other filesystems, incremental backup and restores are being developed in star: http://freshmeat.net/projects/star/. star also claims to be faster than gnu tar, so you might use it even if you aren't doing incremental backups. The latest version of my backup script is attached. It demonstrates the implementation of filesystem level backup of the postgresql data cluster (the $PGDATA folder) using two-phase rsync. The $PGDATA folder is on an xfs formatted LVM volume; various checks are done before and after backup, and errors are e-mailed to a specified account. The script handles situations where (i) the XFS filesystem containing $PGDATA has an external log and (ii) the postmaster log ($PGDATA/pg_xlog) is written to a filesystem different than the one containing the $PGDATA folder. These configurations enhance database performance, though an external XFS log is not a big win for postgresql, which creates relatively few new files and deletes relatively few files (relative to an e-mail server). It should be possible, using this script, to keep backup times below 10 minutes even for very high loads - just increase the frequency at which you do backups (it has been tested to run hourly, and runs every three hours on the production server). Cheers, Murthy (Note: I have experienced filesystem hangs within 2 days to a week, from running this script frequently with XFS versions including XFS 1.3. The XFS CVS kernel from Sep 30th 2003 seems not to have this problem - I have been running this script hourly for two weeks without problems. So you might either use a CVS kernel or wait for an XFS release based on linux 2.4.22 or later; and you will be testing your own setup, right?!) >-----Original Message----- >From: Jeff [mailto:threshar@torgo.978.org] >Sent: Thursday, October 16, 2003 13:37 >To: Josh Berkus >Cc: markw@osdl.org; pgsql-performance@postgresql.org; >linux-lvm@sistina.com; pgsql-admin@postgresql.org >Subject: Re: [ADMIN] [PERFORM] backup/restore - another area. > > >On Thu, 16 Oct 2003 10:09:27 -0700 >Josh Berkus wrote: > >> Jeff, >> >> > I left the DB up while doing this. >> > >> > Even had a program sitting around committing data to try >and corrupt >> > things. (Which is how I discovered I was doing the snapshot wrong) >> >> Really? I'm unclear on the method you're using to take the >snapshot, >> then; I seem to have missed a couple posts on this thread. Want to >> refresh me? >> > >I have a 2 disk stripe LVM on /dev/postgres/pgdata/ > >lvcreate -L4000M -s -n pg_backup /dev/postgres/pgdata >mount /dev/postgres/pg_backup /pg_backup >tar cf - /pg_backup | gzip -1 > /squeegit/mb.backup >umount /pg_backup; >lvremove -f /dev/postgres/pg_backup; > >In a nutshell an LVM snapshot is an atomic operation that >takes, well, a >snapshot of hte FS as it was at that instant. It does not make a 2nd >copy of the data. This way you can simply tar up the pgdata directory >and be happy as the snapshot will not be changing due to db activity. > >-- >Jeff Trout >http://www.jefftrout.com/ >http://www.stuarthamm.net/ > >---------------------------(end of >broadcast)--------------------------- >TIP 9: the planner will ignore your desire to choose an index >scan if your > joining column's datatypes do not match > ------_=_NextPart_000_01C394BD.540875DA Content-Type: application/octet-stream; name="pgSnapBack3.generic" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="pgSnapBack3.generic" #!/bin/bash # FN: pgSnapBack3.generic # AB: creates and mounts snapshot of $PGDATA; # rsyncs to backup host; # unmounts and removes snapshot; # reinitializes database on backup server # DT: 2003-03-05 # AU: S. Murthy Kambhampaty PATH=3D/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # What is this script called and where is it running: ThisCMD=3D$(echo -e "$(basename $0)" | awk 'BEGIN{FS=3D"."}{print $1}') pgHost=3D$(echo -e "$(hostname)" | awk 'BEGIN{FS=3D"."}{print $1}') ThisSession=3D$$ # The postgresql superuser # (if you want to mail error logs somewhere else, either # set your mail server to forward pgSuper's mail, or add a pgMonitor # and change the two sendmail command lines below: pgSuper=3Dpostgres BackupHost=3Dbkhost DataFS=3D/home/db pgData=3D/home/db/pgsql/pgdata RsyncDM=3D"mirrors_$pgHost" # What is the rsync module for this backup call= ed # # As long as you have installed postgresql in # "/usr/bin/pgsql-M.m/, where M.m=3D$(echo -n $(cat $PGDATA/PG_VERSION)), # on both the production server and the backup server, # you shouldn;t have to edit beyond this point # # If $pgData is a symlink, redefine pgData [[ -L "$pgData" ]] && pgData=3D$(ls -l "$pgData" | awk '{FS=3D" "}{print $N= F}') pgMinor=3D$(echo -n "$(cat "$pgData/PG_VERSION")") # A function to execute commands on the backup server: # Requires passwordless logins to $pgSuper@$BackupHost using SSH # See, for example, # http://www.onlamp.com/pub/a/bsd/2002/11/14/FreeBSD_Basics.html RMTExec () { ssh -i "/home/$pgSuper/.ssh/id_rsa" $pgSuper@$BackupHost "$1" } # A function to do the rsync # /etc/rsync.d on the backup server must be configured # A module named mirrors_$pgHost must point to a directory # on the backup server. Within that folder a subdirectory # named pgdata must exist, and will contain the backup # copy of the database RsyncLockFile=3D"/home/$pgSuper/$ThisCMD.lock" # rsync options: # The -B option to increase block size on large files: # 1. Reduces the chance of changes being missed # 2. Uses more bandwidth # If you are really paranoid about missing changes, or if most # tables have very little common data from backup to backup, add the # -W option to rsync whole files, rather than changes only. # NOTE: give the -n option to rsync until sure that it # is configured properly. rsync is not forgiviging. RsyncCMD () { rsync -avW --stats \ --delete --force --exclude=3D'postmaster.pid' \ $1/ \ $BackupHost::$RsyncDM/pgdata/$2 # If you don't give a second arguement, $2 is null; # so it is optional } # When the postmaster is started on the backup server, # the data directory is: pgDataBK=3D"$(RMTExec "cat /etc/rsyncd.conf" | sed -n /$RsyncDM/,/^$/p | gr= ep path | awk 'BEGIN{FS=3D" =3D "}{print $2}')""/pgdata" # A function to print a formatted timestamp in the log DateCMD () { # Two trailing spaces are intentional echo -n "$(date +%Y-%m-%d) $(date +%X) " return 0 } # A function to call when exiting this script with errors ExitOnError () { # This function takes two arguments an "exit code" and and "error message" # in order rm -f "$RsyncLockFile" RMTExec "rm -f ~/RsyncLockFile" lvremove -f "$DataVG/$SnapNM" lvremove -f "$DataVG/$xlSnapNM" # &> /dev/null find /mnt/ -maxdepth 1 -type d -name "*snap_$ThisSession" -exec rm -rf {} = \; echo $'\n\n'"$(DateCMD) $2"$'\n\t'\ "Notified superuser"\ | tee -a "$STASFile" >&2 exec >&6 6>&- exec 2>&7 7>&- cat <(echo "Subject: ATTN: $2"\ $'\n'"X-Priority: 2 (high)"\ $'\n'"!"\ $'\n\t'"Review $(echo -n "$LogFile"), the command log"\ $'\n\t\t'"Error report listed below:" $'\n')\ "$LogFile.err"\ | sendmail "$pgSuper" exit $1 return $1 # Superfluous: this function does not return } # A function for LVM snapshot creation and mounting # There must exist a directory named /mnt/$SnapNM # to which the snapshot is mounted DataLV=3D"$(mount | grep "/home/db\>[^/]" | awk '{print $1}')" DataVG=3D"$(dirname "$DataLV")" # Please keep the xlogLV and DataLV in the = same VG SnapNM=3D"snap_$ThisSession" xlogLV=3D"$(mount | grep "$pgData/pg_xlog\>[^/]" | awk 'BEGIN{FS=3D" "}{pri= nt $1}')" [[ -n "$xlogLV" ]] && { xlSnapMB=3D512; xlSnapNM=3D"xlsnap_$ThisSession"; } DoSnap () { AvailMB=3D"$(echo -n $(vgdisplay --colon "$DataVG") | awk 'BEGIN{FS=3D":"}= {print $16 *$13/2048}')" # 2048 512-byte blocks per MB if [[ -n "$(lvscan | grep Snapshot | grep "$DataLV$")" || \ -n "$(lvscan | grep Snapshot | grep "$xlogLV$")" ]]; then echo $'\n\t'"FATAL: Snapshot of $DataLV or $xlogLV already exists." >&2 lvscan | grep Snapshot echo $'\n\t'"Terminating ..." >&2 SnapTest=3D32 # lvcreate error: "32 snapshot already exists"; sort of ... elif ((-xlSnapMB +AvailMB <=3D0)); then # Variables need not be preceeded = by '$' in arithmetic expansion; # the above syntax does not work if you test ((-$xlSnapMB +$AvailMB)), s= o you'll # have to put up with the confusion over referencing variables without t= he preceding # $-sign sometimes echo $'\n\t'"FATAL: No space left in $DataVG for snapshot creation. Termi= nating ..." >&2 SnapTest=3D19 # lvcreate error: "19 not enoungh space available to create= logical volume" else # Use all the free space available in $DataVG for the snapshot! [[ -n "$xlogLV" ]] && xfs_freeze -f "$pgData/pg_xlog" xfs_freeze -f "$DataFS" [[ -n "$xlogLV" ]] && { lvcreate -s -L "$xlSnapMB"M -n "$xlSnapNM" "$xlog= LV"; xlSnapTest=3D$?; } lvcreate -s -L "$((-xlSnapMB +AvailMB))"M -n "$SnapNM" "$DataLV" SnapTest=3D$? xfs_freeze -u "$DataFS" [[ -n "$xlogLV" ]] && xfs_freeze -u "$pgData/pg_xlog" fi # If snapshot creation failed bail; else mount the snapshot volume if ((+$xlSnapTest +$SnapTest >0)); then ExitOnError 991$SnapTextXL$SnapTest "pgBackup: Snapshot creation failed" else echo $'\n'"$(DateCMD) Successfully created snapshot(s):" lvscan | grep "snap_$ThisSession" # Report snapshot volumes list # If /mnt/ subfolders named "*snap_$ThisSession" exist, # delete them for SDir in $(find /mnt/ -maxdepth 1 -type d -name "*snap_$ThisSession");= do rm -rf $Sdir done mkdir "/mnt/$SnapNM" if [[ -n "$xlogLV" ]]; then mkdir "/mnt/$xlSnapNM" mount -t xfs "$DataVG/$xlSnapNM" "/mnt/$xlSnapNM" -o nouuid,ro xlMountTest=3D$? fi LogDev=3D"$(cat "/etc/mtab" | grep "$DataFS\>[^/]" | awk 'BEGIN{FS=3D"log= dev=3D"}{print $2}' | awk 'BEGIN{FS=3D","}{print $1}')" if [[ -n "$LogDev" ]]; then mount -t xfs "$DataVG/$SnapNM" "/mnt/$SnapNM" -o nouuid,ro,logdev=3D"$L= ogDev" MountTest=3D$? else mount -t xfs "$DataVG/$SnapNM" "/mnt/$SnapNM" -o nouuid,ro MountTest=3D$? fi fi # If snapshot mount failed, then bail; # else print mount report and return if ((+xlMountTest +MountTest >0)); then if [[ -n "$xlogLV" ]]; then umount "$DataVG/$xlSnapNM" &> /dev/null lvremove -f "$DataVG/$xlSnapNM" fi umount "$DataVG/$SnapNM" &> /dev/null lvremove -f "$DataVG/$SnapNM" ExitOnError 992 "pgBackup; Snapshot mount failed" else echo $'\n'"$(DateCMD) Successfully mounted snapshot(s):" mount | grep "snap_$ThisSession" # Report the mounts fi return 0 # Only returns on success } # Setup logging, and get going: STASFile=3D"$pgData/pgSnapBack.status" LogFile=3D"/home/$pgSuper/$ThisCMD-$(date +%Y%m%d-%H%M)" exec 6>&1; exec > "$LogFile" exec 7>&2; exec 2> "$LogFile.err" echo "$(DateCMD) Backup initiated"\ | tee "$STASFile" # Phase 1 rsync # If the previous backup is still running, wait a bit: while [[ -f "$RsyncLockFile" ]]; do echo "$(DateCMD) previous Rsync still running"$'\n'\ "Waiting for completion" >&2 sleep 300 done # and now that it's not, proceed echo $'\n\n'\ "$(DateCMD) Phase 1 - rsync from pgdata to mirror on $BackupHost"\ | tee -a "$STASFile" # Before you start the backup, make sure that no postmaster is running on t= he backup folder: # (test cribbed from the pg_ctl script) while [[ -n $(RMTExec "sed -n 1p $pgDataBK/postmaster.pid 2>/dev/null") ]];= do echo "$(DateCMD) A postmaster is running at the remote \ location; waiting 5 minutes ..." sleep 300 done # You don't want to start simultaneous rsyncs, and you don't want to # start the postmaster on the "reflection" while an rsync is running; # so put down some lock files # (there was something on linux-xfs # about xfs' not recovering inodes allocated to empty files that # are deleted, so don't just "touch" a lockfile, put something in it). echo "$(DateCMD) Phase 1 - rsync" > "$RsyncLockFile" tail -n1 "$RsyncLockFile" | RMTExec "cat - > ~/RsyncLockFile" RsyncCMD "$pgData/" && echo $'\n'"$(DateCMD) Rsync complete"$'\n\n' # Now create and mount the snapshot volume echo $'\n\n'"$(DateCMD) Snapshot creation and mounting"\ | tee -a "$STASFile" DoSnap # Phase 2 rsync echo $'\n\n'"$(DateCMD) Phase 2 - rsync from snapshot to mirror on $BackupH= ost" echo "$(DateCMD) Phase 2 rsync" > "$RsyncLockFile" tail -n1 "$RsyncLockFile" | RMTExec "cat - > ~/RsyncLockFile" ( if [[ -n "$xlogLV" ]]; then RsyncCMD "--exclude=3Dpg_xlog/ $(echo $pgData | sed -e "s|$DataFS|/mnt/$Sn= apNM|")/" && RsyncCMD "/mnt/$xlSnapNM/" "pg_xlog/" else RsyncCMD "$(echo $pgData | sed -e "s|$DataFS|/mnt/$SnapNM|")/" fi ) && echo $'\n\t'"$(DateCMD) Phase 2 rsync complete"$'\n'\ | tee -a "$STASFile" # Now remove the snapshot rm -f "$RsyncLockFile" RMTExec "rm -f ~/RsyncLockFile" if [[ -n "$xlogLV" ]]; then umount "$DataVG/$xlSnapNM" lvremove -f "$DataVG/$xlSnapNM" fi umount "$DataVG/$SnapNM" lvremove -f "$DataVG/$SnapNM" find /mnt/ -maxdepth 1 -type d -name "*snap_$ThisSession" -exec rm -rf {} \; # "Reinitialize" the snapshot of the database on the backup server echo $'\n\n'"$(DateCMD) Start postmaster on $BackupHost, capture output, an= d shutdown" RMTExec "/usr/local/pgsql-$pgMinor/bin/postmaster -B4096 -p55432\ -D $pgDataBK 2>&1" & sleep 300 # give the postmaster time for recovery RMTExec "/usr/local/pgsql-$pgMinor/bin/pg_ctl stop -D $pgDataBK -m immediat= e" && echo $'\n\n'"$(DateCMD) Attempted to reinitialize backup; check for errors= above" # Mop up if [[ ! -s "$LogFile.err" ]]; then echo "Completed, no errors" > "$LogFile.err" rm -f "$LogFile.err" echo $'\n\n'"$(DateCMD) Backup completed."\ | tee -a "$STASFile" echo "$(DateCMD) Verify postmaster-messages, listed above, for success." exec >&6 6>&- exec 2>&7 7>&- exit 0 else ExitOnError 999 "pgBackup; Backup encountered errors" fi true # Superflous ------_=_NextPart_000_01C394BD.540875DA-- From pgsql-performance-owner@postgresql.org Fri Oct 17 12:00: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 26B7ED1B54F for ; Fri, 17 Oct 2003 15:00: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 58034-07 for ; Fri, 17 Oct 2003 12:00:04 -0300 (ADT) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id F0309D1B54C for ; Fri, 17 Oct 2003 11:59:58 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id IAB21227 for ; Fri, 17 Oct 2003 08:59:49 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16272.318.870000.93584@gargle.gargle.HOWL> Date: Fri, 17 Oct 2003 08:48:30 -0600 To: pgsql-performance@postgresql.org Subject: vacuum locking X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/478 X-Sequence-Number: 4226 It seems a simple "vacuum" (not full or analyze) slows down the database dramatically. I am running vacuum every 15 minutes, but it takes about 5 minutes to run even after a fresh import. Even with vacuuming every 15 minutes, I'm not sure vacuuming is working properly. There are a lot of updates. The slowest relation is the primary key index, which is composed of a sequence. I've appended a csv with the parsed output from vacuum. The page counts are growing way too fast imo. I believe this is caused by the updates, and index pages not getting re-used. The index values aren't changing, but other values in the table are. Any suggestions how to make vacuuming more effective and reducing the time it takes to vacuum? I'd settle for less frequent vacuuming or perhaps index rebuilding. The database can be re-imported in about an hour. Rob ---------------------------------------------------------------- Spacing every 15 minutes Pages,Tuples,Deleted 7974,1029258,1536 7979,1025951,4336 7979,1026129,52 7979,1025618,686 7979,1025520,152 7980,1025583,28 7995,1028008,6 8004,1030016,14 8010,1026149,4965 8012,1026684,6 8014,1025910,960 8020,1026812,114 8027,1027642,50 8031,1027913,362 8040,1028368,784 8046,1028454,1143 8049,1029155,6 8053,1029980,10 8065,1031506,24 8084,1029134,4804 8098,1031004,346 8103,1029412,3044 8118,1029736,1872 8141,1031643,1704 8150,1032597,286 8152,1033222,6 8159,1029436,4845 8165,1029987,712 8170,1030229,268 8176,1029568,1632 8189,1030136,1540 8218,1030915,3963 8255,1033049,4598 8297,1036583,3866 8308,1031412,8640 8315,1031987,1058 8325,1033892,6 8334,1030589,4625 8350,1031709,1040 8400,1033071,5946 8426,1031555,8368 8434,1031638,2240 8436,1031703,872 8442,1031891,612 From pgsql-performance-owner@postgresql.org Fri Oct 17 12:12: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 8ACC1D1B542 for ; Fri, 17 Oct 2003 15:12: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 59011-05 for ; Fri, 17 Oct 2003 12:12:03 -0300 (ADT) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 88608D1B532 for ; Fri, 17 Oct 2003 12:12:02 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9HFJQmx014826 for ; Fri, 17 Oct 2003 20:49:26 +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 h9HFJPPI014798; Fri, 17 Oct 2003 20:49:25 +0530 Message-ID: <3F9006BF.40906@persistent.co.in> Date: Fri, 17 Oct 2003 20:41:59 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> In-Reply-To: <16272.318.870000.93584@gargle.gargle.HOWL> 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: 200310/479 X-Sequence-Number: 4227 Rob Nagler wrote: > It seems a simple "vacuum" (not full or analyze) slows down the > database dramatically. I am running vacuum every 15 minutes, but it > takes about 5 minutes to run even after a fresh import. Even with > vacuuming every 15 minutes, I'm not sure vacuuming is working > properly. > > There are a lot of updates. The slowest relation is the primary key > index, which is composed of a sequence. I've appended a csv with the > parsed output from vacuum. The page counts are growing way too fast > imo. I believe this is caused by the updates, and index pages not > getting re-used. The index values aren't changing, but other values > in the table are. You should try 7.4 beta and pg_autovacuum which is a contrib module in CVS tip. It works with 7.3 as well. Major reason for 7.4 is, it fixes index growth in vacuum. So if your database is fit, it will stay that way with proper vacuuming. > > Any suggestions how to make vacuuming more effective and reducing the > time it takes to vacuum? I'd settle for less frequent vacuuming or > perhaps index rebuilding. The database can be re-imported in about an > hour. Make sure that you have FSM properly tuned. Bump it from defaults to suit your needs. I hope you have gone thr. this page for general purpose setting. http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html > > Rob > ---------------------------------------------------------------- > Spacing every 15 minutes > Pages,Tuples,Deleted > 7974,1029258,1536 > 7979,1025951,4336 > 7979,1026129,52 > 7979,1025618,686 Assuming those were incremental figures, largest you have is ~8000 tuples per 15 minutes and 26 pages. I think with proper FSM/shared buffers/effective cache and a pg_autovacuum with 1 min. polling interval, you could end up in lot better shape. Let us know if it works. Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 17 12:26: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 721F9D1B52D for ; Fri, 17 Oct 2003 15:26: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 66214-01 for ; Fri, 17 Oct 2003 12:25:44 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 55743D1B515 for ; Fri, 17 Oct 2003 12:25:34 -0300 (ADT) Received: (qmail 4408 invoked from network); 17 Oct 2003 15:14:19 -0000 Received: from unknown (HELO ?10.0.2.7?) (216.208.117.7) by 205.178.180.9 with SMTP; 17 Oct 2003 15:14:19 -0000 Subject: Re: vacuum locking From: Rod Taylor To: Rob Nagler Cc: Postgresql Performance In-Reply-To: <16272.318.870000.93584@gargle.gargle.HOWL> References: <16272.318.870000.93584@gargle.gargle.HOWL> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-9BVvHbj+cnPFd8w7Bps6" Message-Id: <1066403640.77910.4.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 17 Oct 2003 11:14:01 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/480 X-Sequence-Number: 4228 --=-9BVvHbj+cnPFd8w7Bps6 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > Any suggestions how to make vacuuming more effective and reducing the > time it takes to vacuum? I'd settle for less frequent vacuuming or > perhaps index rebuilding. The database can be re-imported in about an > hour. Which version and what are your FSM settings? --=-9BVvHbj+cnPFd8w7Bps6 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/kAc46DETLow6vwwRAqrdAJ99k+qsfQ8vIYaUvdNMWS1ugiAsoACfSab7 mBvqsRxJSlmnYlsRRBNlVA4= =yVVe -----END PGP SIGNATURE----- --=-9BVvHbj+cnPFd8w7Bps6-- From pgsql-performance-owner@postgresql.org Fri Oct 17 12:54: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 469AFD1B515 for ; Fri, 17 Oct 2003 15:54: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 66994-09 for ; Fri, 17 Oct 2003 12:53:58 -0300 (ADT) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 7FEFCD1B51A for ; Fri, 17 Oct 2003 12:53:48 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB21456 for ; Fri, 17 Oct 2003 09:53:47 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16272.4154.489000.227676@gargle.gargle.HOWL> Date: Fri, 17 Oct 2003 09:52:26 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <3F9006BF.40906@persistent.co.in> References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/481 X-Sequence-Number: 4229 Shridhar Daithankar writes: > You should try 7.4 beta and pg_autovacuum which is a contrib module > in CVS tip. It's on our todo list. :) How does pg_autovacuum differ from vacuumdb? I mean it seems to call the vacuum operation underneath just as vacuumdb does. I obviously didn't follow the logic as to how it gets there. :-) > Make sure that you have FSM properly tuned. Bump it from defaults to > suit your needs. I hope you have gone thr. this page for general > purpose setting. I didn't start vacuuming regularly until recently, so I didn't see this problem. > Assuming those were incremental figures, largest you have is ~8000 > tuples per 15 minutes and 26 pages. I think with proper FSM/shared > buffers/effective cache and a pg_autovacuum with 1 min. polling > interval, you could end up in lot better shape. Here are the numbers that are different. I'm using 7.3: shared_buffers = 8000 sort_mem = 8000 vacuum_mem = 64000 effective_cache_size = 40000 free says: total used free shared buffers cached Mem: 1030676 1005500 25176 0 85020 382280 -/+ buffers/cache: 538200 492476 Swap: 2096472 272820 1823652 It seems effective_cache_size is about right. vacuum_mem might be slowing down the system? But if I reduce it, won't vacuuming get slower? max_fsm_relations is probably too low (the default in my conf file says 100, probably needs to be 1000). Not sure how this affects disk usage. Here's the summary for the two active tables during a vacuum interval with high activity. The other tables don't get much activity, and are much smaller. As you see the 261 + 65 adds up to the bulk of the 5 minutes it takes to vacuum. INFO: Removed 8368 tuples in 427 pages. CPU 0.06s/0.04u sec elapsed 1.54 sec. INFO: Pages 24675: Changed 195, Empty 0; Tup 1031519: Vac 8368, Keep 254, UnUsed 1739. Total CPU 2.92s/2.58u sec elapsed 65.35 sec. INFO: Removed 232 tuples in 108 pages. CPU 0.01s/0.02u sec elapsed 0.27 sec. INFO: Pages 74836: Changed 157, Empty 0; Tup 4716475: Vac 232, Keep 11, UnUsed 641. Total CPU 10.19s/6.03u sec elapsed 261.44 sec. How would vacuuming every minute finish in time? It isn't changing much in the second table, but it's taking 261 seconds to wade through 5m rows. Assuming I vacuum every 15 minutes, it would seem like max_fsm_pages should be 1000, because that's about what was reclaimed. The default is 10000. Do I need to change this? Sorry to be so dense, but I just don't know the right values are. Thanks muchly for the advice, Rob From pgsql-admin-owner@postgresql.org Fri Oct 17 13:06:16 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BAB11D1B532 for ; Fri, 17 Oct 2003 16:06: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 65799-10 for ; Fri, 17 Oct 2003 13:05:45 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B6A6BD1B52D for ; Fri, 17 Oct 2003 13:05:44 -0300 (ADT) 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 h9HG5Puo023372; Fri, 17 Oct 2003 12:05:25 -0400 (EDT) To: Murthy Kambhampaty Cc: "'Jeff'" , Josh Berkus , markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. In-reply-to: <2D92FEBFD3BE1346A6C397223A8DD3FC09243E@THOR.goeci.com> References: <2D92FEBFD3BE1346A6C397223A8DD3FC09243E@THOR.goeci.com> Comments: In-reply-to Murthy Kambhampaty message dated "Fri, 17 Oct 2003 10:45:37 -0400" Date: Fri, 17 Oct 2003 12:05:25 -0400 Message-ID: <23371.1066406725@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/202 X-Sequence-Number: 10763 Murthy Kambhampaty writes: > ... The script handles situations > where (i) the XFS filesystem containing $PGDATA has an external log and (ii) > the postmaster log ($PGDATA/pg_xlog) is written to a filesystem different > than the one containing the $PGDATA folder. It does? How exactly can you ensure snapshot consistency between data files and XLOG if they are on different filesystems? regards, tom lane From pgsql-performance-owner@postgresql.org Fri Oct 17 13:37: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 0D149D1B53E for ; Fri, 17 Oct 2003 16:37: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 75279-09 for ; Fri, 17 Oct 2003 13:36:35 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id E99A2D1B53C for ; Fri, 17 Oct 2003 13:36:34 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3780459; Fri, 17 Oct 2003 09:37:12 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rob Nagler , pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Fri, 17 Oct 2003 09:36:25 -0700 User-Agent: KMail/1.4.3 References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> In-Reply-To: <16272.4154.489000.227676@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310170936.25997.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/483 X-Sequence-Number: 4231 Rob, > vacuum_mem might be slowing down the system? But if I reduce it, > won't vacuuming get slower? Yes, but it will have less of an impact on the system while it's running. > INFO: Removed 8368 tuples in 427 pages. > CPU 0.06s/0.04u sec elapsed 1.54 sec. > INFO: Pages 24675: Changed 195, Empty 0; Tup 1031519: Vac 8368, Keep 254, > UnUsed 1739. Total CPU 2.92s/2.58u sec elapsed 65.35 sec. > > INFO: Removed 232 tuples in 108 pages. > CPU 0.01s/0.02u sec elapsed 0.27 sec. > INFO: Pages 74836: Changed 157, Empty 0; Tup 4716475: Vac 232, Keep 11, > UnUsed 641. > Total CPU 10.19s/6.03u sec elapsed 261.44 sec. What sort of disk array do you have? That seems like a lot of time considering how little work VACUUM is doing. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Fri Oct 17 14:34:16 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8D059D1B4F4; Fri, 17 Oct 2003 17:34: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 78722-09; Fri, 17 Oct 2003 14:33:45 -0300 (ADT) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by svr1.postgresql.org (Postfix) with ESMTP id 3752BD1B531; Fri, 17 Oct 2003 14:33:44 -0300 (ADT) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id <47P8D091>; Fri, 17 Oct 2003 13:33:44 -0400 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC092440@THOR.goeci.com> From: Murthy Kambhampaty To: 'Tom Lane' , Murthy Kambhampaty Cc: 'Jeff' , Josh Berkus , markw@osdl.org, pgsql-performance@postgresql.org, linux-lvm@sistina.com, pgsql-admin@postgresql.org Subject: Re: [PERFORM] backup/restore - another area. Date: Fri, 17 Oct 2003 13:33:36 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/203 X-Sequence-Number: 10764 Friday, October 17, 2003 12:05, Tom Lane [mailto:tgl@sss.pgh.pa.us] wrote: >Murthy Kambhampaty writes: >> ... The script handles situations >> where (i) the XFS filesystem containing $PGDATA has an >external log and (ii) >> the postmaster log ($PGDATA/pg_xlog) is written to a >filesystem different >> than the one containing the $PGDATA folder. > >It does? How exactly can you ensure snapshot consistency between >data files and XLOG if they are on different filesystem Say, you're setup looks something like this: mount -t xfs /dev/VG1/LV_data /home/pgdata mount -t xfs /dev/VG1/LV_xlog /home/pgdata/pg_xlog When you want to take the filesystem backup, you do: Step 1: xfs_freeze -f /dev/VG1/LV_xlog xfs_freeze -f /dev/VG1/LV_data This should finish any checkpoints that were in progress, and not start any new ones till you unfreeze. (writes to an xfs_frozen filesystem wait for the xfs_freeze -u, but reads proceed; see text from xfs_freeze manpage in postcript below.) Step2: create snapshots of /dev/VG1/LV_xlog and /dev/VG1/LV_xlog Step 3: xfs_freeze -u /dev/VG1/LV_data xfs_freeze -u /dev/VG1/LV_xlog Unfreezing in this order should assure that checkpoints resume where they left off, then log writes commence. Step4: mount the snapshots taken in Step2 somewhere; e.g. /mnt/snap_data and /mnt/snap_xlog. Copy (or rsync or whatever) /mnt/snap_data to /mnt/pgbackup/ and /mnt/snap_xlog to /mnt/pgbackup/pg_xlog. Upon completion, /mnt/pgbackup/ looks to the postmaster like /home/pgdata would if the server had crashed at the moment that Step1 was initiated. As I understand it, during recovery (startup) the postmaster will roll the database forward to this point, "checkpoint-ing" all the transactions that made it into the log before the crash. Step5: remove the snapshots created in Step2. The key is (i) xfs_freeze allows you to "quiesce" any filesystem at any point in time and, if I'm not mistaken, the order (LIFO) in which you freeze and unfreeze the two filesystems: freeze $PGDATA/pg_xlog then $PGDATA; unfreeze $PGDATA then $PGDATA/pg_xlog. (ii) WAL recovery assures consistency after a (file)sytem crash. Presently, the test server for my backup scripts is set-up this way, and the backup works flawlessly, AFAICT. (Note that the backup script starts a postmaster on the filesystem copy each time, so you get early warning of problems. Moreover the data in the "production" and "backup" copies are tested and found to be identical. Comments? Any suggestions for additional tests? Thanks, Murthy PS: From the xfs_freeze manpage: "xfs_freeze suspends and resumes access to an XFS filesystem (see xfs(5)). xfs_freeze halts new access to the filesystem and creates a stable image on disk. xfs_freeze is intended to be used with volume managers and hardware RAID devices that support the creation of snapshots. The mount-point argument is the pathname of the directory where the filesystem is mounted. The filesystem must be mounted to be frozen (see mount(8)). The -f flag requests the specified XFS filesystem to be frozen from new modifications. When this is selected, all ongoing transactions in the filesystem are allowed to complete, new write system calls are halted, other calls which modify the filesystem are halted, and all dirty data, metadata, and log information are written to disk. Any process attempting to write to the frozen filesystem will block waiting for the filesystem to be unfrozen. Note that even after freezing, the on-disk filesystem can contain information on files that are still in the process of unlinking. These files will not be unlinked until the filesystem is unfrozen or a clean mount of the snapshot is complete. The -u option is used to un-freeze the filesystem and allow operations to continue. Any filesystem modifications that were blocked by the freeze are unblocked and allowed to complete." From pgsql-performance-owner@postgresql.org Fri Oct 17 14:44: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 08EFAD1B551 for ; Fri, 17 Oct 2003 17:44: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 88423-03 for ; Fri, 17 Oct 2003 14:44:15 -0300 (ADT) Received: from email06.aon.at (WARSL402PIP3.highway.telekom.at [195.3.96.75]) by svr1.postgresql.org (Postfix) with SMTP id BA7FDD1B545 for ; Fri, 17 Oct 2003 14:44:13 -0300 (ADT) Received: (qmail 184424 invoked from network); 17 Oct 2003 17:44:13 -0000 Received: from m150p006.dipool.highway.telekom.at (HELO cantor) ([62.46.8.166]) (envelope-sender ) by qmail6rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 17 Oct 2003 17:44:13 -0000 From: Manfred Koizar To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Fri, 17 Oct 2003 19:41:56 +0200 Message-ID: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> In-Reply-To: <16272.4154.489000.227676@gargle.gargle.HOWL> 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: 200310/484 X-Sequence-Number: 4232 On Fri, 17 Oct 2003 09:52:26 -0600, Rob Nagler wrote: >INFO: Removed 8368 tuples in 427 pages. > CPU 0.06s/0.04u sec elapsed 1.54 sec. >INFO: Pages 24675: Changed 195, Empty 0; Tup 1031519: Vac 8368, Keep 254, UnUsed 1739. > Total CPU 2.92s/2.58u sec elapsed 65.35 sec. > >INFO: Removed 232 tuples in 108 pages. > CPU 0.01s/0.02u sec elapsed 0.27 sec. >INFO: Pages 74836: Changed 157, Empty 0; Tup 4716475: Vac 232, Keep 11, UnUsed >641. > Total CPU 10.19s/6.03u sec elapsed 261.44 sec. The low UnUsed numbers indicate that FSM is working fine. >Assuming I vacuum every 15 minutes, it would seem like max_fsm_pages >should be 1000, because that's about what was reclaimed. The default >is 10000. Do I need to change this? ISTM you are VACCUMing too aggressively. You are reclaiming less than 1% and 0.005%, respectively, of tuples. I would increase FSM settings to ca. 1000 fsm_relations, 100000 fsm_pages and VACUUM *less* often, say every two hours or so. ... or configure autovacuum to VACUUM a table when it has 10% dead tuples. Servus Manfred From pgsql-performance-owner@postgresql.org Fri Oct 17 20:12: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 9CA56D1B4E6 for ; Fri, 17 Oct 2003 23:12: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 49713-01 for ; Fri, 17 Oct 2003 20:12:06 -0300 (ADT) Received: from jump.bivio.com (jump.bivio.com [216.87.82.232]) by svr1.postgresql.org (Postfix) with ESMTP id F2C33D1B4E5 for ; Fri, 17 Oct 2003 20:11:58 -0300 (ADT) Received: (from nagler@localhost) by jump.bivio.com (8.11.6/8.11.6) id h9HNBxJ06778; Fri, 17 Oct 2003 17:11:59 -0600 X-Authentication-Warning: jump.bivio.com: nagler set sender to nagler@bivio.biz using -f From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16272.30527.120343.547492@jump.bivio.com> Date: Fri, 17 Oct 2003 17:11:59 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> X-Mailer: VM 6.96 under Emacs 20.7.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/487 X-Sequence-Number: 4235 Manfred Koizar writes: > ISTM you are VACCUMing too aggressively. You are reclaiming less than > 1% and 0.005%, respectively, of tuples. I would increase FSM settings > to ca. 1000 fsm_relations, 100000 fsm_pages and VACUUM *less* often, > say every two hours or so. I did this. We'll see how it goes. > ... or configure autovacuum to VACUUM a table when it has 10% dead > tuples. This solution doesn't really fix the fact that VACUUM consumes the disk while it is running. I want to avoid the erratic performance on my web server when VACUUM is running. mfg, Rob From pgsql-performance-owner@postgresql.org Fri Oct 17 20:37: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 5633AD1B4F2 for ; Fri, 17 Oct 2003 23:37: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 49529-03 for ; Fri, 17 Oct 2003 20:37:16 -0300 (ADT) Received: from jump.bivio.com (jump.bivio.com [216.87.82.232]) by svr1.postgresql.org (Postfix) with ESMTP id 1FC19D1B4E3 for ; Fri, 17 Oct 2003 20:37:13 -0300 (ADT) Received: (from nagler@localhost) by jump.bivio.com (8.11.6/8.11.6) id h9HNbGj06790; Fri, 17 Oct 2003 17:37:16 -0600 X-Authentication-Warning: jump.bivio.com: nagler set sender to nagler@bivio.biz using -f From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16272.32044.80671.948532@jump.bivio.com> Date: Fri, 17 Oct 2003 17:37:16 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <200310170936.25997.josh@agliodbs.com> References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> X-Mailer: VM 6.96 under Emacs 20.7.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/488 X-Sequence-Number: 4236 Josh Berkus writes: > Yes, but it will have less of an impact on the system while it's running. We'll find out. I lowered it to vacuum_mem to 32000. > What sort of disk array do you have? That seems like a lot of time > considering how little work VACUUM is doing. Vendor: DELL Model: PERCRAID Mirror Rev: V1.0 Type: Direct-Access ANSI SCSI revision: 02 Two 10K disks attached. Rob From pgsql-performance-owner@postgresql.org Fri Oct 24 15:03: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 05F95D1B576 for ; Sat, 18 Oct 2003 16:43: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 07635-01 for ; Sat, 18 Oct 2003 13:43:11 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 3A4EAD1B55D for ; Sat, 18 Oct 2003 13:43:08 -0300 (ADT) 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 h9IGh7Nu097202 for ; Sat, 18 Oct 2003 16:43:07 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9IGXWHa096043 for pgsql-performance@postgresql.org; Sat, 18 Oct 2003 16:33:32 GMT From: "Stephen" X-Newsgroups: comp.databases.postgresql.performance Subject: Re: vacuum locking Date: Sat, 18 Oct 2003 12:33:41 -0400 Organization: Hub.Org Networking Services Lines: 37 Message-ID: References: <16272.318.870000.93584@gargle.gargle.HOWL><3F9006BF.40906@persistent.co.in><16272.4154.489000.227676@gargle.gargle.HOWL> <16272.30527.120343.547492@jump.bivio.com> 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-Archive-Number: 200310/627 X-Sequence-Number: 4375 I ran into the same problem with VACUUM on my Linux box. If you are running Linux, take a look at "elvtune" or read this post: http://groups.google.com/groups?q=stephen+vacuum+linux&hl=en&lr=&ie=UTF-8&se lm=gRdjb.7484%241o2.77%40nntp-post.primus.ca&rnum=3 Regards, Stephen "Rob Nagler" wrote in message news:16272.30527.120343.547492@jump.bivio.com... > Manfred Koizar writes: > > ISTM you are VACCUMing too aggressively. You are reclaiming less than > > 1% and 0.005%, respectively, of tuples. I would increase FSM settings > > to ca. 1000 fsm_relations, 100000 fsm_pages and VACUUM *less* often, > > say every two hours or so. > > I did this. We'll see how it goes. > > > ... or configure autovacuum to VACUUM a table when it has 10% dead > > tuples. > > This solution doesn't really fix the fact that VACUUM consumes the > disk while it is running. I want to avoid the erratic performance on > my web server when VACUUM is running. > > mfg, > Rob > > > ---------------------------(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 Sat Oct 18 18:53: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 E0766D1B4E3 for ; Sat, 18 Oct 2003 21:53: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 54497-06 for ; Sat, 18 Oct 2003 18:53:22 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id 401D3D1B4E6 for ; Sat, 18 Oct 2003 18:53:19 -0300 (ADT) Received: from [192.168.10.52] ([192.168.10.52]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9ILtqr19511 for ; Sat, 18 Oct 2003 16:55:52 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: Date: Sat, 18 Oct 2003 16:55:14 -0500 To: pgsql-performance@postgresql.org From: Seum-Lim Gan Subject: index file bloating still in 7.4 ? Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/489 X-Sequence-Number: 4237 Hi, I downloaded PostgreSQL 7.4beta4 and tried it out. It turns out that the index file is still bloating even after running vacuum or vacuum analyze on the table. Still, only reindex will claim the space back. Is the index bloating issue still not resolved in 7.4beta4 ? Thanks. Gan -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Oct 18 19:01: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 BB344D1B4EF for ; Sat, 18 Oct 2003 22:01: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 54613-05 for ; Sat, 18 Oct 2003 19:00:44 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id A3A2AD1B542 for ; Sat, 18 Oct 2003 19:00:41 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3787492; Sat, 18 Oct 2003 15:01:06 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Seum-Lim Gan , pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? Date: Sat, 18 Oct 2003 14:58:15 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310181458.15575.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/490 X-Sequence-Number: 4238 Gan, > Is the index bloating issue still not resolved in 7.4beta4 ? No, it should be. Please post your max_fsm_pages setting, and the output o= f a=20 sample VACUUM VERBOSE ANALYZE. You probably don't have your FSM set right. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Oct 18 22:51: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 EA88FD1B4E6 for ; Sun, 19 Oct 2003 01:51: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 91261-03 for ; Sat, 18 Oct 2003 22:50:51 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id C9CF9D1B4E1 for ; Sat, 18 Oct 2003 22:50:46 -0300 (ADT) Received: from [192.168.10.52] ([192.168.10.52]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9J1rAr20105; Sat, 18 Oct 2003 20:53:11 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: In-Reply-To: <200310181458.15575.josh@agliodbs.com> References: <200310181458.15575.josh@agliodbs.com> Date: Sat, 18 Oct 2003 20:52:32 -0500 To: josh@agliodbs.com, pgsql-performance@postgresql.org From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/491 X-Sequence-Number: 4239 Hi Josh, Sample verbose analyze: VACUUM VERBOSE ANALYZE hello_rda_or_key; INFO: vacuuming "craft.hello_rda_or_key" INFO: index "hello242_1105" now contains 740813 row versions in 2477 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.42s/0.13u sec elapsed 4.76 sec. INFO: "hello_rda_or_key": found 0 removable, 740813 nonremovable row versions in 12778 pages DETAIL: 440813 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.78s/0.66u sec elapsed 6.41 sec. INFO: analyzing "craft.hello_rda_or_key" INFO: "hello_rda_or_key": 12778 pages, 3000 rows sampled, 39388 estimated total rows VACUUM Here is my postgresql.conf file: # ----------------------------- # PostgreSQL configuration file # ----------------------------- # # This file consists of lines of the form: # # name = value # # (The '=' is optional.) White space may be used. Comments are introduced # with '#' anywhere on a line. The complete list of option names and # allowed values can be found in the PostgreSQL documentation. The # commented-out settings shown in this file represent the default values. # # Any option can also be given as a command line switch to the # postmaster, e.g. 'postmaster -c log_connections=on'. Some options # can be changed at run-time with the 'SET' SQL command. # # This file is read on postmaster startup and when the postmaster # receives a SIGHUP. If you edit the file on a running system, you have # to SIGHUP the postmaster for the changes to take effect, or use # "pg_ctl reload". #--------------------------------------------------------------------------- # CONNECTIONS AND AUTHENTICATION #--------------------------------------------------------------------------- # - Connection Settings - #tcpip_socket = false #max_connections = 100 max_connections = 600 # note: increasing max_connections costs about 500 bytes of shared # memory per connection slot, in addition to costs from shared_buffers # and max_locks_per_transaction. #superuser_reserved_connections = 2 #port = 5432 port = 5333 #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' # what interface to listen on; defaults to any #rendezvous_name = '' # defaults to the computer name # - Security & Authentication - #authentication_timeout = 60 # 1-600, in seconds #ssl = false #password_encryption = true #krb_server_keyfile = '' #db_user_namespace = false #--------------------------------------------------------------------------- # RESOURCE USAGE (except WAL) #--------------------------------------------------------------------------- # - Memory - #shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each shared_buffers = 1200 # min 16, at least max_connections*2, 8KB each #sort_mem = 1024 # min 64, size in KB sort_mem = 40960 # min 64, size in KB #vacuum_mem = 8192 # min 1024, size in KB vacuum_mem = 81920 # min 1024, size in KB # - Free Space Map - #max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each max_fsm_pages = 50000 # min max_fsm_relations*16, 6 bytes each #max_fsm_relations = 1000 # min 100, ~50 bytes each max_fsm_relations = 1000 # min 100, ~50 bytes each # - Kernel Resource Usage - #max_files_per_process = 1000 # min 25 #preload_libraries = '' #--------------------------------------------------------------------------- # WRITE AHEAD LOG #--------------------------------------------------------------------------- # - Settings - #fsync = true # turns forced synchronization on or off fsync = false # turns forced synchronization on or off #wal_sync_method = fsync # the default varies across platforms: # fsync, fdatasync, open_sync, or open_datasync #wal_buffers = 8 # min 4, 8KB each # - Checkpoints - #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 300 # range 30-3600, in seconds #checkpoint_warning = 30 # 0 is off, in seconds #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 #--------------------------------------------------------------------------- # QUERY TUNING #--------------------------------------------------------------------------- # - Planner Method Enabling - #enable_hashagg = true #enable_hashjoin = true #enable_indexscan = true #enable_mergejoin = true #enable_nestloop = true #enable_seqscan = true #enable_sort = true #enable_tidscan = true # - Planner Cost Constants - #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) # - Genetic Query Optimizer - #geqo = true #geqo_threshold = 11 #geqo_effort = 1 #geqo_generations = 0 #geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 #geqo_selection_bias = 2.0 # range 1.5-2.0 # - Other Planner Options - #default_statistics_target = 10 # range 1-1000 #from_collapse_limit = 8 #join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs #--------------------------------------------------------------------------- # ERROR REPORTING AND LOGGING #--------------------------------------------------------------------------- # - Syslog - #syslog = 0 # range 0-2; 0=stdout; 1=both; 2=syslog #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # - When to Log - #client_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error #log_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic #log_error_verbosity = default # terse, default, or verbose messages #log_min_error_statement = panic # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) #log_min_duration_statement = 0 # Log all statements whose # execution time exceeds the value, in # milliseconds. Zero disables. #silent_mode = false # DO NOT USE without Syslog! # - What to Log - #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #log_connections = false #log_duration = false #log_pid = false #log_statement = false #log_timestamp = false #log_hostname = false #log_source_port = false #--------------------------------------------------------------------------- # RUNTIME STATISTICS #--------------------------------------------------------------------------- # - Statistics Monitoring - #log_parser_stats = false #log_planner_stats = false #log_executor_stats = false #log_statement_stats = false # - Query/Index Statistics Collector - #stats_start_collector = true #stats_command_string = false #stats_block_level = false #stats_row_level = false #stats_reset_on_server_start = true #--------------------------------------------------------------------------- # CLIENT CONNECTION DEFAULTS #--------------------------------------------------------------------------- # - Statement Behavior - #search_path = '$user,public' # schema names #default_transaction_isolation = 'read committed' #default_transaction_read_only = false #statement_timeout = 0 # 0 is disabled, in milliseconds # - Locale and Formatting - #datestyle = 'iso, mdy' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false #extra_float_digits = 0 # min -15, max 2 #client_encoding = sql_ascii # actually, defaults to database encoding # These settings are initialized by initdb -- they may be changed lc_messages = 'C' # locale for system error message strings lc_monetary = 'C' # locale for monetary formatting lc_numeric = 'C' # locale for number formatting lc_time = 'C' # locale for time formatting # - Other Defaults - #explain_pretty_print = true #dynamic_library_path = '$libdir' #max_expr_depth = 10000 # min 10 #--------------------------------------------------------------------------- # LOCK MANAGEMENT #--------------------------------------------------------------------------- #deadlock_timeout = 1000 # in milliseconds #max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each #--------------------------------------------------------------------------- # VERSION/PLATFORM COMPATIBILITY #--------------------------------------------------------------------------- # - Previous Postgres Versions - #add_missing_from = true #regex_flavor = advanced # advanced, extended, or basic #sql_inheritance = true # - Other Platforms & Clients - #transform_null_equals = false At 2:58 pm -0700 2003/10/18, Josh Berkus wrote: >Gan, > >> Is the index bloating issue still not resolved in 7.4beta4 ? > >No, it should be. Please post your max_fsm_pages setting, and the output of a >sample VACUUM VERBOSE ANALYZE. You probably don't have your FSM set right. > > >-- >-Josh Berkus > Aglio Database Solutions > San Francisco > > >---------------------------(end of broadcast)--------------------------- >TIP 7: don't forget to increase your free space map settings -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sat Oct 18 23:21: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 7D142D1B4EC for ; Sun, 19 Oct 2003 02:21: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 91261-05 for ; Sat, 18 Oct 2003 23:21:22 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 0AC64D1B4E1 for ; Sat, 18 Oct 2003 23:21:18 -0300 (ADT) 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 h9J2L0uo016214; Sat, 18 Oct 2003 22:21:00 -0400 (EDT) To: Seum-Lim Gan Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <200310181458.15575.josh@agliodbs.com> Comments: In-reply-to Seum-Lim Gan message dated "Sat, 18 Oct 2003 20:52:32 -0500" Date: Sat, 18 Oct 2003 22:21:00 -0400 Message-ID: <16213.1066530060@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/492 X-Sequence-Number: 4240 Seum-Lim Gan writes: > Sample verbose analyze: > VACUUM VERBOSE ANALYZE hello_rda_or_key; > INFO: vacuuming "craft.hello_rda_or_key" > INFO: index "hello242_1105" now contains 740813 row versions in 2477 pages So what's the problem? That doesn't seem like a particularly bloated index. You didn't say what datatype the index is on, but making the most optimistic assumptions, index entries must use at least 16 bytes each. You're getting about 300 entries per page, compared to the theoretical limit of 512 ... actually more, since I'm not allowing for upper btree levels in this calculation ... which says to me that the page loading is right around the expected btree loading of 2/3. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 19 02:10: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 EA568D1B509 for ; Sun, 19 Oct 2003 05:10: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 11251-07 for ; Sun, 19 Oct 2003 02:09:47 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id BACA4D1B4E3 for ; Sun, 19 Oct 2003 02:09:45 -0300 (ADT) Received: from [192.168.10.52] ([192.168.10.52]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9J5Btr20650; Sun, 19 Oct 2003 00:12:10 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: In-Reply-To: <16213.1066530060@sss.pgh.pa.us> References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> Date: Sun, 19 Oct 2003 00:11:13 -0500 To: Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/493 X-Sequence-Number: 4241 Hi Tom, I did that when I have stopped my updates. Now, I am doing updates below is the output of vacuum. After doing the vacuum verbose analyze, it reported the following : INFO: vacuuming "craft.dsperf_rda_or_key" INFO: index "hello242_1105" now contains 1792276 row versions in 6237 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.61s/0.36u sec elapsed 17.92 sec. INFO: "hello_rda_or_key": found 0 removable, 1791736 nonremovable row versions in 30892 pages DETAIL: 1492218 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 1.95s/1.99u sec elapsed 26.95 sec. INFO: analyzing "craft.dsperf_rda_or_key" INFO: "hello_rda_or_key": 30909 pages, 3000 rows sampled, 93292 estimated total rows VACUUM Gan At 10:21 pm -0400 2003/10/18, Tom Lane wrote: >Seum-Lim Gan writes: >> Sample verbose analyze: > >> VACUUM VERBOSE ANALYZE hello_rda_or_key; >> INFO: vacuuming "craft.hello_rda_or_key" >> INFO: index "hello242_1105" now contains 740813 row versions in 2477 pages > >So what's the problem? That doesn't seem like a particularly bloated >index. You didn't say what datatype the index is on, but making the >most optimistic assumptions, index entries must use at least 16 bytes >each. You're getting about 300 entries per page, compared to the >theoretical limit of 512 ... actually more, since I'm not allowing for >upper btree levels in this calculation ... which says to me that the >page loading is right around the expected btree loading of 2/3. > > regards, tom lane -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sun Oct 19 02:49: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 180BCD1B51E for ; Sun, 19 Oct 2003 05:49: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 19401-03 for ; Sun, 19 Oct 2003 02:48:40 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 19169D1B523 for ; Sun, 19 Oct 2003 02:48:39 -0300 (ADT) 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 h9J5mTuo017173; Sun, 19 Oct 2003 01:48:29 -0400 (EDT) To: Seum-Lim Gan Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> Comments: In-reply-to Seum-Lim Gan message dated "Sun, 19 Oct 2003 00:11:13 -0500" Date: Sun, 19 Oct 2003 01:48:29 -0400 Message-ID: <17172.1066542509@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/494 X-Sequence-Number: 4242 Seum-Lim Gan writes: > INFO: vacuuming "craft.dsperf_rda_or_key" > INFO: index "hello242_1105" now contains 1792276 row versions in 6237 pages > DETAIL: 0 index pages have been deleted, 0 are currently reusable. > CPU 0.61s/0.36u sec elapsed 17.92 sec. > INFO: "hello_rda_or_key": found 0 removable, 1791736 nonremovable > row versions in 30892 pages > DETAIL: 1492218 dead row versions cannot be removed yet. You still haven't got an index-bloat problem. I am, however, starting to wonder why you have so many dead-but-unremovable rows. I think you must have some client process that's been holding an open transaction for a long time. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 19 11: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 F3481D1B509 for ; Sun, 19 Oct 2003 14: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 95638-04 for ; Sun, 19 Oct 2003 11:44:21 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id 32CBCD1B501 for ; Sun, 19 Oct 2003 11:44:16 -0300 (ADT) Received: from [192.168.10.52] ([192.168.10.52]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9JEkgr22024; Sun, 19 Oct 2003 09:46:47 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: In-Reply-To: <17172.1066542509@sss.pgh.pa.us> References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> Date: Sun, 19 Oct 2003 09:46:08 -0500 To: Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/495 X-Sequence-Number: 4243 Hi Tom, Thanks for info. I stoped the update and removed the process that's doing the update and did vacuum analyze. This time the result says the index row has been removed : vacuum verbose analyze dsperf_rda_or_key; INFO: vacuuming "scncraft.dsperf_rda_or_key" INFO: index "dsperf242_1105" now contains 300000 row versions in 12387 pages DETAIL: 3097702 index row versions were removed. 0 index pages have been deleted, 0 are currently reusable. CPU 2.86s/25.49u sec elapsed 54.16 sec. INFO: "dsperf_rda_or_key": removed 3097702 row versions in 53726 pages DETAIL: CPU 6.29s/26.05u sec elapsed 78.23 sec. INFO: "dsperf_rda_or_key": found 3097702 removable, 300000 nonremovable row versions in 58586 pages DETAIL: 0 dead row versions cannot be removed yet. There were 5 unused item pointers. 0 pages are entirely empty. CPU 10.23s/53.79u sec elapsed 135.78 sec. INFO: analyzing "scncraft.dsperf_rda_or_key" INFO: "dsperf_rda_or_key": 58586 pages, 3000 rows sampled, 176830 estimated total rows VACUUM However, when I check the disk space usage, it has not changed. Before and after the vacuum, it stayed the same : /pg 822192 21% Sun Oct 19 09:34:25 CDT 2003 table /pg/data/base/17139/34048 Size=479936512 (relfilenode for table) index /pg/data/base/17139/336727 Size=101474304 (relfilenode for index) Any idea here ? Another question, if we have a process that has different threads trying to update PostgreSQL, is this going to post a problem if we do not have the thread-safety option during configure ? Thanks. Gan At 1:48 am -0400 2003/10/19, Tom Lane wrote: >Seum-Lim Gan writes: >> INFO: vacuuming "craft.dsperf_rda_or_key" >> INFO: index "hello242_1105" now contains 1792276 row versions in 6237 pages >> DETAIL: 0 index pages have been deleted, 0 are currently reusable. >> CPU 0.61s/0.36u sec elapsed 17.92 sec. >> INFO: "hello_rda_or_key": found 0 removable, 1791736 nonremovable >> row versions in 30892 pages >> DETAIL: 1492218 dead row versions cannot be removed yet. > >You still haven't got an index-bloat problem. I am, however, starting >to wonder why you have so many dead-but-unremovable rows. I think you >must have some client process that's been holding an open transaction >for a long time. > > regards, tom lane -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sun Oct 19 12:48: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 B6725D1B51E for ; Sun, 19 Oct 2003 15:48: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 13464-03 for ; Sun, 19 Oct 2003 12:47:41 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 6ACE0D1B4E6 for ; Sun, 19 Oct 2003 12:47:40 -0300 (ADT) 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 h9JFlMuo019693; Sun, 19 Oct 2003 11:47:22 -0400 (EDT) To: Seum-Lim Gan Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> Comments: In-reply-to Seum-Lim Gan message dated "Sun, 19 Oct 2003 09:46:08 -0500" Date: Sun, 19 Oct 2003 11:47:22 -0400 Message-ID: <19692.1066578442@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/496 X-Sequence-Number: 4244 Seum-Lim Gan writes: > vacuum verbose analyze dsperf_rda_or_key; > INFO: vacuuming "scncraft.dsperf_rda_or_key" > INFO: index "dsperf242_1105" now contains 300000 row versions in 12387 pages > DETAIL: 3097702 index row versions were removed. > 0 index pages have been deleted, 0 are currently reusable. Hm, interesting that you deleted 90% of the entries and still had no empty index pages at all. What was the pattern of your deletes and/or updates with respect to this index's key? > However, when I check the disk space usage, it has not changed. It won't in any case. Plain VACUUM is designed for maintaining a steady-state level of free space in tables and indexes, not for returning major amounts of space to the OS. For that you need more-invasive operations like VACUUM FULL or REINDEX. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Oct 19 13:54: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 4C338D1B4EC for ; Sun, 19 Oct 2003 16:54: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 24143-04 for ; Sun, 19 Oct 2003 13:54:06 -0300 (ADT) Received: from slgan.com (c-67-163-28-202.client.comcast.net [67.163.28.202]) by svr1.postgresql.org (Postfix) with ESMTP id A9C64D1B4E6 for ; Sun, 19 Oct 2003 13:54:04 -0300 (ADT) Received: from [192.168.10.52] ([192.168.10.52]) by slgan.com (8.10.2/8.10.2) with ESMTP id h9JGuWr22347; Sun, 19 Oct 2003 11:56:32 -0500 Mime-Version: 1.0 X-Sender: slgan@192.168.10.10 Message-Id: In-Reply-To: <19692.1066578442@sss.pgh.pa.us> References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> <19692.1066578442@sss.pgh.pa.us> Date: Sun, 19 Oct 2003 11:55:57 -0500 To: Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/497 X-Sequence-Number: 4245 Hi Tom, The key is a range from 1 to 30000 and picked randomly. Oh, so in order to reclaim the disk space, we must run reindex or vacuum full ? This will lock out the table and we won't be able to do anything. Looks like this is a problem. It means we cannot use it for 24x7 operations without having to stop the process and do the vacuum full and reindex. Is there anything down the road that these operations will not lock out the table ? I let the process ran overnight. The last email I sent you with the vacuum analyze output just about an hour ago, that was after I removed the process that does the updates. However, I search through all the vacuum I did just before I went to bed and found that earlier vacuum did say 5 indexes deleted and 5 reusable. It has been pretty constant for about 1 to 2 hours and then down to zero and has been like this since. Sun Oct 19 00:50:07 CDT 2003 INFO: vacuuming "scncraft.dsperf_rda_or_key" INFO: index "dsperf242_1105" now contains 402335 row versions in 7111 pages DETAIL: 5 index pages have been deleted, 5 are currently reusable. CPU 1.32s/0.17u sec elapsed 22.44 sec. INFO: "dsperf_rda_or_key": found 0 removable, 401804 nonremovable row versions in 35315 pages DETAIL: 101802 dead row versions cannot be removed yet. There were 1646275 unused item pointers. 0 pages are entirely empty. CPU 2.38s/0.71u sec elapsed 27.09 sec. INFO: analyzing "scncraft.dsperf_rda_or_key" INFO: "dsperf_rda_or_key": 35315 pages, 3000 rows sampled, 156124 estimated total rows VACUUM Sleep 60 seconds Sun Oct 19 00:51:40 CDT 2003 INFO: vacuuming "scncraft.dsperf_rda_or_key" INFO: index "dsperf242_1105" now contains 411612 row versions in 7111 pages DETAIL: 5 index pages have been deleted, 5 are currently reusable. CPU 1.28s/0.22u sec elapsed 23.38 sec. INFO: "dsperf_rda_or_key": found 0 removable, 410889 nonremovable row versions in 35315 pages DETAIL: 110900 dead row versions cannot be removed yet. There were 1637190 unused item pointers. 0 pages are entirely empty. CPU 2.13s/0.92u sec elapsed 27.13 sec. INFO: analyzing "scncraft.dsperf_rda_or_key" INFO: "dsperf_rda_or_key": 35315 pages, 3000 rows sampled, 123164 estimated total rows VACUUM Sleep 60 seconds . . . Sun Oct 19 02:14:41 CDT 2003 INFO: vacuuming "scncraft.dsperf_rda_or_key" INFO: index "dsperf242_1105" now contains 1053582 row versions in 7112 pages DETAIL: 5 index pages have been deleted, 5 are currently reusable. CPU 0.58s/0.29u sec elapsed 21.63 sec. INFO: "dsperf_rda_or_key": found 0 removable, 1053103 nonremovable row versions in 35315 pages DETAIL: 753064 dead row versions cannot be removed yet. There were 995103 unused item pointers. 0 pages are entirely empty. CPU 1.54s/1.35u sec elapsed 26.17 sec. INFO: analyzing "scncraft.dsperf_rda_or_key" INFO: "dsperf_rda_or_key": 35315 pages, 3000 rows sampled, 106627 estimated total rows VACUUM Sleep 60 seconds Sun Oct 19 02:16:16 CDT 2003 INFO: vacuuming "scncraft.dsperf_rda_or_key" INFO: index "dsperf242_1105" now contains 1065887 row versions in 7119 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.71s/0.36u sec elapsed 21.12 sec. INFO: "dsperf_rda_or_key": found 0 removable, 1065357 nonremovable row versions in 35315 pages DETAIL: 765328 dead row versions cannot be removed yet. There were 982849 unused item pointers. 0 pages are entirely empty. CPU 1.70s/1.42u sec elapsed 26.65 sec. INFO: analyzing "scncraft.dsperf_rda_or_key" INFO: "dsperf_rda_or_key": 35315 pages, 3000 rows sampled, 106627 estimated total rows VACUUM Sleep 60 seconds . . . Thanks. Gan At 11:47 am -0400 2003/10/19, Tom Lane wrote: >Seum-Lim Gan writes: >> vacuum verbose analyze dsperf_rda_or_key; >> INFO: vacuuming "scncraft.dsperf_rda_or_key" >> INFO: index "dsperf242_1105" now contains 300000 row versions in >>12387 pages >> DETAIL: 3097702 index row versions were removed. > > 0 index pages have been deleted, 0 are currently reusable. > >Hm, interesting that you deleted 90% of the entries and still had no >empty index pages at all. What was the pattern of your deletes and/or >updates with respect to this index's key? > >> However, when I check the disk space usage, it has not changed. > >It won't in any case. Plain VACUUM is designed for maintaining a >steady-state level of free space in tables and indexes, not for >returning major amounts of space to the OS. For that you need >more-invasive operations like VACUUM FULL or REINDEX. > > regards, tom lane -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Sun Oct 19 16:05:20 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 70EC9D1B54C for ; Sun, 19 Oct 2003 19:05: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 44726-05 for ; Sun, 19 Oct 2003 16:04:49 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 86543D1B548 for ; Sun, 19 Oct 2003 16:04:47 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3791051; Sun, 19 Oct 2003 12:05:26 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Seum-Lim Gan , Tom Lane Subject: Re: index file bloating still in 7.4 ? Date: Sun, 19 Oct 2003 12:04:23 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <19692.1066578442@sss.pgh.pa.us> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310191204.23888.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/498 X-Sequence-Number: 4246 Gan, > Oh, so in order to reclaim the disk space, we must run > reindex or vacuum full ? > This will lock out the table and we won't be able to do anything. > Looks like this is a problem. It means we cannot use it for > 24x7 operations without having to stop the process and do the vacuum full > and reindex. Is there anything down the road that these operations > will not lock out the table ? I doubt it; the amount of page-shuffling required to reclaim 90% of the space in an index for a table that has been mostly cleared is substantial, and would prevent concurrent access. Also, you seem to have set up an impossible situation for VACUUM. If I'm reading your statistics right, you have a large number of threads accessing most of the data 100% of the time, preventing VACUUM from cleaning up the pages. This is not, in my experience, a realistic test case ... there are peak and idle periods for all databases, even webservers that have been slashdotted. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 20 04:10: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 561FBD1B509 for ; Mon, 20 Oct 2003 07:10: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 50889-09 for ; Mon, 20 Oct 2003 04:09:48 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 18EBDD1B4E1 for ; Mon, 20 Oct 2003 04:09:45 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886 for ; Mon, 20 Oct 2003 09:09:41 +0200 Message-ID: <006101c396d9$8995a060$b696a8c0@APR> From: "Alexander Priem" To: References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> Subject: PostgreSQL data on a NAS device ? Date: Mon, 20 Oct 2003 09:12:35 +0200 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.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: 200310/499 X-Sequence-Number: 4247 Hi all, Does anyone have any experience with putting PostgreSQL data on a NAS device? I am asking this because a NAS device is much cheaper to set up than a couple of SCSI disks. I would like to use a relatively cheap NAS device which uses four IDE drives (7.200 rpm), like the Dell PowerVault 725N. The disks themselves would be much slower than SCSI disks, I know, but a NAS device can be equipped with 3 Gb of memory, so this would make a very large disk cache, right? If this NAS would be dedicated only to PostgreSQL, would this be slower/faster than a SCSI RAID-10 setup of 6 disks? It would be much cheaper... Any advice on this would be appreciated :) Kind regards, Alexander Priem. From pgsql-performance-owner@postgresql.org Mon Oct 20 09:15: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 23BE2D1B4E1 for ; Mon, 20 Oct 2003 12:15: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 06927-06 for ; Mon, 20 Oct 2003 09:14:54 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 69775D1B524 for ; Mon, 20 Oct 2003 09:14:47 -0300 (ADT) Received: (qmail 3423 invoked from network); 20 Oct 2003 12:20:45 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 20 Oct 2003 12:20:45 -0000 Date: Mon, 20 Oct 2003 08:20:30 -0400 From: Jeff To: "Alexander Priem" Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL data on a NAS device ? Message-Id: <20031020082030.4b460b25.threshar@torgo.978.org> In-Reply-To: <006101c396d9$8995a060$b696a8c0@APR> References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> <006101c396d9$8995a060$b696a8c0@APR> 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: 200310/500 X-Sequence-Number: 4248 On Mon, 20 Oct 2003 09:12:35 +0200 "Alexander Priem" wrote: > I am asking this because a NAS device is much cheaper to set up than a > couple of SCSI disks. I would like to use a relatively cheap NAS > device which uses four IDE drives (7.200 rpm), like the Dell > PowerVault 725N. The disks themselves would be much slower than SCSI > disks, I know, but a NAS device can be equipped with 3 Gb of memory, > so this would make a very large disk cache, right? If this NAS would > be dedicated only to PostgreSQL, would this be slower/faster than a > SCSI RAID-10 setup of 6 disks? It would be much cheaper... > The big concern would be the network connection, unless you are going fiber. You need to use _AT LEAST_ gigabit. _at least_. If you do go that route it'd be interesting to see bonnie results. And the other thing - remember that just because you are running NAS doesn't mean you can attach another machine running postgres and have a cluster. (See archives for more info about this). I suppose it all boils down to your budget (I usually get to work with a budget of $0). And I mentioned this in another post- If you don't mind refurb disks(or slightly used) check out ebay - you can get scsi disks by the truckload for cheap. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 20 09:27: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 A16FFD1B4E1 for ; Mon, 20 Oct 2003 12:27: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 07292-07 for ; Mon, 20 Oct 2003 09:26:48 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 24C8AD1B50C for ; Mon, 20 Oct 2003 09:26:40 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Mon, 20 Oct 2003 14:26:37 +0200 Message-ID: <00d301c39705$d0898550$b696a8c0@APR> From: "Alexander Priem" To: "Jeff" Cc: References: <19692.1066578442@sss.pgh.pa.us><200310191204.23888.josh@agliodbs.com><006101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> Subject: Re: PostgreSQL data on a NAS device ? Date: Mon, 20 Oct 2003 14:29:32 +0200 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/501 X-Sequence-Number: 4249 Thanks for your reply, Jeff. If we are going to use a NAS device for storage, then it will be attached through a gigabit ethernet connection. Fiber will not be an option, since that would negate the savings we can make by using an IDE NAS device instead of SCSI-RAID, fiber's pretty expensive, right? Using a NAS device (that is used only by PostgreSQL, so it's dedicated) with 3Gb of RAM and four 7200 rpm IDE harddisks, connected using a gigabit ethernet connection to the PostgreSQL server, do you think it will be a match for a SCSI-RAID config using 4 or 6 15000rpm disks (RAID-10) through a SCSI-RAID controller having 128mb of writeback cache (battery-backed)? The SCSI-RAID config would be a lot more expensive. I can't purchase both configs and test which one wil be faster, but if the NAS solution would be (almost) as fast as the SCSI-RAID solution, it would be cheaper and easier to maintain... About clustering: I know this can't be done by hooking multiple postmasters to one and the same NAS. This would result in data corruption, i've read... Kind regards, Alexander. ----- Original Message ----- From: "Jeff" To: "Alexander Priem" Cc: Sent: Monday, October 20, 2003 2:20 PM Subject: Re: [PERFORM] PostgreSQL data on a NAS device ? > On Mon, 20 Oct 2003 09:12:35 +0200 > "Alexander Priem" wrote: > > > I am asking this because a NAS device is much cheaper to set up than a > > couple of SCSI disks. I would like to use a relatively cheap NAS > > device which uses four IDE drives (7.200 rpm), like the Dell > > PowerVault 725N. The disks themselves would be much slower than SCSI > > disks, I know, but a NAS device can be equipped with 3 Gb of memory, > > so this would make a very large disk cache, right? If this NAS would > > be dedicated only to PostgreSQL, would this be slower/faster than a > > SCSI RAID-10 setup of 6 disks? It would be much cheaper... > > > > The big concern would be the network connection, unless you are going > fiber. You need to use _AT LEAST_ gigabit. _at least_. If you do > go that route it'd be interesting to see bonnie results. And the > other thing - remember that just because you are running NAS doesn't > mean you can attach another machine running postgres and have a > cluster. (See archives for more info about this). > > I suppose it all boils down to your budget (I usually get to work with > a budget of $0). And I mentioned this in another post- If you don't mind > refurb disks(or slightly used) check out ebay - you can get scsi disks > by the truckload for cheap. > > > -- > Jeff Trout > http://www.jefftrout.com/ > http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 20 09:31: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 3C5A5D1B51A for ; Mon, 20 Oct 2003 12:31: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 13920-04 for ; Mon, 20 Oct 2003 09:30:44 -0300 (ADT) Received: from smtp.pspl.co.in (www.pspl.co.in [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 7F585D1B52C for ; Mon, 20 Oct 2003 09:30:39 -0300 (ADT) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9KCcvXT025827 for ; Mon, 20 Oct 2003 18:08:57 +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 h9KCcuPI025810 for ; Mon, 20 Oct 2003 18:08:56 +0530 Message-ID: <3F93D571.8090105@persistent.co.in> Date: Mon, 20 Oct 2003 18:00:41 +0530 From: Shridhar Daithankar Organization: Persistent Systems Pvt. Ltd. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL data on a NAS device ? References: <19692.1066578442@sss.pgh.pa.us><200310191204.23888.josh@agliodbs.com><006101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> <00d301c39705$d0898550$b696a8c0@APR> In-Reply-To: <00d301c39705$d0898550$b696a8c0@APR> 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: 200310/502 X-Sequence-Number: 4250 Alexander Priem wrote: > About clustering: I know this can't be done by hooking multiple postmasters > to one and the same NAS. This would result in data corruption, i've read... Only if they are reading same data directory. You can run 4 different data installations of postgresql, each one in its own directory and still put them on same device. Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 20 10:02: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 B6F0FD1B4E3 for ; Mon, 20 Oct 2003 13: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 17264-02 for ; Mon, 20 Oct 2003 10:01:40 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id E3511D1B538 for ; Mon, 20 Oct 2003 10:01:35 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886 for ; Mon, 20 Oct 2003 15:01:38 +0200 Message-ID: <010401c3970a$b4857c60$b696a8c0@APR> From: "Alexander Priem" To: References: <19692.1066578442@sss.pgh.pa.us><200310191204.23888.josh@agliodbs.com><006101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> <00d301c39705$d0898550$b696a8c0@APR> <3F93D571.8090105@persistent.co.in> Subject: Re: PostgreSQL data on a NAS device ? Date: Mon, 20 Oct 2003 15:04:32 +0200 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/503 X-Sequence-Number: 4251 Even better than the four-disk NAS I mentioned earlier is the following: Promise UltraTrak RM8000. This is a so-called SCSI-to-IDE RAID system. Basically it's a RAID setup of eight IDE disks, using a hardware RAID engine, that's connected to (in this case) the PostgreSQL server via a SCSI Ultra160 interface (!). So the server won't know any better than that there's a SCSI disk attached, but in reality it's a IDE RAID setup. It supports RAID levels 0, 1, 0+1, 5, 50 and JBOD and supports hot-swapping. Such a NAS config would cost around EUR 3700 (ex. VAT), using 8x40 Gb IDE disks (7200rpm). A SCSI RAID-10 setup using 6x18Gb (15000rpm) disks would cost around EUR 6000 (ex. VAT) so it's a big difference... Does anyone have experience with this NAS device or other "SCSI-to-IDE" RAID systems? Are they OK in terms of performance and reliability? Kind regards, Alexander. From pgsql-performance-owner@postgresql.org Mon Oct 20 10:09: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 887CED1B523 for ; Mon, 20 Oct 2003 13:09: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 23886-03 for ; Mon, 20 Oct 2003 10:09:12 -0300 (ADT) Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) by svr1.postgresql.org (Postfix) with ESMTP id 35231D1B516 for ; Mon, 20 Oct 2003 10:09:08 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9KD8vBE005075; Mon, 20 Oct 2003 16:08:57 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9KD8NvR005073; Mon, 20 Oct 2003 16:08:23 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: PostgreSQL data on a NAS device ? From: Hannu Krosing To: Alexander Priem Cc: Jeff , pgsql-performance@postgresql.org In-Reply-To: <00d301c39705$d0898550$b696a8c0@APR> References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com><006101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> <00d301c39705$d0898550$b696a8c0@APR> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1066655302.4888.15.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 20 Oct 2003 16:08:23 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/504 X-Sequence-Number: 4252 Alexander Priem kirjutas E, 20.10.2003 kell 15:29: > Thanks for your reply, Jeff. > > If we are going to use a NAS device for storage, then it will be attached > through a gigabit ethernet connection. Fiber will not be an option, since > that would negate the savings we can make by using an IDE NAS device instead > of SCSI-RAID, fiber's pretty expensive, right? > > Using a NAS device (that is used only by PostgreSQL, so it's dedicated) with > 3Gb of RAM and four 7200 rpm IDE harddisks, connected using a gigabit > ethernet connection to the PostgreSQL server, do you think it will be a > match for a SCSI-RAID config using 4 or 6 15000rpm disks (RAID-10) through a > SCSI-RAID controller having 128mb of writeback cache (battery-backed)? I sincerely don't know. But if NAS is something that involves TCP (like iSCSI) then you should take a look at some network card and TCP/IP stack that offloads the protocol processing to the coprocessor on network card. (or just have some extra processors free to do the protocol processing ) --------------- Hannu From pgsql-performance-owner@postgresql.org Mon Oct 20 10:20:21 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 0AFA9D1B4E3 for ; Mon, 20 Oct 2003 13: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 24938-01 for ; Mon, 20 Oct 2003 10:19:35 -0300 (ADT) Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) by svr1.postgresql.org (Postfix) with ESMTP id 9A48FD1B4FB for ; Mon, 20 Oct 2003 10:19:31 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9KDJ8BE005167; Mon, 20 Oct 2003 16:19:09 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9KDJ8Um005165; Mon, 20 Oct 2003 16:19:08 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: PostgreSQL data on a NAS device ? From: Hannu Krosing To: Alexander Priem Cc: pgsql-performance@postgresql.org In-Reply-To: <010401c3970a$b4857c60$b696a8c0@APR> References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com><006101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> <00d301c39705$d0898550$b696a8c0@APR> <3F93D571.8090105@persistent.co.in> <010401c3970a$b4857c60$b696a8c0@APR> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1066655946.4888.18.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 20 Oct 2003 16:19:07 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/505 X-Sequence-Number: 4253 Alexander Priem kirjutas E, 20.10.2003 kell 16:04: > Even better than the four-disk NAS I mentioned earlier is the following: > > Promise UltraTrak RM8000. This is a so-called SCSI-to-IDE RAID system. While you are at it, you could also check out http://www.3ware.com/ I guess one of these with 10000 rpm 36GB SATA drivest would be pretty fast and possibly cheaper than SCSI raid. -------------- Hannu From pgsql-admin-owner@postgresql.org Mon Oct 20 11:16:21 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0D746D1B509; Mon, 20 Oct 2003 14:16: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 27319-09; Mon, 20 Oct 2003 11:15:38 -0300 (ADT) Received: from host2.hostseguro.com (133-188-198-200.hostseguro.com [200.198.188.133]) by svr1.postgresql.org (Postfix) with ESMTP id 70829D1B4E3; Mon, 20 Oct 2003 11:15:33 -0300 (ADT) Received: from cpanel by host2.hostseguro.com with local (Exim 4.20) id 1ABamk-00041y-QC; Mon, 20 Oct 2003 12:13:26 -0200 Received: from 200.102.200.91 ([200.102.200.91]) by sistemica.info (IMP) with HTTP for ; Mon, 20 Oct 2003 12:13:26 -0200 Message-ID: <1066659206.3f93ed86b9907@sistemica.info> Date: Mon, 20 Oct 2003 12:13:26 -0200 From: Rhaoni Chiu Pereira To: PostgreSQL ADMIN , PostgreSQL Performance Subject: Low Insert/Update Performance MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.102.200.91 X-MailScanner-Information: Verificado pelo McAfee VirusScan / Scanned by McAfee VirusScan X-MailScanner: Nao infectado / Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2.hostseguro.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 32001] / [47 12] X-AntiAbuse: Sender Address Domain - sistemica.info X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/229 X-Sequence-Number: 10790 Hi List, I got a P4 1.7Ghz , 512MB RAM , HD 7200 RPM, on RED HAT 9 running PostgreSQL 7.3.2-3 Database. I have a Delphi aplication that updates the Oracle database using .dbf file's information ( converting the data from the old clipper aplication ) and it takes about 3min and 45 seconds to update Jan/2003 . My problem is that I must substitute this Oracle for a PostgreSQL database and this same Delphi aplication takes 45 min to update Jan/2003. All delphi routines are converted and optmized to work with PgSQL. Here follows my postgresql.conf: # # Connection Parameters # tcpip_socket = true #ssl = false max_connections = 10 #superuser_reserved_connections = 2 port = 5432 #hostname_lookup = false #show_source_port = false #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' #krb_server_keyfile = '' # # Shared Memory Size # shared_buffers = 10000 # min max_connections*2 or 16, 8KB each max_fsm_relations = 2000 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 20000 # min 1000, fsm is free space map, ~6 bytes #max_locks_per_transaction = 64 # min 10 #wal_buffers = # min 4, typically 8KB each # # Non-shared Memory Sizes # sort_mem = 8000 # min 64, size in KB vacuum_mem = 16192 # min 1024, size in KB # # Write-ahead log (WAL) # checkpoint_segments = 9 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 300 # range 30-3600, in seconds # #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 # fsync = false #wal_sync_method = fsync # the default varies across platforms: # # fsync, fdatasync, open_sync, or open_datasync #wal_debug = 0 # range 0-16 # # Optimizer Parameters # enable_seqscan = false enable_indexscan = true enable_tidscan = true enable_sort = true enable_nestloop = true enable_mergejoin = true enable_hashjoin = true effective_cache_size = 16000 # 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) default_statistics_target = 1000 # range 1-1000 # # GEQO Optimizer Parameters # #geqo = true #geqo_selection_bias = 2.0 # range 1.5-2.0 #geqo_threshold = 11 #geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 #geqo_effort = 1 #geqo_generations = 0 #geqo_random_seed = -1 # auto-compute seed # # Message display # #server_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic #client_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error #silent_mode = false #log_connections = false #log_pid = false #log_statement = false #log_duration = false log_timestamp = true #log_min_error_statement = error # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #explain_pretty_print = true # requires USE_ASSERT_CHECKING #debug_assertions = true # # Syslog # #syslog = 0 # range 0-2 #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # # Statistics # #show_parser_stats = false #show_planner_stats = false #show_executor_stats = false #show_statement_stats = false # requires BTREE_BUILD_STATS #show_btree_build_stats = false # # Access statistics collection # #stats_start_collector = true #stats_reset_on_server_start = true #stats_command_string = false #stats_row_level = false #stats_block_level = false # # Lock Tracing # #trace_notify = false # requires LOCK_DEBUG #trace_locks = false #trace_userlocks = false #trace_lwlocks = false #debug_deadlocks = false #trace_lock_oidmin = 16384 #trace_lock_table = 0 # # Misc # #autocommit = true #dynamic_library_path = '$libdir' search_path = 'vendas' #datestyle = 'iso, us' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false #client_encoding = sql_ascii # actually, defaults to database encoding #authentication_timeout = 60 # 1-600, in seconds #deadlock_timeout = 1000 # in milliseconds #default_transaction_isolation = 'read committed' #max_expr_depth = 10000 # min 10 #max_files_per_process = 1000 # min 25 #password_encryption = true #sql_inheritance = true #transform_null_equals = false #statement_timeout = 0 # 0 is disabled, in milliseconds #db_user_namespace = false # # Locale settings # # (initialized by initdb -- may be changed) LC_MESSAGES = 'en_US.UTF-8' LC_MONETARY = 'en_US.UTF-8' LC_NUMERIC = 'en_US.UTF-8' LC_TIME = 'en_US.UTF-8' Atenciosamente, Rhaoni Chiu Pereira Sist�mica Computadores Visite-nos na Web: http://sistemica.info Fone/Fax : +55 51 3328 1122 From pgsql-admin-owner@postgresql.org Mon Oct 20 11:44:41 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 75527D1B4E4 for ; Mon, 20 Oct 2003 14:44: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 36736-04 for ; Mon, 20 Oct 2003 11:44:06 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id DABBBD1B4E1 for ; Mon, 20 Oct 2003 11:44:00 -0300 (ADT) Received: (qmail 5845 invoked from network); 20 Oct 2003 14:50:03 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 20 Oct 2003 14:50:03 -0000 Date: Mon, 20 Oct 2003 10:49:46 -0400 From: Jeff To: Rhaoni Chiu Pereira Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Low Insert/Update Performance Message-Id: <20031020104946.575c5845.threshar@torgo.978.org> In-Reply-To: <1066659206.3f93ed86b9907@sistemica.info> References: <1066659206.3f93ed86b9907@sistemica.info> 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: 200310/230 X-Sequence-Number: 10791 On Mon, 20 Oct 2003 12:13:26 -0200 Rhaoni Chiu Pereira wrote: > Hi List, > > I got a P4 1.7Ghz , 512MB RAM , HD 7200 RPM, on RED HAT 9 running > PostgreSQL > 7.3.2-3 Database. [clip] Please send schema & queries or we will not be able to help you. Also, if you could provide explain analyze of each query it would be even more helpful! -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Mon Oct 20 12:30: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 2CAFBD1B523 for ; Mon, 20 Oct 2003 15:30: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 47321-06 for ; Mon, 20 Oct 2003 12:30:07 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id 6CD94D1B518 for ; Mon, 20 Oct 2003 12:30:06 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Mon, 20 Oct 2003 10:29:34 -0500 Subject: Re: PostgreSQL data on a NAS device ? From: Will LaShell To: Alexander Priem Cc: pgsql-performance@postgresql.org In-Reply-To: <010401c3970a$b4857c60$b696a8c0@APR> References: <19692.1066578442@sss.pgh.pa.us><200310191204.23888.josh@agliodbs.com><006 101c396d9$8995a060$b696a8c0@APR> <20031020082030.4b460b25.threshar@torgo.978.org> <00d301c39705$d0898550$b696a8c0@APR> <3F93D571.8090105@persistent.co.in> <010401c3970a$b4857c60$b696a8c0@APR> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-bXxLmEzwF1KgYyrKR8sJ" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 20 Oct 2003 08:29:32 -0700 Message-Id: <1066663774.26155.25.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/508 X-Sequence-Number: 4256 --=-bXxLmEzwF1KgYyrKR8sJ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hello Alexander, On Mon, 2003-10-20 at 06:04, Alexander Priem wrote: > Even better than the four-disk NAS I mentioned earlier is the following: >=20 > Promise UltraTrak RM8000. This is a so-called SCSI-to-IDE RAID system. > Basically it's a RAID setup of eight IDE disks, using a hardware RAID > engine, that's connected to (in this case) the PostgreSQL server via a SC= SI > Ultra160 interface (!). So the server won't know any better than that > there's a SCSI disk attached, but in reality it's a IDE RAID setup. It > supports RAID levels 0, 1, 0+1, 5, 50 and JBOD and supports hot-swapping. We have a Promise FasTrak 4000 in our development server connected to 120 Gig western digital 8mb cache drives. Basically the fastest drives we could get for an ide configuration. This system works well, however there are a few things you need to consider. The biggest is that you have very limited control over your devices with the Promise controllers. The bios of the raid controller doesn't have many options on it. You basically plug everything together, and just hope it works. It usually does, but there have been times in the past that really gave us a scare. And we had a situation that in a hard poweroff ( UPS died ) we suffered complete corruptions of 2 of our 4 drives.=20 Performance wise it is =3Dokay=3D but definitely not on par with either our Megaraid elite 1650 controller or a solution I'm going to suggest to you later in this mail. Your biggest hit is going to be multiple simultaneous accesses. The controller and drives just can't keep up to it. Realistically with my experiences I cannot recommend this solution for a production machine, even with the budget constraints you have put forth. >=20 > Such a NAS config would cost around EUR 3700 (ex. VAT), using 8x40 Gb IDE > disks (7200rpm). >=20 > A SCSI RAID-10 setup using 6x18Gb (15000rpm) disks would cost around EUR > 6000 (ex. VAT) so it's a big difference... I'm not sure where you have your figures, but I would like to propose the following solution for you. for your boot device use either a single ide drive and keep an exact duplicate of the drive in the event of a drive failure, or use 2 drives and use software raid to mirror the two. In this manner you can spend approx $100 USD for each drive and no additional cost for your controller as you will use the motherboards IDE controller. For your postgresql partition or even /var use software raid on an adaptec 29320-R SCSI controller. ( http://www.adaptec.com/worldwide/product/proddetail.html?sess=3Dno&language= =3DEnglish+US&prodkey=3DASC-39320-R&cat=3D%2fTechnology%2fSCSI%2fUltra320+S= CSI ) cost: $399 USD IF you bought it from adaptec Match this with 6 Seagate 10k 36G Cheetah U320 scsi drives:=20 ( http://www.c-source.com/csource/newsite/ttechnote.asp?part_no=3D207024 ) for a cost of $189 USD per drive. If you have 6 of them it brings the total price for your drives to $1134 USD. Total cost for this would be approx $1633 before shipping costs. We use this configuration in our two file servers and have nothing but positive results. If you are totally unable to use software raid you could still buy 6 of those drives, and spend approx $900 USD on an LSI Megaraid 1650 controller. I really believe you'll find either of those options to be superior in terms of price for you. Sincerely, Will LaShell =20 > Does anyone have experience with this NAS device or other "SCSI-to-IDE" R= AID > systems? Are they OK in terms of performance and reliability? > Kind regards, > Alexander. >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings --=-bXxLmEzwF1KgYyrKR8sJ 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/k/9cZr3R5kgOZd0RAvFXAJ9v/DYPOwWHzAxqpIjIPLrOlJW+6wCgipA6 CfjLFA/zyYKGmc7MJIfFclA= =U6mm -----END PGP SIGNATURE----- --=-bXxLmEzwF1KgYyrKR8sJ-- From pgsql-performance-owner@postgresql.org Mon Oct 20 13:04: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 CFE2FD1B518 for ; Mon, 20 Oct 2003 16:04: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 48240-05 for ; Mon, 20 Oct 2003 13:03:41 -0300 (ADT) Received: from ihemail1.firewall.lucent.com (ihemail1.lucent.com [192.11.222.161]) by svr1.postgresql.org (Postfix) with ESMTP id A0669D1B51E for ; Mon, 20 Oct 2003 13:03:35 -0300 (ADT) Received: from ihmail.ih.lucent.com (h135-1-218-70.lucent.com [135.1.218.70]) by ihemail1.firewall.lucent.com (Switch-2.2.8/Switch-2.2.0) with ESMTP id h9KG2oP22694; Mon, 20 Oct 2003 11:02:59 -0500 (CDT) Received: from [192.168.10.52] (USS-Excelsior.ih.lucent.com [135.185.171.70]) by ihmail.ih.lucent.com (8.11.7+Sun/EMS-1.5 sol2) id h9KG2mt07102; Mon, 20 Oct 2003 11:02:49 -0500 (CDT) Mime-Version: 1.0 X-Sender: slgan@135.1.218.70 Message-Id: In-Reply-To: <200310191204.23888.josh@agliodbs.com> References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> Date: Mon, 20 Oct 2003 11:04:43 -0500 To: Josh Berkus , Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/509 X-Sequence-Number: 4257 Hi Josh, Tom, OK. As I understand it, vacuum does not release the space used by the index file. However, it should be able to reuse the space for indexing. I have observed that during initial updates of the table, the index file did not grow and was steady but it did not last long and keeps growing afterwards. Vacuum/vacuum analyze did not help. In all the update testing, vacuum analyze was done every 1 minute. Tom, something caught your attention the last time. Any insight so far ? Is it a bug ? Thanks. Gan Tom Lane wrote: Seum-Lim Gan writes: > vacuum verbose analyze dsperf_rda_or_key; > INFO: vacuuming "scncraft.dsperf_rda_or_key" > INFO: index "dsperf242_1105" now contains 300000 row versions in 12387 pages > DETAIL: 3097702 index row versions were removed. > 0 index pages have been deleted, 0 are currently reusable. Hm, interesting that you deleted 90% of the entries and still had no empty index pages at all. What was the pattern of your deletes and/or updates with respect to this index's key? > However, when I check the disk space usage, it has not changed. It won't in any case. Plain VACUUM is designed for maintaining a steady-state level of free space in tables and indexes, not for returning major amounts of space to the OS. For that you need more-invasive operations like VACUUM FULL or REINDEX. regards, tom lane At 12:04 pm -0700 2003/10/19, Josh Berkus wrote: >Gan, > >> Oh, so in order to reclaim the disk space, we must run >> reindex or vacuum full ? >> This will lock out the table and we won't be able to do anything. >> Looks like this is a problem. It means we cannot use it for >> 24x7 operations without having to stop the process and do the vacuum full >> and reindex. Is there anything down the road that these operations >> will not lock out the table ? > >I doubt it; the amount of page-shuffling required to reclaim 90% of the space >in an index for a table that has been mostly cleared is substantial, and >would prevent concurrent access. > >Also, you seem to have set up an impossible situation for VACUUM. If I'm >reading your statistics right, you have a large number of threads accessing >most of the data 100% of the time, preventing VACUUM from cleaning up the >pages. This is not, in my experience, a realistic test case ... there are >peak and idle periods for all databases, even webservers that have been >slashdotted. > >-- >Josh Berkus >Aglio Database Solutions >San Francisco > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Oct 20 14:20: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 DB663D1B4F2 for ; Mon, 20 Oct 2003 16:50: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 60829-01 for ; Mon, 20 Oct 2003 13:50:22 -0300 (ADT) Received: from haeb.noc.uk.easynet.net (haeb.noc.uk.easynet.net [195.40.7.191]) by svr1.postgresql.org (Postfix) with ESMTP id 036F3D1B4E4 for ; Mon, 20 Oct 2003 13:50:21 -0300 (ADT) Received: (from haeb@localhost) by haeb.noc.uk.easynet.net (8.9.3/8.9.1) id RAA12431 for pgsql-performance@postgresql.org; Mon, 20 Oct 2003 17:50:16 +0100 (BST) (envelope-from haeb) Message-Id: <200310201650.RAA12431@haeb.noc.uk.easynet.net> Subject: Performance weirdness with/without vacuum analyze To: pgsql-performance@postgresql.org Date: Mon, 20 Oct 2003 17:50:16 +0100 (BST) From: Harry Broomhall Reply-To: "Harry Broomhall" X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM756467486-10251-0_ Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/511 X-Sequence-Number: 4259 --ELM756467486-10251-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit It has been suggested to me that I resubmit this question to this list, rather than the GENERAL list it was originaly sent to. I asked earlier about ways of doing an UPDATE involving a left outer join and got some very useful feedback. This has thrown up a (to me) strange anomaly about the speed of such an update. The input to this query is a fairly large (the example I'm working with has 335,000 rows) set of records containing numbers to be looked up in the lookup table. This lookup table has 239 rows. I'm always reading the suggestion that doing a 'VACUUM ANALYZE' on a database is 'A Good Thing' as it helps the planner to do the best thing, so I arranged a vacuum analyze on the input records. Running the query takes about 13 mins or so. If, however I *don't* do an analyze, but leave the input table as it was when imported the run takes about 2.5 mins! Looking at the output from 'explain' I can see that the main difference in the way the planner does it is that it does a merge join in the non-analyze case, and a hash join in the analyze case. Unfortunately I don't really know what this is implying, hence the call for assistance. I have a file with all sorts of info about the problem (details of tables, output of 'explain' etc) but as it is about 5K in size, and wide as well, I didn't want to dump it in the list without any warning! However - it has been suggested that it should be OK to include this I have now done so - hopefully with this message. Regards, Harry. --ELM756467486-10251-0_ Content-Type: text/plain Content-Disposition: attachment; filename=run.info.txt Content-Description: run.info.txt Content-Transfer-Encoding: 7bit select version(); version --------------------------------------------------------------------- PostgreSQL 7.3.4 on i386-unknown-freebsd4.5, compiled by GCC 2.95.3 create table num_xlate (interim_num varchar(30) not null , num varchar(30) not null, starttime timestamp with time zone not null, endtime timestamp with time zone not null, constraint num_pos_dur check (endtime >= starttime), primary key (interim_num, starttime)); create table unrated_cdrs (cdr_id bigserial unique, interim_cli varchar(30), interim_tli varchar(30), cli varchar(30), tli varchar(30)); CREATE TABLE copy unrated_cdrs (interim_cli, interim_tli) from '/data/swipe/bin/mt2.csv' with delimiter as ','; COPY explain update unrated_cdrs set cli = coalesce(b.num, unrated_cdrs.interim_cli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_cli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Merge Join (cost=286.99..358.99 rows=1000 width=393) Merge Cond: ("outer".cdr_id = "inner".cdr_id) -> Index Scan using unrated_cdrs_cdr_id_key on unrated_cdrs (cost=0.00..52.00 rows=1000 width=262) -> Sort (cost=286.99..289.49 rows=1000 width=131) Sort Key: un.cdr_id -> Merge Join (cost=139.66..237.16 rows=1000 width=131) Merge Cond: ("outer".interim_cli = "inner".interim_num) Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) -> Sort (cost=69.83..72.33 rows=1000 width=49) Sort Key: un.interim_cli -> Seq Scan on unrated_cdrs un (cost=0.00..20.00 rows=1000 width=49) -> Sort (cost=69.83..72.33 rows=1000 width=82) Sort Key: num_xlate.interim_num -> Seq Scan on num_xlate (cost=0.00..20.00 rows=1000 width=82) (14 rows) update unrated_cdrs set cli = coalesce(b.num, unrated_cdrs.interim_cli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_cli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; UPDATE 335671 update unrated_cdrs set tli = coalesce(b.num, unrated_cdrs.interim_tli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_tli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; UPDATE 335671 2m57.37s real 0.00s user 0.00s sys DROP TABLE create table unrated_cdrs (cdr_id bigserial unique, interim_cli varchar(30), interim_tli varchar(30), cli varchar(30), tli varchar(30)); CREATE TABLE copy unrated_cdrs (interim_cli, interim_tli) from '/data/swipe/bin/mt2.csv' with delimiter as ','; COPY vacuum analyze unrated_cdrs; VACUUM explain update unrated_cdrs set cli = coalesce(b.num, unrated_cdrs.interim_cli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_cli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Hash Join (cost=67773.77..112554.43 rows=335671 width=343) Hash Cond: ("outer".cdr_id = "inner".cdr_id) -> Seq Scan on unrated_cdrs (cost=0.00..8832.71 rows=335671 width=229) -> Hash (cost=61197.59..61197.59 rows=335671 width=114) -> Merge Join (cost=58661.58..61197.59 rows=335671 width=114) Merge Cond: ("outer".interim_cli = "inner".interim_num) Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) -> Sort (cost=58591.75..59430.93 rows=335671 width=32) Sort Key: un.interim_cli -> Seq Scan on unrated_cdrs un (cost=0.00..8832.71 rows=335671 width=32) -> Sort (cost=69.83..72.33 rows=1000 width=82) Sort Key: num_xlate.interim_num -> Seq Scan on num_xlate (cost=0.00..20.00 rows=1000 width=82) (13 rows) update unrated_cdrs set cli = coalesce(b.num, unrated_cdrs.interim_cli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_cli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; UPDATE 335671 update unrated_cdrs set tli = coalesce(b.num, unrated_cdrs.interim_tli) from (unrated_cdrs as un left outer join num_xlate on (un.interim_tli = interim_num and un.starttime between num_xlate.starttime and num_xlate.endtime)) as b where unrated_cdrs.cdr_id = b.cdr_id; UPDATE 335671 13m43.74s real 0.00s user 0.00s sys --ELM756467486-10251-0_-- From pgsql-admin-owner@postgresql.org Tue Oct 21 15:13:50 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BBBD8D1B52D; Mon, 20 Oct 2003 17:08: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 64227-08; Mon, 20 Oct 2003 14:08:21 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id BB188D1B551; Mon, 20 Oct 2003 14:08:19 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3795301; Mon, 20 Oct 2003 10:09:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rhaoni Chiu Pereira , PostgreSQL ADMIN , PostgreSQL Performance Subject: Re: [PERFORM] Low Insert/Update Performance Date: Mon, 20 Oct 2003 10:07:48 -0700 User-Agent: KMail/1.4.3 References: <1066659206.3f93ed86b9907@sistemica.info> In-Reply-To: <1066659206.3f93ed86b9907@sistemica.info> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310201007.48534.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/263 X-Sequence-Number: 10824 Rhaoni, > My problem is that I must substitute this Oracle for a PostgreSQL > database and this same Delphi aplication takes 45 min to update Jan/2003. > All delphi routines are converted and optmized to work with PgSQL. Obviously not. How about posting the update queries? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Oct 20 14:34: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 69ABBD1B515 for ; Mon, 20 Oct 2003 17:33: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 70572-09 for ; Mon, 20 Oct 2003 14:33:25 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 7532AD1B4EC for ; Mon, 20 Oct 2003 14:33:24 -0300 (ADT) 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 h9KHVhOk016676; Mon, 20 Oct 2003 11:31:43 -0600 (MDT) Date: Mon, 20 Oct 2003 11:20:46 -0600 (MDT) From: "scott.marlowe" To: Alexander Priem Cc: Subject: Re: PostgreSQL data on a NAS device ? In-Reply-To: <006101c396d9$8995a060$b696a8c0@APR> 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: 200310/513 X-Sequence-Number: 4261 On Mon, 20 Oct 2003, Alexander Priem wrote: > Hi all, > > Does anyone have any experience with putting PostgreSQL data on a NAS > device? > > I am asking this because a NAS device is much cheaper to set up than a > couple of SCSI disks. I would like to use a relatively cheap NAS device > which uses four IDE drives (7.200 rpm), like the Dell PowerVault 725N. The > disks themselves would be much slower than SCSI disks, I know, but a NAS > device can be equipped with 3 Gb of memory, so this would make a very large > disk cache, right? If this NAS would be dedicated only to PostgreSQL, would > this be slower/faster than a SCSI RAID-10 setup of 6 disks? It would be much > cheaper... > > Any advice on this would be appreciated :) How important is this data? With a local SCSI RAID controller and SCSI drives, you can pull the power cord out the back of the machine during 1000 transactions, and your database will come back up in a coherent state. If you need that kind of reliability, then you'll likely want to use local SCSI drives. Note that you should test your setup to be sure, i.e. pull the network cord and see how the machine recovers (if the machine recovers). Running storage on a NAS is a bit of a tightrope act with your data, as is using IDE drives with write cache enabled. But depending on your application, using NAS may be a good solution. So, what's this database gonna be used for? From pgsql-performance-owner@postgresql.org Mon Oct 20 14:29: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 7246FD1B518 for ; Mon, 20 Oct 2003 17:29: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 70355-06 for ; Mon, 20 Oct 2003 14:28:32 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7A583D1B55C for ; Mon, 20 Oct 2003 14:28:31 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3795441; Mon, 20 Oct 2003 10:29:11 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Harry Broomhall" , pgsql-performance@postgresql.org Subject: Re: Performance weirdness with/without vacuum analyze Date: Mon, 20 Oct 2003 10:28:00 -0700 User-Agent: KMail/1.4.3 References: <200310201650.RAA12431@haeb.noc.uk.easynet.net> In-Reply-To: <200310201650.RAA12431@haeb.noc.uk.easynet.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310201028.00146.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/512 X-Sequence-Number: 4260 Harry, > It has been suggested to me that I resubmit this question to this list, > rather than the GENERAL list it was originaly sent to. > > I asked earlier about ways of doing an UPDATE involving a left outer > join and got some very useful feedback. The query you posted will always be somewhat slow due to the forced join order, which is unavodable with a left outer join. However, regarding your peculiar behaviour, please post: 1) Your random_page_cost and effective_cache_size settings 2) The EXPLAIN ANALYZE of each query instead of just the EXPLAIN Thanks! -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Tue Oct 21 15:13:48 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B5915D1B4F6; Mon, 20 Oct 2003 17:51: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 72397-07; Mon, 20 Oct 2003 14:51:03 -0300 (ADT) 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 095ACD1B51E; Mon, 20 Oct 2003 14:50:58 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9KHoWqJ005597; Mon, 20 Oct 2003 20:50:35 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9KHoMb4005595; Mon, 20 Oct 2003 20:50:22 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: [PERFORM] Low Insert/Update Performance From: Hannu Krosing To: Rhaoni Chiu Pereira Cc: PostgreSQL ADMIN , PostgreSQL Performance In-Reply-To: <1066659206.3f93ed86b9907@sistemica.info> References: <1066659206.3f93ed86b9907@sistemica.info> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1066672221.5434.5.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 20 Oct 2003 20:50:22 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/262 X-Sequence-Number: 10823 Rhaoni Chiu Pereira kirjutas E, 20.10.2003 kell 17:13: > Hi List, > > I got a P4 1.7Ghz , 512MB RAM , HD 7200 RPM, on RED HAT 9 running PostgreSQL > 7.3.2-3 Database. > I have a Delphi aplication that updates the Oracle database using .dbf > file's information ( converting the data from the old clipper aplication ) and > it takes about 3min and 45 seconds to update Jan/2003 . Have you tried contrib/dbase to do the same ? How fast does this run > My problem is that I must substitute this Oracle for a PostgreSQL database > and this same Delphi aplication takes 45 min to update Jan/2003. > All delphi routines are converted and optmized to work with PgSQL. Could it be that you try to run each insert in a separate transaction in PgSQL version ? Another possibility is that there is a primary key index created on empty tables which is not used in subsequent UNIQUE tests when tables start to fill and using index would be useful. An ANALYZE in a parallel backend could help here. Same can be true for foreign keys and unique constraints. --------------- Hannu From pgsql-performance-owner@postgresql.org Mon Oct 20 18:13: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 4E70ED1B508 for ; Mon, 20 Oct 2003 21:13: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 06336-05 for ; Mon, 20 Oct 2003 18:12:54 -0300 (ADT) Received: from hoemail1.firewall.lucent.com (hoemail1.lucent.com [192.11.226.161]) by svr1.postgresql.org (Postfix) with ESMTP id 4837DD1B51B for ; Mon, 20 Oct 2003 18:12:51 -0300 (ADT) Received: from ihmail.ih.lucent.com (h135-1-218-70.lucent.com [135.1.218.70]) by hoemail1.firewall.lucent.com (Switch-2.2.8/Switch-2.2.0) with ESMTP id h9KLCF424495; Mon, 20 Oct 2003 16:12:23 -0500 (CDT) Received: from [192.168.10.52] (USS-Excelsior.ih.lucent.com [135.185.171.70]) by ihmail.ih.lucent.com (8.11.7+Sun/EMS-1.5 sol2) id h9KLCEt16966; Mon, 20 Oct 2003 16:12:14 -0500 (CDT) Mime-Version: 1.0 X-Sender: slgan@135.1.218.70 Message-Id: In-Reply-To: References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> Date: Mon, 20 Oct 2003 16:14:09 -0500 To: Josh Berkus , Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/515 X-Sequence-Number: 4263 Hi Tom, Josh, We tried one more thing: with the table not being updated at all and we did vacuum. Each time a vacuum is done, the index file becomes bigger. This is probably what is contributing to the index file growing as well. Thanks. Gan At 11:04 am -0500 2003/10/20, Seum-Lim Gan wrote: >Hi Josh, Tom, > >OK. As I understand it, vacuum does not release the space >used by the index file. >However, it should be able to reuse the space for indexing. > >I have observed that during initial updates of the table, >the index file did not grow and was steady but it did not last long >and keeps growing afterwards. Vacuum/vacuum analyze did not help. > >In all the update testing, vacuum analyze was done every 1 minute. > >Tom, something caught your attention the last time. > >Any insight so far ? Is it a bug ? > >Thanks. > >Gan > >Tom Lane wrote: > >Seum-Lim Gan writes: >> vacuum verbose analyze dsperf_rda_or_key; >> INFO: vacuuming "scncraft.dsperf_rda_or_key" >> INFO: index "dsperf242_1105" now contains 300000 row versions in >>12387 pages >> DETAIL: 3097702 index row versions were removed. >> 0 index pages have been deleted, 0 are currently reusable. > >Hm, interesting that you deleted 90% of the entries and still had no >empty index pages at all. What was the pattern of your deletes and/or >updates with respect to this index's key? > >> However, when I check the disk space usage, it has not changed. > >It won't in any case. Plain VACUUM is designed for maintaining a >steady-state level of free space in tables and indexes, not for >returning major amounts of space to the OS. For that you need >more-invasive operations like VACUUM FULL or REINDEX. > > regards, tom lane > >At 12:04 pm -0700 2003/10/19, Josh Berkus wrote: >>Gan, >> >>> Oh, so in order to reclaim the disk space, we must run >>> reindex or vacuum full ? >>> This will lock out the table and we won't be able to do anything. >>> Looks like this is a problem. It means we cannot use it for >>> 24x7 operations without having to stop the process and do the vacuum full >>> and reindex. Is there anything down the road that these operations >>> will not lock out the table ? >> >>I doubt it; the amount of page-shuffling required to reclaim 90% of the space >>in an index for a table that has been mostly cleared is substantial, and >>would prevent concurrent access. >> >>Also, you seem to have set up an impossible situation for VACUUM. If I'm >>reading your statistics right, you have a large number of threads accessing >>most of the data 100% of the time, preventing VACUUM from cleaning up the >>pages. This is not, in my experience, a realistic test case ... there are >>peak and idle periods for all databases, even webservers that have been >>slashdotted. >> >>-- >>Josh Berkus >>Aglio Database Solutions >>San Francisco >> >>---------------------------(end of broadcast)--------------------------- >>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > >-- >+--------------------------------------------------------+ >| Seum-Lim GAN email : slgan@lucent.com | >| Lucent Technologies | >| 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | >| Naperville, IL 60566, USA. fax : (630)-713-7272 | >| web : http://inuweb.ih.lucent.com/~slgan | >+--------------------------------------------------------+ > >---------------------------(end of broadcast)--------------------------- >TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Mon Oct 20 18:25: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 7E058D1B510 for ; Mon, 20 Oct 2003 21:25: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 14580-02 for ; Mon, 20 Oct 2003 18:25:20 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 7E875D1B501 for ; Mon, 20 Oct 2003 18:25:17 -0300 (ADT) 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 h9KLPDit015842; Mon, 20 Oct 2003 17:25:13 -0400 (EDT) To: Seum-Lim Gan Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> Comments: In-reply-to Seum-Lim Gan message dated "Mon, 20 Oct 2003 16:14:09 -0500" Date: Mon, 20 Oct 2003 17:25:13 -0400 Message-ID: <15841.1066685113@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/516 X-Sequence-Number: 4264 Seum-Lim Gan writes: > We tried one more thing: with the table not being updated > at all and we did vacuum. Each time a vacuum is done, > the index file becomes bigger. It is not possible for plain vacuum to make the index bigger. VACUUM FULL possibly could make the index bigger, since it has to transiently create duplicate index entries for every row it moves. If you want any really useful comments on your situation, you're going to have to offer considerably more detail than you have done so far --- preferably, a test case that lets someone else reproduce your results. So far, all we can do is guess on the basis of very incomplete information. When you aren't even bothering to mention whether a vacuum is FULL or not, I have to wonder whether I have any realistic picture of what's going on. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 20 18:43: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 B76FFD1B4E1 for ; Mon, 20 Oct 2003 21:43: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 13813-08 for ; Mon, 20 Oct 2003 18:42:59 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 746ECD1B510 for ; Mon, 20 Oct 2003 18:42:56 -0300 (ADT) 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 h9KLgqit015969; Mon, 20 Oct 2003 17:42:52 -0400 (EDT) To: Seum-Lim Gan Cc: josh@agliodbs.com, pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> <19692.1066578442@sss.pgh.pa.us> Comments: In-reply-to Seum-Lim Gan message dated "Sun, 19 Oct 2003 11:55:57 -0500" Date: Mon, 20 Oct 2003 17:42:52 -0400 Message-ID: <15968.1066686172@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/517 X-Sequence-Number: 4265 Seum-Lim Gan writes: > [ successive outputs from VACUUM ANALYZE ] FWIW, I don't think your problem is really index bloat at all, it's more like too-many-dead-rows bloat. Note that the number of "dead row versions" is climbing steadily from run to run: > DETAIL: 101802 dead row versions cannot be removed yet. > DETAIL: 110900 dead row versions cannot be removed yet. > DETAIL: 753064 dead row versions cannot be removed yet. > DETAIL: 765328 dead row versions cannot be removed yet. It's hardly the index's fault that it's growing, when it has to keep track of an ever-increasing number of rows. The real question is what you're doing that requires the system to keep hold of these dead rows instead of recycling them. I suspect you have a client process somewhere that is holding an open transaction for a long time ... probably not doing anything, just sitting there with an unclosed BEGIN ... regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 20 21:57:55 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 1CA3BD1B53D for ; Tue, 21 Oct 2003 00: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 44291-07 for ; Mon, 20 Oct 2003 21:57:26 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id DAD3ED1B557 for ; Mon, 20 Oct 2003 21:57:22 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3798724 for pgsql-performance@postgresql.org; Mon, 20 Oct 2003 17:58:06 -0700 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: SRFs ... no performance penalty? Date: Mon, 20 Oct 2003 17:55:12 -0700 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310201755.12713.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/518 X-Sequence-Number: 4266 Folks, I'm working on the demo session for our upcoming presentation at PHPCon.=20= =20 As a side issue, we ended up comparing 3 versions of the same search screen: 1) All in PHP with views; 2) Using a function to build a query and count results but executing that= =20 query directly and sorting, paging in PHP; 3) Using a Set Returning function to handle row-returning, sorting, and=20 paging. All three methods were executing a series moderately complex query against = a=20 medium-sized data set (only about 20,000 rows but it's on a laptop). The= =20 postgresql.conf was tuned like a webserver; e.g. low sort_mem, high=20 max_connections. So far, on the average of several searches, we have: 1) 0.19687 seconds 2) 0.20667 seconds 3) 0.20594 seconds In our tests, using any kind of PL/pgSQL function seems to carry a 0.01 sec= ond=20 penalty over using PHP to build the search query. I'm not sure if this is= =20 comparitive time for string-parsing or something else; the 0.01 seems to be= =20 consistent regardless of scale. The difference between using a PL/pgSQL function as a query-builder only (t= he=20 7.2.x method) and using SRFs was small enough not to be significant. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 07:57: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 BDE54D1B55F for ; Tue, 21 Oct 2003 10:57: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 34709-09 for ; Tue, 21 Oct 2003 07:56:56 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 89124D1B527 for ; Tue, 21 Oct 2003 07:56:53 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1ABuC8-0005c4-00 for ; Tue, 21 Oct 2003 06:56:56 -0400 Received: by dba2 (Postfix, from userid 1019) id 273FAC63E; Tue, 21 Oct 2003 06:56:56 -0400 (EDT) Date: Tue, 21 Oct 2003 06:56:56 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? Message-ID: <20031021105655.GB9837@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> <19692.1066578442@sss.pgh.pa.us> <15968.1066686172@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15968.1066686172@sss.pgh.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/519 X-Sequence-Number: 4267 On Mon, Oct 20, 2003 at 05:42:52PM -0400, Tom Lane wrote: > hold of these dead rows instead of recycling them. I suspect you have > a client process somewhere that is holding an open transaction for a > long time ... probably not doing anything, just sitting there with an > unclosed BEGIN ... Which could be because you're doing something nasty with one of the "autocommit=off" clients. Most of the client libraries implement this by doing "commit;begin;" at every commit. This means you have way more idle in transaction connections than you think. Look in pg_stat_activity, assuming you've turned on query echoing. 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 Tue Oct 21 08:41: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 5845FD1B509 for ; Tue, 21 Oct 2003 11:41: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 51071-04 for ; Tue, 21 Oct 2003 08:40:36 -0300 (ADT) Received: from haeb.noc.uk.easynet.net (haeb.noc.uk.easynet.net [195.40.7.191]) by svr1.postgresql.org (Postfix) with ESMTP id 8938CD1B4F6 for ; Tue, 21 Oct 2003 08:40:32 -0300 (ADT) Received: (from haeb@localhost) by haeb.noc.uk.easynet.net (8.9.3/8.9.1) id MAA15046; Tue, 21 Oct 2003 12:40:26 +0100 (BST) (envelope-from haeb) Message-Id: <200310211140.MAA15046@haeb.noc.uk.easynet.net> Subject: Re: Performance weirdness with/without vacuum analyze In-Reply-To: <200310201028.00146.josh@agliodbs.com> from Josh Berkus at "Oct 20, 2003 10:28: 0 am" To: josh@agliodbs.com (Josh Berkus) Date: Tue, 21 Oct 2003 12:40:26 +0100 (BST) Cc: harry.broomhall@uk.easynet.net, pgsql-performance@postgresql.org From: Harry Broomhall Reply-To: "Harry Broomhall" X-Mailer: ELM [version 2.4ME+ PL43 (25)] 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: 200310/520 X-Sequence-Number: 4268 Josh Berkus writes: > Harry, Many thanks for your response, > > > It has been suggested to me that I resubmit this question to this list, > > rather than the GENERAL list it was originaly sent to. > > > > I asked earlier about ways of doing an UPDATE involving a left outer > > join and got some very useful feedback. > > The query you posted will always be somewhat slow due to the forced join > order, which is unavodable with a left outer join. Yes - I rather suspected that! It is a shame it takes two joins to do the work. > > However, regarding your peculiar behaviour, please post: > > 1) Your random_page_cost and effective_cache_size settings #effective_cache_size = 1000 # typically 8KB each #random_page_cost = 4 # units are one sequential page fetch cost i.e. - still set to their defaults. > 2) The EXPLAIN ANALYZE of each query instead of just the EXPLAIN First the case with no vacuum analyze: QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=99.32..171.32 rows=1000 width=259) (actual time=18579.92..48277.69 rows=335671 loops=1) Merge Cond: ("outer".cdr_id = "inner".cdr_id) -> Index Scan using import_cdrs_cdr_id_key on import_cdrs (cost=0.00..52.00 rows=1000 width=164) (actual time=0.42..11479.51 rows=335671 loops=1) -> Sort (cost=99.32..101.82 rows=1000 width=95) (actual time=18578.71..21155.65 rows=335671 loops=1) Sort Key: un.cdr_id -> Hash Join (cost=6.99..49.49 rows=1000 width=95) (actual time=4.70..10011.35 rows=335671 loops=1) Hash Cond: ("outer".interim_cli = "inner".interim_num) Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) -> Seq Scan on import_cdrs un (cost=0.00..20.00 rows=1000 width=49) (actual time=0.02..4265.63 rows=335671 loops=1) -> Hash (cost=6.39..6.39 rows=239 width=46) (actual time=4.57..4.57 rows=0 loops=1) -> Seq Scan on num_xlate (cost=0.00..6.39 rows=239 width=46) (actual time=0.12..2.77 rows=239 loops=1) Total runtime: 80408.42 msec (12 rows) And now the case *with* the vacuum analyze: QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=15335.91..49619.57 rows=335671 width=202) (actual time=12383.44..49297.58 rows=335671 loops=1) Hash Cond: ("outer".cdr_id = "inner".cdr_id) -> Seq Scan on import_cdrs (cost=0.00..8496.71 rows=335671 width=126) (actual time=0.15..9504.24 rows=335671 loops=1) -> Hash (cost=10398.73..10398.73 rows=335671 width=76) (actual time=12371.13..12371.13 rows=0 loops=1) -> Hash Join (cost=6.99..10398.73 rows=335671 width=76) (actual time=4.91..9412.55 rows=335671 loops=1) Hash Cond: ("outer".interim_cli = "inner".interim_num) Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) -> Seq Scan on import_cdrs un (cost=0.00..8496.71 rows=335671 width=30) (actual time=0.09..3813.54 rows=335671 loops=1) -> Hash (cost=6.39..6.39 rows=239 width=46) (actual time=4.71..4.71 rows=0 loops=1) -> Seq Scan on num_xlate (cost=0.00..6.39 rows=239 width=46) (actual time=0.22..2.90 rows=239 loops=1) Total runtime: 432543.73 msec (11 rows) Please note that since I first posted I have been slightly adjusting the schema of the tables, but the disparity remains. Many thanks for your assistance. Regards, Harry. From pgsql-performance-owner@postgresql.org Tue Oct 21 09:00: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 8FB01D1B53C for ; Tue, 21 Oct 2003 12:00: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 43590-10 for ; Tue, 21 Oct 2003 09:00:15 -0300 (ADT) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id 4B866D1B518 for ; Tue, 21 Oct 2003 09:00:12 -0300 (ADT) 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.42 $ on Novell NetWare via secured & encrypted transport (TLS); Tue, 21 Oct 2003 06:00:18 -0600 Message-ID: <3F951FC8.2090906@myrealbox.com> Date: Tue, 21 Oct 2003 17:30:08 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Harry Broomhall , Performance Subject: Re: Performance weirdness with/without vacuum analyze References: <200310211140.MAA15046@haeb.noc.uk.easynet.net> In-Reply-To: <200310211140.MAA15046@haeb.noc.uk.easynet.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: 200310/521 X-Sequence-Number: 4269 Harry Broomhall wrote: > #effective_cache_size = 1000 # typically 8KB each > #random_page_cost = 4 # units are one sequential page fetch cost You must tune the first one at least. Try http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html to tune these parameters. >>2) The EXPLAIN ANALYZE of each query instead of just the EXPLAIN > > > First the case with no vacuum analyze: > > QUERY PLAN > ------------------------------------------------------------------------------------------------------------------------------------------------------- > Merge Join (cost=99.32..171.32 rows=1000 width=259) (actual time=18579.92..48277.69 rows=335671 loops=1) > Merge Cond: ("outer".cdr_id = "inner".cdr_id) > -> Index Scan using import_cdrs_cdr_id_key on import_cdrs (cost=0.00..52.00 rows=1000 width=164) (actual time=0.42..11479.51 rows=335671 loops=1) > -> Sort (cost=99.32..101.82 rows=1000 width=95) (actual time=18578.71..21155.65 rows=335671 loops=1) > Sort Key: un.cdr_id > -> Hash Join (cost=6.99..49.49 rows=1000 width=95) (actual time=4.70..10011.35 rows=335671 loops=1) > Hash Cond: ("outer".interim_cli = "inner".interim_num) > Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) > -> Seq Scan on import_cdrs un (cost=0.00..20.00 rows=1000 width=49) (actual time=0.02..4265.63 rows=335671 loops=1) > -> Hash (cost=6.39..6.39 rows=239 width=46) (actual time=4.57..4.57 rows=0 loops=1) > -> Seq Scan on num_xlate (cost=0.00..6.39 rows=239 width=46) (actual time=0.12..2.77 rows=239 loops=1) > Total runtime: 80408.42 msec > (12 rows) You are lucky to get a better plan here because planner is way off w.r.t estimated number of rows. > > And now the case *with* the vacuum analyze: > > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------------------- > Hash Join (cost=15335.91..49619.57 rows=335671 width=202) (actual time=12383.44..49297.58 rows=335671 loops=1) > Hash Cond: ("outer".cdr_id = "inner".cdr_id) > -> Seq Scan on import_cdrs (cost=0.00..8496.71 rows=335671 width=126) (actual time=0.15..9504.24 rows=335671 loops=1) > -> Hash (cost=10398.73..10398.73 rows=335671 width=76) (actual time=12371.13..12371.13 rows=0 loops=1) > -> Hash Join (cost=6.99..10398.73 rows=335671 width=76) (actual time=4.91..9412.55 rows=335671 loops=1) > Hash Cond: ("outer".interim_cli = "inner".interim_num) > Join Filter: (("outer".starttime >= "inner".starttime) AND ("outer".starttime <= "inner".endtime)) > -> Seq Scan on import_cdrs un (cost=0.00..8496.71 rows=335671 width=30) (actual time=0.09..3813.54 rows=335671 loops=1) > -> Hash (cost=6.39..6.39 rows=239 width=46) (actual time=4.71..4.71 rows=0 loops=1) > -> Seq Scan on num_xlate (cost=0.00..6.39 rows=239 width=46) (actual time=0.22..2.90 rows=239 loops=1) > Total runtime: 432543.73 msec > (11 rows) > What happens if you turn off hash joins? Also bump sort memory to something good.. around 16MB and see what difference does it make to performance.. Shridhar From pgsql-performance-owner@postgresql.org Tue Oct 21 09:13: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 118C1D1B508 for ; Tue, 21 Oct 2003 12:13: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 52043-10 for ; Tue, 21 Oct 2003 09:13:06 -0300 (ADT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id CF477D1B527 for ; Tue, 21 Oct 2003 09:13:01 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id h9LBFHw29703; Tue, 21 Oct 2003 13:15:17 +0200 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 h9LC4HR25098; Tue, 21 Oct 2003 14:04:18 +0200 Message-ID: <3F9522B2.2010009@bigfoot.com> Date: Tue, 21 Oct 2003 14:12:34 +0200 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: Andrew Sullivan Subject: Re: index file bloating still in 7.4 ? References: <200310181458.15575.josh@agliodbs.com> <16213.1066530060@sss.pgh.pa.us> <17172.1066542509@sss.pgh.pa.us> <19692.1066578442@sss.pgh.pa.us> <15968.1066686172@sss.pgh.pa.us> <20031021105655.GB9837@libertyrms.info> In-Reply-To: <20031021105655.GB9837@libertyrms.info> 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: 200310/522 X-Sequence-Number: 4270 Andrew Sullivan wrote: > On Mon, Oct 20, 2003 at 05:42:52PM -0400, Tom Lane wrote: > > >>hold of these dead rows instead of recycling them. I suspect you have >>a client process somewhere that is holding an open transaction for a >>long time ... probably not doing anything, just sitting there with an >>unclosed BEGIN ... > > > Which could be because you're doing something nasty with one of the > "autocommit=off" clients. Most of the client libraries implement > this by doing "commit;begin;" at every commit. This means you have > way more idle in transaction connections than you think. Look in > pg_stat_activity, assuming you've turned on query echoing. Or is enough do a ps -eafwww | grep post to see the state of the connections Regards Gaetano Mendola From pgsql-performance-owner@postgresql.org Tue Oct 21 09:37: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 DC185D1B518 for ; Tue, 21 Oct 2003 12:37: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 61491-04 for ; Tue, 21 Oct 2003 09:36:41 -0300 (ADT) Received: from haeb.noc.uk.easynet.net (haeb.noc.uk.easynet.net [195.40.7.191]) by svr1.postgresql.org (Postfix) with ESMTP id D4131D1B520 for ; Tue, 21 Oct 2003 09:36:28 -0300 (ADT) Received: (from haeb@localhost) by haeb.noc.uk.easynet.net (8.9.3/8.9.1) id NAA15239; Tue, 21 Oct 2003 13:35:50 +0100 (BST) (envelope-from haeb) Message-Id: <200310211235.NAA15239@haeb.noc.uk.easynet.net> Subject: Re: Performance weirdness with/without vacuum analyze In-Reply-To: <3F951FC8.2090906@myrealbox.com> from Shridhar Daithankar at "Oct 21, 2003 5:30: 8 pm" To: shridhar_daithankar@myrealbox.com (Shridhar Daithankar) Date: Tue, 21 Oct 2003 13:35:50 +0100 (BST) Cc: harry.broomhall@uk.easynet.net, pgsql-performance@postgresql.org From: Harry Broomhall Reply-To: "Harry Broomhall" X-Mailer: ELM [version 2.4ME+ PL43 (25)] 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: 200310/523 X-Sequence-Number: 4271 Shridhar Daithankar writes: > Harry Broomhall wrote: > > #effective_cache_size = 1000 # typically 8KB each > > #random_page_cost = 4 # units are one sequential page fetch cost > > You must tune the first one at least. Try > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html to tune these > parameters. Wow. Many thanks for the pointer. I'm going to be spending some time trying to get my head around all of that! [SNIP] > > Total runtime: 80408.42 msec > > (12 rows) > > You are lucky to get a better plan here because planner is way off w.r.t > estimated number of rows. Yes! I thought that. Which was why I was so surprised at the difference. > > > > And now the case *with* the vacuum analyze: > > [SNIP] > > What happens if you turn off hash joins? Also bump sort memory to something > good.. around 16MB and see what difference does it make to performance.. Lots of things to try there..... It will probably take me some time . Regards, Harry. From pgsql-performance-owner@postgresql.org Tue Oct 21 09:45: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 EFEC7D1B4FD for ; Tue, 21 Oct 2003 12:45: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 61608-06 for ; Tue, 21 Oct 2003 09:45:14 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id D1EB4D1B53D for ; Tue, 21 Oct 2003 09:45:09 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Tue, 21 Oct 2003 14:45:10 +0200 Message-ID: <006201c397d1$932488f0$b696a8c0@APR> From: "Alexander Priem" To: "scott.marlowe" Cc: References: Subject: Re: PostgreSQL data on a NAS device ? Date: Tue, 21 Oct 2003 14:48:06 +0200 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/524 X-Sequence-Number: 4272 The machine is going to be used for a pretty large database (well over 100 tables with some of them containing over a million records from the start, number of tables and records will grow (much?) larger in the future). This database is going to be used by a pretty large number of employees. The number of concurrent users will vary between 1 - 100 or so, depending on the time of day etc. This will be a database containing client and supplier data as well as product descriptions and prices/ingredients/labels/brands etc. Database use will include lots of SELECTS but also lots of INSERTS/UPDATES, i.e. the database will be pretty active during bussiness hours... I think you (Scott and Will) are right when you say that NAS devices are not ideal for this kind of thing. I have been thinking about the hardware configuration for this machine for some time now (and had a lot of hints through this list already) and decided to go for a SCSI RAID config after all. The extra costs will be worth it :) The machine I have in mind now is like this : Dell PowerEdge 1750 machine with Intel Xeon CPU at 3 GHz and 4 GB of RAM. This machine will contain a PERC4/Di RAID controller with 128MB of battery backed cache memory. The O/S and logfiles will be placed on a RAID-1 setup of two 36Gb SCSI-U320 drives (15.000rpm). Database data will be placed on a Dell PowerVault 220S rack-module containing six 36Gb SCSI-U320 drives (15.000rpm) in a RAID-10 setup. This PowerVault will be connected to the DB server via a SCSI cable... This machine will be a bit more expensive than I thought at first (it's going to be about EUR 14.000, but that's including 3 years of on-site support from Dell (24x7, 4-hour response) and peripherals like UPS etc... Do you think this machine wil be OK for this task? Thanks for your help so far :) Kind regards, Alexander Priem. From pgsql-performance-owner@postgresql.org Tue Oct 21 09:58: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 B6B31D1B53C for ; Tue, 21 Oct 2003 12:58: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 62006-03 for ; Tue, 21 Oct 2003 09:58:02 -0300 (ADT) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id 73DFDD1B53B for ; Tue, 21 Oct 2003 09:57:58 -0300 (ADT) 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.42 $ on Novell NetWare via secured & encrypted transport (TLS); Tue, 21 Oct 2003 06:57:48 -0600 Message-ID: <3F952D41.9030603@myrealbox.com> Date: Tue, 21 Oct 2003 18:27:37 +0530 From: Shridhar Daithankar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030917 Thunderbird/0.3a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alexander Priem Cc: "scott.marlowe" , pgsql-performance@postgresql.org Subject: Re: PostgreSQL data on a NAS device ? References: <006201c397d1$932488f0$b696a8c0@APR> In-Reply-To: <006201c397d1$932488f0$b696a8c0@APR> 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: 200310/525 X-Sequence-Number: 4273 Alexander Priem wrote: > Dell PowerEdge 1750 machine with Intel Xeon CPU at 3 GHz and 4 GB of RAM. > This machine will contain a PERC4/Di RAID controller with 128MB of battery > backed cache memory. The O/S and logfiles will be placed on a RAID-1 setup > of two 36Gb SCSI-U320 drives (15.000rpm). Database data will be placed on a > Dell PowerVault 220S rack-module containing six 36Gb SCSI-U320 drives > (15.000rpm) in a RAID-10 setup. This PowerVault will be connected to the DB > server via a SCSI cable... > This machine will be a bit more expensive than I thought at first (it's > going to be about EUR 14.000, but that's including 3 years of on-site > support from Dell (24x7, 4-hour response) and peripherals like UPS etc... Check opteron as well.. I don't know much about european resellers. IBM sells eserver 325 which has opterons. Apparently they scale much better at higher load. Of course pricing,availability and support are most important. http://theregister.co.uk/content/61/33378.html http://www.pc.ibm.com/us/eserver/opteron/325/ Any concrete benchmarks for postgresql w.r.t xeons and opterons? A collection would be nice to have..:-) Shridhar From pgsql-performance-owner@postgresql.org Tue Oct 21 10:31: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 02C7AD1B560 for ; Tue, 21 Oct 2003 13:31: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 63877-07 for ; Tue, 21 Oct 2003 10:30:53 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 45D80D1B55E for ; Tue, 21 Oct 2003 10:30:49 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Tue, 21 Oct 2003 15:30:51 +0200 Message-ID: <009201c397d7$f4eb25c0$b696a8c0@APR> From: "Alexander Priem" To: "Shridhar Daithankar" Cc: "scott.marlowe" , References: <006201c397d1$932488f0$b696a8c0@APR> <3F952D41.9030603@myrealbox.com> Subject: Re: PostgreSQL data on a NAS device ? Date: Tue, 21 Oct 2003 15:33:47 +0200 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.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/526 X-Sequence-Number: 4274 I have considered Opteron, yes. But I think there are too many uncertainties, like : * It's a new CPU that has not proven itself yet. * I don't think I can buy directly from IBM (according to their site), so how about support (24x7) ? This will be very important to our client. * I need to install and configure a 64bit Linux flavour which I don't know (yet) Any suggestions about the usability of the system I described before? Here is the description again: Dell PowerEdge 1750 machine with Intel Xeon CPU at 3 GHz and 4 GB of RAM. This machine will contain a PERC4/Di RAID controller with 128MB of battery backed cache memory. The O/S and logfiles will be placed on a RAID-1 setup of two 36Gb SCSI-U320 drives (15.000rpm). Database data will be placed on a Dell PowerVault 220S rack-module containing six 36Gb SCSI-U320 drives (15.000rpm) in a RAID-10 setup. This PowerVault will be connected to the DB server via a SCSI cable... I have never worked with a XEON CPU before. Does anyone know how it performs running PostgreSQL 7.3.4 / 7.4 on RedHat 9 ? Is it faster than a Pentium 4? I believe the main difference is cache memory, right? Aside from cache mem, it's basically a Pentium 4, or am I wrong? Kind regards, Alexander. From pgsql-performance-owner@postgresql.org Tue Oct 21 10:38:55 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 596E8D1B561 for ; Tue, 21 Oct 2003 13:38: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 72019-02 for ; Tue, 21 Oct 2003 10:38:24 -0300 (ADT) Received: from 3times25.net (66-23-202-190.clients.speedfactory.net [66.23.202.190]) by svr1.postgresql.org (Postfix) with ESMTP id 2B149D1B55A for ; Tue, 21 Oct 2003 10:38:20 -0300 (ADT) Received: from 3times25.net (localhost [127.0.0.1]) by 3times25.net (Postfix) with ESMTP id 2BEA02AF98 for ; Tue, 21 Oct 2003 09:39:53 -0400 (EDT) Message-ID: <3F953728.5000405@3times25.net> Date: Tue, 21 Oct 2003 09:39:52 -0400 From: Geoffrey User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: PostgreSQL data on a NAS device ? References: <006201c397d1$932488f0$b696a8c0@APR> <3F952D41.9030603@myrealbox.com> <009201c397d7$f4eb25c0$b696a8c0@APR> In-Reply-To: <009201c397d7$f4eb25c0$b696a8c0@APR> 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: 200310/527 X-Sequence-Number: 4275 Alexander Priem wrote: > I have considered Opteron, yes. But I think there are too many > uncertainties, like : > > * It's a new CPU that has not proven itself yet. > * I don't think I can buy directly from IBM (according to their site), so > how about support (24x7) ? This will be very important to our client. > * I need to install and configure a 64bit Linux flavour which I don't know > (yet) See http://www.monarchcomputer.com/ they custom build operton systems and preload them with Linux. You don't pay the Microsoft tax. -- Until later, Geoffrey esoteric@3times25.net From pgsql-performance-owner@postgresql.org Tue Oct 21 12:11: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 A4702D1B518 for ; Tue, 21 Oct 2003 15:11: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 86279-04 for ; Tue, 21 Oct 2003 12:10:41 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id C0B19D1B4F8 for ; Tue, 21 Oct 2003 12:10:39 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C397DF.8F6D3374" Subject: Tuning for mid-size server Date: Tue, 21 Oct 2003 10:28:13 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Tuning for mid-size server Thread-Index: AcOX349f483ObCssS1OiRqp3hvDwEQ== From: "Anjan Dave" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/530 X-Sequence-Number: 4278 This is a multi-part message in MIME format. ------_=_NextPart_001_01C397DF.8F6D3374 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory, with internal drives on RAID5 will be delivered. Postgres will be from RH8.0. I am planning for these values for the postgres configuration - to begin with: Shared_buffers (25% of RAM / 8KB)) =3D 8589934592 * .25 / 8192 =3D 262144 Sort_mem (4% of RAM / 1KB) =3D 335544. We'll take about half of that - 167772 Effective_cache_size =3D 262144 (same as shared_buffers - 25%) In the /etc/sysctl file: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D kernel.shmall =3D 536870912 (512MB) SHMALL Total amount of shared memory available (bytes or pages) kernel.shmmax =3D 536870912 (512MB) SHMMAX Maximum size of shared memory segment (bytes) In a generic sense, these are recommended values I found in some documents. The database will be small in size and will gradually grow over time from few thousands to a few million records, or more. The activity will be mostly of select statements from a few tables with joins, orderby, groupby clauses. The web application is based on Apache/Resin and hotspot JVM 1.4.0. Are the above settings ok to begin with? Are there any other parameters that I should configure now, or monitor lateron? In other words, am I missing anything here to take full advantage of 4 CPUs and 8Gigs of RAM? Appreciate any help. Thanks, Anjan ************************************************************************ **=20 This e-mail and any files transmitted with it are intended for the use of the addressee(s) only and may be confidential and covered by the attorney/client and other privileges. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. ------_=_NextPart_001_01C397DF.8F6D3374 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Tuning for mid-size server

Hi,

Pretty soon, a PowerEdge 6650 with 4 x 2Gh= z XEONs, and 8GB Memory, with internal drives on RAID5 will be delivered. P= ostgres will be from RH8.0.

I am planning for these values for the pos= tgres configuration - to begin with:

Shared_buffers (25% of RAM / 8KB)) =3D 858= 9934592 * .25 / 8192 =3D 262144

Sort_mem (4% of RAM / 1KB) =3D 335544. We'= ll take about half of that - 167772

Effective_cache_size =3D 262144 (same as s= hared_buffers - 25%)


In the /etc/sysctl file:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D
kernel.shmall =3D 536870912 (512MB) SHMALL Total amount of shared memory avail= able (bytes or pages)
kernel.shmmax =3D 536870912 (512MB) SHMMAX Maximum size of shared memory segme= nt (bytes)

In a generic sense, these are recommended = values I found in some documents. The database will be small in size and wi= ll gradually grow over time from few thousands to a few million records, or= more. The activity will be mostly of select statements from a few tables w= ith joins, orderby, groupby clauses. The web application is based on Apache= /Resin and hotspot JVM 1.4.0.

Are the above settings ok to begin with? A= re there any other parameters that I should configure now, or monitor later= on?

In other words, am I missing anything here= to take full advantage of 4 CPUs and 8Gigs of RAM?

Appreciate any help.


Thanks,
Anjan

************************= **************************************************
This e-mail and any fil= es transmitted with it are intended for the use of the addressee(s) only an= d may be confidential and covered by the attorney/client and other privileg= es.  If you received this e-mail in error, please notify the sender; d= o not disclose, copy, distribute, or take any action in reliance on the con= tents of this information; and delete it from your system. Any other use of= this e-mail is prohibited.


------_=_NextPart_001_01C397DF.8F6D3374-- From pgsql-performance-owner@postgresql.org Tue Oct 21 11:51: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 21176D1B4F8 for ; Tue, 21 Oct 2003 14:51: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 73743-08 for ; Tue, 21 Oct 2003 11:50:55 -0300 (ADT) Received: from haeb.noc.uk.easynet.net (haeb.noc.uk.easynet.net [195.40.7.191]) by svr1.postgresql.org (Postfix) with ESMTP id 44FE3D1B518 for ; Tue, 21 Oct 2003 11:50:50 -0300 (ADT) Received: (from haeb@localhost) by haeb.noc.uk.easynet.net (8.9.3/8.9.1) id PAA15768; Tue, 21 Oct 2003 15:50:48 +0100 (BST) (envelope-from haeb) Message-Id: <200310211450.PAA15768@haeb.noc.uk.easynet.net> Subject: Re: Performance weirdness with/without vacuum analyze In-Reply-To: <3F951FC8.2090906@myrealbox.com> from Shridhar Daithankar at "Oct 21, 2003 5:30: 8 pm" To: shridhar_daithankar@myrealbox.com (Shridhar Daithankar) Date: Tue, 21 Oct 2003 15:50:48 +0100 (BST) Cc: harry.broomhall@uk.easynet.net, pgsql-performance@postgresql.org From: Harry Broomhall Reply-To: "Harry Broomhall" X-Mailer: ELM [version 2.4ME+ PL43 (25)] 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: 200310/528 X-Sequence-Number: 4276 Shridhar Daithankar writes: First - many thanks for your suggestions and pointers to further info. I have been trying some of them with some interesting results! > Harry Broomhall wrote: > > #effective_cache_size = 1000 # typically 8KB each > > #random_page_cost = 4 # units are one sequential page fetch cost > > You must tune the first one at least. Try > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html to tune these > parameters. Changing effective_cache_size seemed to have very little effect. I took it in steps up to 300MB (the machine has 640MB memory), and the differences in speed were less than 10%. [SNIP] > > What happens if you turn off hash joins? This makes the non vacuum version about 40% slower, and the vacuum version to the same speed (i.e. about 4X faster than it had been!). > Also bump sort memory to something > good.. around 16MB and see what difference does it make to performance.. This was interesting. Taking it to 10MB made a slight improvement. Up to 20MB and the vacuum case improved by 5X speed, but the non-vacuum version slowed down. Putting it up to 40MB slowed both down again. I will need to test with some of the other scripts and functions I have written, but it looks as if selective use of more sort memory will be useful. Regards, Harry. From pgsql-performance-owner@postgresql.org Tue Oct 21 12:03: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 B017CD1B518 for ; Tue, 21 Oct 2003 15:03: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 81926-03 for ; Tue, 21 Oct 2003 12:02:39 -0300 (ADT) Received: from localhost.localdomain (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 9A496D1B4F8 for ; Tue, 21 Oct 2003 12:02:38 -0300 (ADT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id h9LE1uqd016680; Tue, 21 Oct 2003 10:01:56 -0400 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 h9LF2QZ21011; Tue, 21 Oct 2003 11:02:26 -0400 Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id TD8AYXX3; Tue, 21 Oct 2003 11:02:24 -0400 Subject: Re: SRFs ... no performance penalty? From: Robert Treat To: Josh Berkus Cc: pgsql-performance@postgresql.org In-Reply-To: <200310201755.12713.josh@agliodbs.com> References: <200310201755.12713.josh@agliodbs.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 21 Oct 2003 11:02:25 -0400 Message-Id: <1066748545.2069.7085.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/529 X-Sequence-Number: 4277 On Mon, 2003-10-20 at 20:55, Josh Berkus wrote: > Folks, > > I'm working on the demo session for our upcoming presentation at PHPCon. > > As a side issue, we ended up comparing 3 versions of the same search screen: > > 1) All in PHP with views; > 2) Using a function to build a query and count results but executing that > query directly and sorting, paging in PHP; > 3) Using a Set Returning function to handle row-returning, sorting, and > paging. > > All three methods were executing a series moderately complex query against a > medium-sized data set (only about 20,000 rows but it's on a laptop). The > postgresql.conf was tuned like a webserver; e.g. low sort_mem, high > max_connections. > > So far, on the average of several searches, we have: > > 1) 0.19687 seconds > 2) 0.20667 seconds > 3) 0.20594 seconds > Is this measuring time in the back-end or total time of script execution? > In our tests, using any kind of PL/pgSQL function seems to carry a 0.01 second > penalty over using PHP to build the search query. I'm not sure if this is > comparitive time for string-parsing or something else; the 0.01 seems to be > consistent regardless of scale. > > The difference between using a PL/pgSQL function as a query-builder only (the > 7.2.x method) and using SRFs was small enough not to be significant. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Tue Oct 21 12:53: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 0BF35D1B4F8 for ; Tue, 21 Oct 2003 15:53: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 93315-07 for ; Tue, 21 Oct 2003 12:53:08 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D0D74D1B4E6 for ; Tue, 21 Oct 2003 12:53:07 -0300 (ADT) 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 h9LFprOk000546; Tue, 21 Oct 2003 09:51:53 -0600 (MDT) Date: Tue, 21 Oct 2003 09:40:49 -0600 (MDT) From: "scott.marlowe" To: Alexander Priem Cc: Subject: Re: PostgreSQL data on a NAS device ? In-Reply-To: <006201c397d1$932488f0$b696a8c0@APR> 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: 200310/531 X-Sequence-Number: 4279 On Tue, 21 Oct 2003, Alexander Priem wrote: > The machine is going to be used for a pretty large database (well over 100 > tables with some of them containing over a million records from the start, > number of tables and records will grow (much?) larger in the future). This > database is going to be used by a pretty large number of employees. The > number of concurrent users will vary between 1 - 100 or so, depending on the > time of day etc. This will be a database containing client and supplier data > as well as product descriptions and prices/ingredients/labels/brands etc. > Database use will include lots of SELECTS but also lots of INSERTS/UPDATES, > i.e. the database will be pretty active during bussiness hours... > > I think you (Scott and Will) are right when you say that NAS devices are not > ideal for this kind of thing. I have been thinking about the hardware > configuration for this machine for some time now (and had a lot of hints > through this list already) and decided to go for a SCSI RAID config after > all. The extra costs will be worth it :) > > The machine I have in mind now is like this : > > Dell PowerEdge 1750 machine with Intel Xeon CPU at 3 GHz and 4 GB of RAM. > This machine will contain a PERC4/Di RAID controller with 128MB of battery > backed cache memory. The O/S and logfiles will be placed on a RAID-1 setup > of two 36Gb SCSI-U320 drives (15.000rpm). Database data will be placed on a > Dell PowerVault 220S rack-module containing six 36Gb SCSI-U320 drives > (15.000rpm) in a RAID-10 setup. This PowerVault will be connected to the DB > server via a SCSI cable... Funny, we're looking at the same basic type of system here, but with a Perc3/CI controller. We have a local supplier who gives us machines with a 3 year warranty and looks to be $1,000 to $2,000 lower than the Dell. We're just going to run two 73 Gig drives in a RAID1 to start with, with battery backed RAM. So that brings up my question, which is better, the Perc4 or Perc3 controllers, and what's the difference between them? I find Dell's tendency to hide other people's hardware behind their own model numbers mildly bothersome, as it makes it hard to comparison shop. From pgsql-performance-owner@postgresql.org Tue Oct 21 12:57: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 6140DD1B4FD for ; Tue, 21 Oct 2003 15:57: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 93461-08 for ; Tue, 21 Oct 2003 12:57:17 -0300 (ADT) Received: from anchor-post-37.mail.demon.net (anchor-post-37.mail.demon.net [194.217.242.87]) by svr1.postgresql.org (Postfix) with ESMTP id 81BBAD1B563 for ; Tue, 21 Oct 2003 12:57:12 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1ABysU-000KOi-0b; Tue, 21 Oct 2003 16:56:58 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id CCB7316D7C; Tue, 21 Oct 2003 16:56:51 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 2149316D7B; Tue, 21 Oct 2003 16:56:51 +0100 (BST) From: Richard Huxton To: "Anjan Dave" , Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 16:56:50 +0100 User-Agent: KMail/1.5 References: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310211656.50374.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/532 X-Sequence-Number: 4280 On Tuesday 21 October 2003 15:28, Anjan Dave wrote: > Hi, > > Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory, with > internal drives on RAID5 will be delivered. Postgres will be from RH8.0. You'll want to upgrade PG to v7.3.4 > I am planning for these values for the postgres configuration - to begin > with: > > Shared_buffers (25% of RAM / 8KB)) = 8589934592 * .25 / 8192 = 262144 > > Sort_mem (4% of RAM / 1KB) = 335544. We'll take about half of that - > 167772 > > Effective_cache_size = 262144 (same as shared_buffers - 25%) My instincts would be to lower the first two substantially, and increase the effective cache once you know load levels. I'd probably start with something like the values below and work up: shared_buffers = 8,000 - 10,000 (PG is happier letting the OS do the cacheing) sort_mem = 4,000 - 8,000 (don't forget this is for each sort) You'll find the annotated postgresql.conf and performance tuning articles useful: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > In a generic sense, these are recommended values I found in some > documents. The database will be small in size and will gradually grow > over time from few thousands to a few million records, or more. The > activity will be mostly of select statements from a few tables with > joins, orderby, groupby clauses. The web application is based on > Apache/Resin and hotspot JVM 1.4.0. You'll need to figure out how many concurrent users you'll have and how much memory will be required by apache/java. If your database grows radically, you'll probably want to re-tune as it grows. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Oct 24 15:01: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 5BC28D1B50C for ; Tue, 21 Oct 2003 16:14: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 95016-08 for ; Tue, 21 Oct 2003 13:13:55 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id A9969D1B510 for ; Tue, 21 Oct 2003 13:13:54 -0300 (ADT) 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 h9LGDkNu033217 for ; Tue, 21 Oct 2003 16:13:46 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9LGCHT5033020 for pgsql-performance@postgresql.org; Tue, 21 Oct 2003 16:12:17 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: PostgreSQL data on a NAS device ? Date: Tue, 21 Oct 2003 09:12:14 -0700 Organization: Hub.Org Networking Services Lines: 22 Message-ID: References: <006201c397d1$932488f0$b696a8c0@APR> <3F952D41.9030603@myrealbox.com> <009201c397d7$f4eb25c0$b696a8c0@APR> 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: <009201c397d7$f4eb25c0$b696a8c0@APR> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/626 X-Sequence-Number: 4374 > I have never worked with a XEON CPU before. Does anyone know how it performs > running PostgreSQL 7.3.4 / 7.4 on RedHat 9 ? Is it faster than a Pentium 4? > I believe the main difference is cache memory, right? Aside from cache mem, > it's basically a Pentium 4, or am I wrong? Well, see the problem is of course, there's so many flavors of P4s and Xeons that it's hard to tell which is faster unless you specify the exact model. And even then, it would depend on the workload. Would a Xeon/3GHz/2MB L3/400FSB be faster than a P4C/3GHz/800FSB? No idea as no one has complete number breakdowns on these comparisons. Oh yeah, you could get a big round number that says on SPEC or something one CPU is faster than the other but whether that's faster for Postgres and your PG app is a totally different story. That in mind, I wouldn't worry about it. The CPU is probably plenty fast for what you need to do. I'd look into two things in the server: memory and CPU expandability. I know you already plan on 4GB but you may need even more in the future. Few things can dramatically improve performance more than moving disk access to disk cache. And if there's a 2nd socket where you can pop another CPU in, that would leave you extra room if your server becomes CPU limited. From pgsql-performance-owner@postgresql.org Tue Oct 21 13:21: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 D6BFFD1B4F8 for ; Tue, 21 Oct 2003 16:21: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 01873-03 for ; Tue, 21 Oct 2003 13:21:26 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 823FCD1B4E6 for ; Tue, 21 Oct 2003 13:21:25 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801633; Tue, 21 Oct 2003 09:22:03 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Anjan Dave" , pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 09:20:44 -0700 User-Agent: KMail/1.4.3 References: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310210920.44890.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/533 X-Sequence-Number: 4281 Anjan, > Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory, with > internal drives on RAID5 will be delivered. Postgres will be from RH8.0. How many drives? RAID5 sucks for heavy read-write databases, unless you have 5+ drives. Or a large battery-backed cache. Also, last I checked, you can't address 8GB of RAM without a 64-bit processor. Since when are the Xeons 64-bit? > Shared_buffers (25% of RAM / 8KB)) = 8589934592 * .25 / 8192 = 262144 That's too high. Cut it in half at least. Probably down to 5% of available RAM. > Sort_mem (4% of RAM / 1KB) = 335544. We'll take about half of that - > 167772 Fine if you're running a few-user-large-operation database. If this is a webserver, you want a much, much lower value. > Effective_cache_size = 262144 (same as shared_buffers - 25%) Much too low. Where did you get these calculations, anyway? > In a generic sense, these are recommended values I found in some > documents. Where? We need to contact the author of the "documents" and tell them to correct things. > joins, orderby, groupby clauses. The web application is based on > Apache/Resin and hotspot JVM 1.4.0. You'll need to estimate the memory consumed by Java & Apache to have realistic figures to work with. > Are the above settings ok to begin with? Are there any other parameters > that I should configure now, or monitor lateron? No, they're not. See: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html to tune these parameters. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 13:23: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 DC9E9D1B554 for ; Tue, 21 Oct 2003 16:23: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 94193-09 for ; Tue, 21 Oct 2003 13:22:46 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 6EE1CD1B51E for ; Tue, 21 Oct 2003 13:22:45 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801631; Tue, 21 Oct 2003 09:23:24 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Robert Treat Subject: Re: SRFs ... no performance penalty? Date: Tue, 21 Oct 2003 09:22:05 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <200310201755.12713.josh@agliodbs.com> <1066748545.2069.7085.camel@camel> In-Reply-To: <1066748545.2069.7085.camel@camel> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310210922.06000.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/534 X-Sequence-Number: 4282 Robert, > > 1) 0.19687 seconds > > 2) 0.20667 seconds > > 3) 0.20594 seconds > > Is this measuring time in the back-end or total time of script > execution? Total time of execution, e.g. from clicking the "enter" button to displaying the list of matches. Any other comparison would be misleading. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 13:24: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 20D14D1B51E for ; Tue, 21 Oct 2003 16:24: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 95677-09 for ; Tue, 21 Oct 2003 13:23:50 -0300 (ADT) Received: from ihemail2.firewall.lucent.com (ihemail2.lucent.com [192.11.222.163]) by svr1.postgresql.org (Postfix) with ESMTP id 12443D1B55F for ; Tue, 21 Oct 2003 13:23:45 -0300 (ADT) Received: from ihmail.ih.lucent.com (h135-1-218-70.lucent.com [135.1.218.70]) by ihemail2.firewall.lucent.com (Switch-2.2.8/Switch-2.2.0) with ESMTP id h9LGNeN08603; Tue, 21 Oct 2003 11:23:41 -0500 (CDT) Received: from [192.168.10.52] (USS-Excelsior.ih.lucent.com [135.185.171.70]) by ihmail.ih.lucent.com (8.11.7+Sun/EMS-1.5 sol2) id h9LGNdF24594; Tue, 21 Oct 2003 11:23:39 -0500 (CDT) Mime-Version: 1.0 X-Sender: slgan@135.1.218.70 Message-Id: In-Reply-To: <15841.1066685113@sss.pgh.pa.us> References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> <15841.1066685113@sss.pgh.pa.us> Date: Tue, 21 Oct 2003 11:25:33 -0500 To: Tom Lane From: Seum-Lim Gan Subject: Re: index file bloating still in 7.4 ? Cc: Josh Berkus , pgsql-performance@postgresql.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/535 X-Sequence-Number: 4283 Hi Tom, 1.) OK. We have narrowed it down. We did a few (like 5 to 8 times) vacuum analyze (no full), the pg_statistics relfilenode grew. There was no database operation when we did this, no other client connections except the one that does the vacuum. If we do plain simple "vacuum " (again no full), we see pg_statistics_relid_att_index relfilenode grew instead of pg_statistics. So, overtime, these files will grow if we do vacuum. Are these expected ? The question now is, if we are not doing anything to the database, why would they grow after a few vacuums ? 2.) The other problem we have with > DETAIL: 101802 dead row versions cannot be removed yet. > DETAIL: 110900 dead row versions cannot be removed yet. > DETAIL: 753064 dead row versions cannot be removed yet. > DETAIL: 765328 dead row versions cannot be removed yet. We will collect more data and see what we can get from the the process. Offhand, the process is connecting to the database through ODBC and we don't use any BEGIN in our updates, just doing plain UPDATE repeatedly with different keys randomly. The database is defaulted to autocommit=true in postgresql.conf. Thanks. Gan At 5:25 pm -0400 2003/10/20, Tom Lane wrote: >Seum-Lim Gan writes: >> We tried one more thing: with the table not being updated >> at all and we did vacuum. Each time a vacuum is done, >> the index file becomes bigger. > >It is not possible for plain vacuum to make the index bigger. > >VACUUM FULL possibly could make the index bigger, since it has to >transiently create duplicate index entries for every row it moves. > >If you want any really useful comments on your situation, you're going >to have to offer considerably more detail than you have done so far --- >preferably, a test case that lets someone else reproduce your results. >So far, all we can do is guess on the basis of very incomplete >information. When you aren't even bothering to mention whether a vacuum >is FULL or not, I have to wonder whether I have any realistic picture of >what's going on. > > regards, tom lane > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster -- +--------------------------------------------------------+ | Seum-Lim GAN email : slgan@lucent.com | | Lucent Technologies | | 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | | Naperville, IL 60566, USA. fax : (630)-713-7272 | | web : http://inuweb.ih.lucent.com/~slgan | +--------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Fri Oct 24 15:01: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 1C4E8D1B4F8 for ; Tue, 21 Oct 2003 16:44: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 04526-01 for ; Tue, 21 Oct 2003 13:43:47 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id E7817D1B4E5 for ; Tue, 21 Oct 2003 13:43:46 -0300 (ADT) 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 h9LGhkNu038124 for ; Tue, 21 Oct 2003 16:43:46 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9LGPtcq035214 for pgsql-performance@postgresql.org; Tue, 21 Oct 2003 16:25:55 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 09:25:56 -0700 Organization: Hub.Org Networking Services Lines: 38 Message-ID: References: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.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: <2F2E24372F10744588A27DEECC85FE04B6769C@vt-pe2550-001.vantage.vantage.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/625 X-Sequence-Number: 4373 Anjan Dave wrote: > Shared_buffers (25% of RAM / 8KB)) = 8589934592 * .25 / 8192 = 262144 250,000 is probably the max you can use due to the 2GB process limit unless you recompile the Linux Kernel to use 3GB process/1GB kernel. Yes, I've got 8GB also and I started at 262144 and kept working my way down until Linux would allocate the memory. > > Sort_mem (4% of RAM / 1KB) = 335544. We'll take about half of that - 167772 > > Effective_cache_size = 262144 (same as shared_buffers - 25%) This should reflect the amount of memory available for caching. And unless you plan on running a ton of memory hogging software on the same machine, you probably will have 6GB available as cache. Top on my system confirms the 6GB number so I've got my setting at 750,000. (Left a little space for OS/programs/etc.) > In the /etc/sysctl file: > ================= > kernel.shmall = 536870912 (512MB) SHMALL Total amount of shared memory > available (bytes or pages) > kernel.shmmax = 536870912 (512MB) SHMMAX Maximum size of shared memory > segment (bytes) Ain't gonna happen unless you recompile the linux kernel to do 3/1. Through trial-and-error, I've found the largest number is: 2,147,483,648 > Are the above settings ok to begin with? Are there any other parameters > that I should configure now, or monitor lateron? Above is pretty good. I'd also bump up the free space map settings and maybe try to symlink the pg_xlog directory (log files) to a seperate drive. From pgsql-performance-owner@postgresql.org Tue Oct 21 14:11: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 A6645D1B4E6 for ; Tue, 21 Oct 2003 17:11: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 05481-07 for ; Tue, 21 Oct 2003 14:10:31 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9B858D1B4E1 for ; Tue, 21 Oct 2003 14:10:29 -0300 (ADT) 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: Tuning for mid-size server Date: Tue, 21 Oct 2003 12:26:09 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04D27FBF@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tuning for mid-size server Thread-Index: AcOX6/26X5X4vApJQ/qVLWpD2t9vHwAA1j5g From: "Anjan Dave" To: "Richard Huxton" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/539 X-Sequence-Number: 4287 =46rom what I know, there is a cache-row-set functionality that doesn't exist with the newer postgres... Concurrent users will start from 1 to a high of 5000 or more, and could ramp up rapidly. So far, with increased users, we have gone up to starting the JVM (resin startup) with 1024megs min and max (recommended by Sun) - on the app side. Thanks, Anjan=20 -----Original Message----- From: Richard Huxton [mailto:dev@archonet.com]=20 Sent: Tuesday, October 21, 2003 11:57 AM To: Anjan Dave; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Tuning for mid-size server On Tuesday 21 October 2003 15:28, Anjan Dave wrote: > Hi, > > Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory,=20 > with internal drives on RAID5 will be delivered. Postgres will be from > RH8.0. You'll want to upgrade PG to v7.3.4 > I am planning for these values for the postgres configuration - to=20 > begin > with: > > Shared_buffers (25% of RAM / 8KB)) =3D 8589934592 * .25 / 8192 =3D 262144 > > Sort_mem (4% of RAM / 1KB) =3D 335544. We'll take about half of that -=20 > 167772 > > Effective_cache_size =3D 262144 (same as shared_buffers - 25%) My instincts would be to lower the first two substantially, and increase the=20 effective cache once you know load levels. I'd probably start with something=20 like the values below and work up: shared_buffers =3D 8,000 - 10,000 (PG is happier letting the OS do the cacheing) sort_mem =3D 4,000 - 8,000 (don't forget this is for each sort) You'll find the annotated postgresql.conf and performance tuning articles=20 useful: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > In a generic sense, these are recommended values I found in some=20 > documents. The database will be small in size and will gradually grow=20 > over time from few thousands to a few million records, or more. The=20 > activity will be mostly of select statements from a few tables with=20 > joins, orderby, groupby clauses. The web application is based on=20 > Apache/Resin and hotspot JVM 1.4.0. You'll need to figure out how many concurrent users you'll have and how much=20 memory will be required by apache/java. If your database grows radically,=20 you'll probably want to re-tune as it grows. --=20 Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Tue Oct 21 13:43: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 7D89ED1B4E6 for ; Tue, 21 Oct 2003 16:43: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 04204-03 for ; Tue, 21 Oct 2003 13:43:18 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 7154AD1B51E for ; Tue, 21 Oct 2003 13:43:17 -0300 (ADT) 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 h9LGgtit004251; Tue, 21 Oct 2003 12:42:55 -0400 (EDT) To: Seum-Lim Gan Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: index file bloating still in 7.4 ? In-reply-to: References: <19692.1066578442@sss.pgh.pa.us> <200310191204.23888.josh@agliodbs.com> <15841.1066685113@sss.pgh.pa.us> Comments: In-reply-to Seum-Lim Gan message dated "Tue, 21 Oct 2003 11:25:33 -0500" Date: Tue, 21 Oct 2003 12:42:55 -0400 Message-ID: <4250.1066754575@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/536 X-Sequence-Number: 4284 Seum-Lim Gan writes: > We did a few (like 5 to 8 times) vacuum analyze (no full), the > pg_statistics relfilenode grew. Well, sure. ANALYZE puts new rows into pg_statistic, and obsoletes old ones. You need to vacuum pg_statistic every so often (not to mention the other system catalogs). > If we do plain simple "vacuum " (again no full), we see > pg_statistics_relid_att_index relfilenode grew instead of > pg_statistics. Don't think I believe that. Plain vacuum won't touch pg_statistic at all (unless it's the target table of course). I'd expect ANALYZE to make both the stats table and its index grow, though. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 21 14:04: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 89075D1B4F8 for ; Tue, 21 Oct 2003 17:04: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 06137-07 for ; Tue, 21 Oct 2003 14:03:32 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 60508D1B4E1 for ; Tue, 21 Oct 2003 14:03:31 -0300 (ADT) 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 h9LGxcOk005091; Tue, 21 Oct 2003 10:59:38 -0600 (MDT) Date: Tue, 21 Oct 2003 10:48:33 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: Anjan Dave , Subject: Re: Tuning for mid-size server In-Reply-To: <200310210920.44890.josh@agliodbs.com> 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: 200310/538 X-Sequence-Number: 4286 On Tue, 21 Oct 2003, Josh Berkus wrote: > Anjan, > > > Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory, with > > internal drives on RAID5 will be delivered. Postgres will be from RH8.0. > > How many drives? RAID5 sucks for heavy read-write databases, unless you have > 5+ drives. Or a large battery-backed cache. You don't need a large cache, so much as a cache. The size isn't usually an issue now that 64 to 256 megs caches are the nominal cache sizes. Back when it was a choice of 4 or 8 megs it made a much bigger difference than 64 versus 256 meg make today. Also, if it's a read only environment, RAID5 with n drives equals the performance of RAID0 with n-1 drives. > Also, last I checked, you can't address 8GB of RAM without a 64-bit processor. > Since when are the Xeons 64-bit? Josh, you gotta get out more. IA32 has supported >4 gig ram for a long time now, and so has the linux kernel. It uses a paging method to do it. Individual processes are still limited to ~3 gig on Linux on 32 bit hardware though, so the extra mem will almost certainly spend it's time as kernel cache. From pgsql-performance-owner@postgresql.org Tue Oct 21 14:01: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 476BDD1B4F8 for ; Tue, 21 Oct 2003 17:01: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 06137-04 for ; Tue, 21 Oct 2003 14:00:45 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1E137D1B4E6 for ; Tue, 21 Oct 2003 14:00:44 -0300 (ADT) 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 h9LH0git004406; Tue, 21 Oct 2003 13:00:42 -0400 (EDT) To: "Harry Broomhall" Cc: josh@agliodbs.com (Josh Berkus), pgsql-performance@postgresql.org Subject: Re: Performance weirdness with/without vacuum analyze In-reply-to: <200310211140.MAA15046@haeb.noc.uk.easynet.net> References: <200310211140.MAA15046@haeb.noc.uk.easynet.net> Comments: In-reply-to Harry Broomhall message dated "Tue, 21 Oct 2003 12:40:26 +0100" Date: Tue, 21 Oct 2003 13:00:41 -0400 Message-ID: <4405.1066755641@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/537 X-Sequence-Number: 4285 Harry Broomhall writes: > -> Index Scan using import_cdrs_cdr_id_key on import_cdrs (cost=0.00..52.00 rows=1000 width=164) (actual time=0.42..11479.51 rows=335671 loops=1) > -> Seq Scan on import_cdrs (cost=0.00..8496.71 rows=335671 width=126) (actual time=0.15..9504.24 rows=335671 loops=1) Hm. The planner's default cost parameters assume that a full-table index scan will be much slower than a full-table seq scan. That's evidently not the case in your test situation. You could probably bring the estimates more in line with reality (and thereby improve the choice of plan) by reducing random_page_cost towards 1 and increasing effective_cache_size to represent some realistic fraction of your available RAM (though I concur with your observation that the latter doesn't change the estimates all that much). Beware however that test-case reality and production reality are not the same thing. You are evidently testing with tables that fit in RAM. If your production tables will not, you'd better be wary of being overly aggressive about reducing random_page_cost. I believe the default value (4.0) is fairly representative for situations where many actual disk fetches are needed, ie, the tables are much larger than RAM. 1.0 would be appropriate if all your tables are always fully cached in RAM (since RAM has by definition no random-access penalty). In intermediate cases you need to select intermediate values. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 21 14:11: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 B92BCD1B4F8 for ; Tue, 21 Oct 2003 17:11: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 05272-09 for ; Tue, 21 Oct 2003 14:10:34 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 17DD5D1B4E5 for ; Tue, 21 Oct 2003 14:10:31 -0300 (ADT) 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: Tuning for mid-size server Date: Tue, 21 Oct 2003 13:02:08 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tuning for mid-size server Thread-Index: AcOX72BiYRaXjSZKTQqV90EKuzOV/wAAM9Bw From: "Anjan Dave" To: "Josh Berkus" , Cc: "Anjan Dave" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/540 X-Sequence-Number: 4288 Josh, The 6650 can have upto 32GB of RAM. There are 5 drives. In future, they will be replaced by a fiber array - hopefully. I read an article that suggests you 'start' with 25% of memory for shared_buffers. Sort memory was suggested to be at 2-4%. Here's the link: http://www.ca.postgresql.org/docs/momjian/hw_performance/node8.html Maybe, I misinterpreted it. I read the document on http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html and the suggested values are much lower than what I have mentioned here. It won't hurt to start with lower numbers and increase lateron if needed. Thanks, Anjan=20 -----Original Message----- From: Josh Berkus [mailto:josh@agliodbs.com]=20 Sent: Tuesday, October 21, 2003 12:21 PM To: Anjan Dave; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Tuning for mid-size server Anjan, > Pretty soon, a PowerEdge 6650 with 4 x 2Ghz XEONs, and 8GB Memory,=20 > with internal drives on RAID5 will be delivered. Postgres will be from > RH8.0. How many drives? RAID5 sucks for heavy read-write databases, unless you have=20 5+ drives. Or a large battery-backed cache. Also, last I checked, you can't address 8GB of RAM without a 64-bit processor.=20=20 Since when are the Xeons 64-bit? > Shared_buffers (25% of RAM / 8KB)) =3D 8589934592 * .25 / 8192 =3D 262144 That's too high. Cut it in half at least. Probably down to 5% of available=20 RAM. > Sort_mem (4% of RAM / 1KB) =3D 335544. We'll take about half of that -=20 > 167772 Fine if you're running a few-user-large-operation database. If this is a=20 webserver, you want a much, much lower value. > Effective_cache_size =3D 262144 (same as shared_buffers - 25%) Much too low. Where did you get these calculations, anyway? > In a generic sense, these are recommended values I found in some=20 > documents. Where? We need to contact the author of the "documents" and tell them to=20 correct things. > joins, orderby, groupby clauses. The web application is based on=20 > Apache/Resin and hotspot JVM 1.4.0. You'll need to estimate the memory consumed by Java & Apache to have realistic=20 figures to work with. > Are the above settings ok to begin with? Are there any other=20 > parameters that I should configure now, or monitor lateron? No, they're not. See: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html to tune these=20 parameters. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 14:13: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 4EE25D1B51E for ; Tue, 21 Oct 2003 17:13: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 06093-09 for ; Tue, 21 Oct 2003 14:12:59 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4DE75D1B4E1 for ; Tue, 21 Oct 2003 14:12:58 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801908; Tue, 21 Oct 2003 10:13:34 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "scott.marlowe" Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 10:12:15 -0700 User-Agent: KMail/1.4.3 Cc: Anjan Dave , References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310211012.15845.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/541 X-Sequence-Number: 4289 Scott, > Also, if it's a read only environment, RAID5 with n drives equals the > performance of RAID0 with n-1 drives. True. > Josh, you gotta get out more. IA32 has supported >4 gig ram for a long > time now, and so has the linux kernel. It uses a paging method to do it. > Individual processes are still limited to ~3 gig on Linux on 32 bit > hardware though, so the extra mem will almost certainly spend it's time as > kernel cache. Not that you'd want a sigle process to grow that large anyway. So what is the ceiling on 32-bit processors for RAM? Most of the 64-bit vendors are pushing Athalon64 and G5 as "breaking the 4GB barrier", and even I can do the math on 2^32. All these 64-bit vendors, then, are talking about the limit on ram *per application* and not per machine? This has all been academic to me to date, as the only very-high-ram systems I've worked with were Sparc or micros. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 14:15: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 2F1B5D1B518 for ; Tue, 21 Oct 2003 17:15: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 06093-10 for ; Tue, 21 Oct 2003 14:14:36 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 3D90FD1B52D for ; Tue, 21 Oct 2003 14:14:35 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801916; Tue, 21 Oct 2003 10:15:12 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rhaoni Chiu Pereira Subject: Re: Low Insert/Update Performance Date: Tue, 21 Oct 2003 10:13:53 -0700 User-Agent: KMail/1.4.3 References: <1066659206.3f93ed86b9907@sistemica.info> <200310201007.48534.josh@agliodbs.com> <1066756132.3f95682499d8d@sistemica.info> In-Reply-To: <1066756132.3f95682499d8d@sistemica.info> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310211013.53997.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/542 X-Sequence-Number: 4290 Rhaoni, > The delphi program does just one commit for all queries . > I was wandering if ther is some configuration parameters to be changed to > improve the performance ? To help you, we'll need to to trap a query and run an EXPLAIN ANALYZE on it. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 14:17: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 B68DED1B508 for ; Tue, 21 Oct 2003 17:17: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 12473-01 for ; Tue, 21 Oct 2003 14:16:39 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D8C48D1B4FD for ; Tue, 21 Oct 2003 14:16:37 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801933; Tue, 21 Oct 2003 10:17:16 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Anjan Dave" , Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 10:15:57 -0700 User-Agent: KMail/1.4.3 References: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310211015.57569.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/543 X-Sequence-Number: 4291 Anjan, > I read an article that suggests you 'start' with 25% of memory for > shared_buffers. Sort memory was suggested to be at 2-4%. Here's the > link: > http://www.ca.postgresql.org/docs/momjian/hw_performance/node8.html > Maybe, I misinterpreted it. No, I can see how you arrived at that conclusion, and Bruce is an authority. I'll contact him. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 14:24: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 44D4FD1B51A for ; Tue, 21 Oct 2003 17:24: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 06982-04 for ; Tue, 21 Oct 2003 14:23:30 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 41491D1B4F8 for ; Tue, 21 Oct 2003 14:23:29 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3801980; Tue, 21 Oct 2003 10:24:08 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Anjan Dave" , "Richard Huxton" , Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 10:22:49 -0700 User-Agent: KMail/1.4.3 References: <2F2E24372F10744588A27DEECC85FE04D27FBF@vt-pe2550-001.vantage.vantage.com> In-Reply-To: <2F2E24372F10744588A27DEECC85FE04D27FBF@vt-pe2550-001.vantage.vantage.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310211022.49356.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/544 X-Sequence-Number: 4292 Anjan, > From what I know, there is a cache-row-set functionality that doesn't > exist with the newer postgres... What? PostgreSQL has always used the kernel cache for queries. > Concurrent users will start from 1 to a high of 5000 or more, and could > ramp up rapidly. So far, with increased users, we have gone up to > starting the JVM (resin startup) with 1024megs min and max (recommended > by Sun) - on the app side. Well, just keep in mind when tuning that your calculations should be based on *available* RAM, meaning RAM not used by Apache or the JVM. With that many concurrent requests, you'll want to be *very* conservative with sort_mem; I might stick to the default of 1024 if I were you, or even lower it to 512k. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 14:43: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 63293D1B518 for ; Tue, 21 Oct 2003 17:43: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 06761-10 for ; Tue, 21 Oct 2003 14:43:14 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 37FF2D1B531 for ; Tue, 21 Oct 2003 14:43:13 -0300 (ADT) 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 h9LHffOk007936; Tue, 21 Oct 2003 11:41:41 -0600 (MDT) Date: Tue, 21 Oct 2003 11:30:36 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: Anjan Dave , Subject: Re: Tuning for mid-size server In-Reply-To: <200310211012.15845.josh@agliodbs.com> 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: 200310/545 X-Sequence-Number: 4293 On Tue, 21 Oct 2003, Josh Berkus wrote: > Scott, > > > Also, if it's a read only environment, RAID5 with n drives equals the > > performance of RAID0 with n-1 drives. > > True. > > > Josh, you gotta get out more. IA32 has supported >4 gig ram for a long > > time now, and so has the linux kernel. It uses a paging method to do it. > > Individual processes are still limited to ~3 gig on Linux on 32 bit > > hardware though, so the extra mem will almost certainly spend it's time as > > kernel cache. > > Not that you'd want a sigle process to grow that large anyway. True :-) Especially a pgsql backend. > So what is the ceiling on 32-bit processors for RAM? Most of the 64-bit > vendors are pushing Athalon64 and G5 as "breaking the 4GB barrier", and even > I can do the math on 2^32. All these 64-bit vendors, then, are talking > about the limit on ram *per application* and not per machine? I think it's 64 gigs in the current implementation, but that could just be a chip set thing, i.e. the theoretical limit is probably 2^63 or 2^64, but the realistic limitation is that the current mobo chipsets are gonna have a much lower limit, and I seem to recall that being 64 gig last I looked. From pgsql-performance-owner@postgresql.org Tue Oct 21 14:47: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 C6CF9D1B4F8 for ; Tue, 21 Oct 2003 17:47: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 14530-02 for ; Tue, 21 Oct 2003 14:46:50 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id CE32ED1B524 for ; Tue, 21 Oct 2003 14:46:48 -0300 (ADT) 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 h9LHimOk008107; Tue, 21 Oct 2003 11:44:48 -0600 (MDT) Date: Tue, 21 Oct 2003 11:33:43 -0600 (MDT) From: "scott.marlowe" To: Josh Berkus Cc: Anjan Dave , Richard Huxton , Subject: Re: Tuning for mid-size server In-Reply-To: <200310211022.49356.josh@agliodbs.com> 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: 200310/546 X-Sequence-Number: 4294 On Tue, 21 Oct 2003, Josh Berkus wrote: > Anjan, > > > From what I know, there is a cache-row-set functionality that doesn't > > exist with the newer postgres... > > What? PostgreSQL has always used the kernel cache for queries. > > > Concurrent users will start from 1 to a high of 5000 or more, and could > > ramp up rapidly. So far, with increased users, we have gone up to > > starting the JVM (resin startup) with 1024megs min and max (recommended > > by Sun) - on the app side. > > Well, just keep in mind when tuning that your calculations should be based on > *available* RAM, meaning RAM not used by Apache or the JVM. > > With that many concurrent requests, you'll want to be *very* conservative with > sort_mem; I might stick to the default of 1024 if I were you, or even lower > it to 512k. Exactly. Remember, Anjan, that that if you have a single sort that can't fit in RAM, it will use the hard drive for temp space, effectively "swapping" on its own. If the concurrent sorts run the server out of memory, the server will start swapping process, quite possibly the sorts, in a sort of hideous round robin death spiral that will bring your machine to its knees as the worst possible time, midday under load. sort_mem is one of the small "foot guns" in the postgresql.conf file that people tend to pick up and go "huh, what's this do?" right before cranking it up. From pgsql-performance-owner@postgresql.org Tue Oct 21 14:49: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 C30B8D1B51E for ; Tue, 21 Oct 2003 17:49: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 15273-03 for ; Tue, 21 Oct 2003 14:48:53 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 5741DD1B51A for ; Tue, 21 Oct 2003 14:48:52 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AC0cm-0004mQ-00 for ; Tue, 21 Oct 2003 13:48:52 -0400 Received: by dba2 (Postfix, from userid 1019) id C0557CD6A; Tue, 21 Oct 2003 13:48:52 -0400 (EDT) Date: Tue, 21 Oct 2003 13:48:52 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Message-ID: <20031021174852.GG11421@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200310211012.15845.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310211012.15845.josh@agliodbs.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/547 X-Sequence-Number: 4295 On Tue, Oct 21, 2003 at 10:12:15AM -0700, Josh Berkus wrote: > > So what is the ceiling on 32-bit processors for RAM? Most of the 64-bit > vendors are pushing Athalon64 and G5 as "breaking the 4GB barrier", and even > I can do the math on 2^32. All these 64-bit vendors, then, are talking > about the limit on ram *per application* and not per machine? Or per same-time access. Remember that, back in the old days on the pre-386s, accessing the extended or expanded memory (anyone remember which was which?) involved some fairly serious work, and not everything was seamless. I expect something similar is at work here. Not that I've had a reason to play with 4G ix86 machines, anyway. 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 Tue Oct 21 14:50: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 70599D1B51A for ; Tue, 21 Oct 2003 17:50: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 14289-07 for ; Tue, 21 Oct 2003 14:50:27 -0300 (ADT) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 4DDFED1B509 for ; Tue, 21 Oct 2003 14:50:17 -0300 (ADT) Received: (qmail 27423 invoked from network); 21 Oct 2003 17:50:24 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 21 Oct 2003 17:50:24 -0000 Date: Tue, 21 Oct 2003 13:50:15 -0400 From: Jeff To: Josh Berkus Cc: scott.marlowe@ihs.com, adave@vantage.com, pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Message-Id: <20031021135015.15bb8bb5.threshar@torgo.978.org> In-Reply-To: <200310211012.15845.josh@agliodbs.com> References: <200310211012.15845.josh@agliodbs.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: 200310/549 X-Sequence-Number: 4297 On Tue, 21 Oct 2003 10:12:15 -0700 Josh Berkus wrote: > So what is the ceiling on 32-bit processors for RAM? Most of the > 64-bit vendors are pushing Athalon64 and G5 as "breaking the 4GB > barrier", and even I can do the math on 2^32. All these 64-bit > vendors, then, are talking about the limit on ram *per application* > and not per machine? You can have > 4GB per app, but also you get a big performance boost as you don't have to deal with all the silly paging - think of it from when we switched from real mode to protected mode. If you check out hte linux-kernel archives you'll see one of the things often recommended when things go odd is to turn off HIMEM support. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 21 14:50: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 65A97D1B4E6 for ; Tue, 21 Oct 2003 17:50: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 15825-02 for ; Tue, 21 Oct 2003 14:50:17 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 5A353D1B4F8 for ; Tue, 21 Oct 2003 14:50:16 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AC0e9-0004ni-00 for ; Tue, 21 Oct 2003 13:50:17 -0400 Received: by dba2 (Postfix, from userid 1019) id 130CBCD6A; Tue, 21 Oct 2003 13:50:17 -0400 (EDT) Date: Tue, 21 Oct 2003 13:50:17 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Message-ID: <20031021175016.GH11421@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> <200310211015.57569.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310211015.57569.josh@agliodbs.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/548 X-Sequence-Number: 4296 On Tue, Oct 21, 2003 at 10:15:57AM -0700, Josh Berkus wrote: > Anjan, > > > I read an article that suggests you 'start' with 25% of memory for > > shared_buffers. Sort memory was suggested to be at 2-4%. Here's the > > link: > > http://www.ca.postgresql.org/docs/momjian/hw_performance/node8.html > > Maybe, I misinterpreted it. > > No, I can see how you arrived at that conclusion, and Bruce is an authority. > I'll contact him. I think the "25%" rule of thumb is slightly stale: above some threshold, it just falls apart, and lots of people now have machines well within that threshold. Heck, I'll bet Bruce's 2-way machine is within that threshold. 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 Oct 24 14:57: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 20B33D1B570 for ; Tue, 21 Oct 2003 18:44: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 25821-07 for ; Tue, 21 Oct 2003 15:43:50 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 75FBFD1B50C for ; Tue, 21 Oct 2003 15:43:49 -0300 (ADT) 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 h9LIhmNw059545 for ; Tue, 21 Oct 2003 18:43:49 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9LIR9KH056093 for pgsql-performance@postgresql.org; Tue, 21 Oct 2003 18:27:09 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 11:27:08 -0700 Organization: Hub.Org Networking Services Lines: 14 Message-ID: References: <200310211012.15845.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: <200310211012.15845.josh@agliodbs.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/622 X-Sequence-Number: 4370 > So what is the ceiling on 32-bit processors for RAM? Most of the 64-bit > vendors are pushing Athalon64 and G5 as "breaking the 4GB barrier", and even > I can do the math on 2^32. All these 64-bit vendors, then, are talking > about the limit on ram *per application* and not per machine? 64-bit CPU on 64-bit OS. Up to physical address limit for anything and everything. 64-bit CPU on 32-bit OS. Up to 4GB minus the kernel allocation -- which is usually 2GB on Windows and Linux. On Windows, you can up this to 3GB by using the /3GB switch. Linux requires a kernel recompile. PAE is then used to "move" the memory window to point to different areas of the physical memory. From pgsql-performance-owner@postgresql.org Tue Oct 21 15:44: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 6639FD1B56A for ; Tue, 21 Oct 2003 18:44: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 27216-02 for ; Tue, 21 Oct 2003 15:43:49 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 4ED62D1B548 for ; Tue, 21 Oct 2003 15:43:47 -0300 (ADT) 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 h9LIhmit005141 for ; Tue, 21 Oct 2003 14:43:48 -0400 (EDT) To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server In-reply-to: <20031021175016.GH11421@libertyrms.info> References: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> <200310211015.57569.josh@agliodbs.com> <20031021175016.GH11421@libertyrms.info> Comments: In-reply-to Andrew Sullivan message dated "Tue, 21 Oct 2003 13:50:17 -0400" Date: Tue, 21 Oct 2003 14:43:47 -0400 Message-ID: <5140.1066761827@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/550 X-Sequence-Number: 4298 Andrew Sullivan writes: > I think the "25%" rule of thumb is slightly stale: above some > threshold, it just falls apart, and lots of people now have machines > well within that threshold. Heck, I'll bet Bruce's 2-way machine is > within that threshold. IIRC, we've not seen much evidence that increasing shared_buffers above about 10000 delivers any performance boost. That's 80Mb, so the "25%" rule doesn't get seriously out of whack until you get to a gig or so of RAM. Which was definitely not common at the time the rule was put forward, but is now. Probably we should modify the rule-of-thumb to something like "25%, but not more than 10000 buffers". regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 21 15:54: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 110F9D1B510 for ; Tue, 21 Oct 2003 18:54: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 26521-10 for ; Tue, 21 Oct 2003 15:53:34 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 0BCC2D1B527 for ; Tue, 21 Oct 2003 15:53:29 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3802455; Tue, 21 Oct 2003 11:54:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Andrew Sullivan , pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 11:51:02 -0700 User-Agent: KMail/1.4.3 References: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> <200310211015.57569.josh@agliodbs.com> <20031021175016.GH11421@libertyrms.info> In-Reply-To: <20031021175016.GH11421@libertyrms.info> Cc: Bruce Momjian MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310211151.02751.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/551 X-Sequence-Number: 4299 Andrew, > I think the "25%" rule of thumb is slightly stale: above some > threshold, it just falls apart, and lots of people now have machines > well within that threshold. Heck, I'll bet Bruce's 2-way machine is > within that threshold. Sure. But we had a few people on this list do tests (including me) and the= =20 anecdotal evidence was lower than 25%, substantially. The falloff is subt= le=20 until you hit 50% of RAM, like: % query throughput 1 ---- 5 --------- 10 ----------- 15 ---------- 20 ---------- 25 --------- 30 -------- 35 -------- 40 ------- ... so it's often not immediately apparent when you've set stuff a little t= oo=20 high. However, in the folks that tested, the ideal was never anywhere ne= ar=20 25%, usually more in the realm of 5-10%. I've been using 6% as my starting= =20 figure for the last year for a variety of servers with good results. Of course, if you have anecdotal evidence to the contrary, then the only wa= y=20 to work this would be to have OSDL help us sort it out. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 16:52: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 A5A80D1B531 for ; Tue, 21 Oct 2003 19:52: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 36498-05 for ; Tue, 21 Oct 2003 16:52:01 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1C81CD1B50C for ; Tue, 21 Oct 2003 16:51:57 -0300 (ADT) 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="utf-8" Content-Transfer-Encoding: base64 Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 14:53:03 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04B676A0@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tuning for mid-size server Thread-Index: AcOX+072OQXaD6a0Q+CZ9g7j2MSjRAACQRfl From: "Anjan Dave" To: "scott.marlowe" , "Josh Berkus" Cc: "Richard Huxton" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/556 X-Sequence-Number: 4304 SG9wZWZ1bGx5LCBpIGFtIG5vdCBzdGVlcmluZyB0aGlzIGludG8gYSBkaWZm ZXJlbnQgZGlyZWN0aW9uLCBidXQgaXMgdGhlcmUgYSB3YXkgdG8gZmluZCBv dXQgaG93IG11Y2ggc29ydCBtZW1vcnkgZWFjaCBxdWVyeSBpcyB0YWtpbmcg dXAsIHNvIHRoYXQgd2UgY2FuIHNjYWxlIHRoYXQgdXAgd2l0aCBpbmNyZWFz aW5nIHVzZXJzPw0KDQpUSGFua3MsDQpBbmphbg0KDQoJLS0tLS1PcmlnaW5h bCBNZXNzYWdlLS0tLS0gDQoJRnJvbTogc2NvdHQubWFybG93ZSBbbWFpbHRv OnNjb3R0Lm1hcmxvd2VAaWhzLmNvbV0gDQoJU2VudDogVHVlIDEwLzIxLzIw MDMgMTozMyBQTSANCglUbzogSm9zaCBCZXJrdXMgDQoJQ2M6IEFuamFuIERh dmU7IFJpY2hhcmQgSHV4dG9uOyBwZ3NxbC1wZXJmb3JtYW5jZUBwb3N0Z3Jl c3FsLm9yZyANCglTdWJqZWN0OiBSZTogW1BFUkZPUk1dIFR1bmluZyBmb3Ig bWlkLXNpemUgc2VydmVyDQoJDQoJDQoNCglPbiBUdWUsIDIxIE9jdCAyMDAz LCBKb3NoIEJlcmt1cyB3cm90ZToNCgkNCgk+IEFuamFuLA0KCT4NCgk+ID4g RnJvbSB3aGF0IEkga25vdywgdGhlcmUgaXMgYSBjYWNoZS1yb3ctc2V0IGZ1 bmN0aW9uYWxpdHkgdGhhdCBkb2Vzbid0DQoJPiA+IGV4aXN0IHdpdGggdGhl IG5ld2VyIHBvc3RncmVzLi4uDQoJPg0KCT4gV2hhdD8gIFBvc3RncmVTUUwg aGFzIGFsd2F5cyB1c2VkIHRoZSBrZXJuZWwgY2FjaGUgZm9yIHF1ZXJpZXMu DQoJPg0KCT4gPiBDb25jdXJyZW50IHVzZXJzIHdpbGwgc3RhcnQgZnJvbSAx IHRvIGEgaGlnaCBvZiA1MDAwIG9yIG1vcmUsIGFuZCBjb3VsZA0KCT4gPiBy YW1wIHVwIHJhcGlkbHkuIFNvIGZhciwgd2l0aCBpbmNyZWFzZWQgdXNlcnMs IHdlIGhhdmUgZ29uZSB1cCB0bw0KCT4gPiBzdGFydGluZyB0aGUgSlZNIChy ZXNpbiBzdGFydHVwKSB3aXRoIDEwMjRtZWdzIG1pbiBhbmQgbWF4IChyZWNv bW1lbmRlZA0KCT4gPiBieSBTdW4pIC0gb24gdGhlIGFwcCBzaWRlLg0KCT4N Cgk+IFdlbGwsIGp1c3Qga2VlcCBpbiBtaW5kIHdoZW4gdHVuaW5nIHRoYXQg eW91ciBjYWxjdWxhdGlvbnMgc2hvdWxkIGJlIGJhc2VkIG9uDQoJPiAqYXZh aWxhYmxlKiBSQU0sIG1lYW5pbmcgUkFNIG5vdCB1c2VkIGJ5IEFwYWNoZSBv ciB0aGUgSlZNLg0KCT4NCgk+IFdpdGggdGhhdCBtYW55IGNvbmN1cnJlbnQg cmVxdWVzdHMsIHlvdSdsbCB3YW50IHRvIGJlICp2ZXJ5KiBjb25zZXJ2YXRp dmUgd2l0aA0KCT4gc29ydF9tZW07IEkgbWlnaHQgc3RpY2sgdG8gdGhlIGRl ZmF1bHQgb2YgMTAyNCBpZiBJIHdlcmUgeW91LCBvciBldmVuIGxvd2VyDQoJ PiBpdCB0byA1MTJrLg0KCQ0KCUV4YWN0bHkuICBSZW1lbWJlciwgQW5qYW4s IHRoYXQgdGhhdCBpZiB5b3UgaGF2ZSBhIHNpbmdsZSBzb3J0IHRoYXQgY2Fu J3QNCglmaXQgaW4gUkFNLCBpdCB3aWxsIHVzZSB0aGUgaGFyZCBkcml2ZSBm b3IgdGVtcCBzcGFjZSwgZWZmZWN0aXZlbHkNCgkic3dhcHBpbmciIG9uIGl0 cyBvd24uICBJZiB0aGUgY29uY3VycmVudCBzb3J0cyBydW4gdGhlIHNlcnZl ciBvdXQgb2YNCgltZW1vcnksIHRoZSBzZXJ2ZXIgd2lsbCBzdGFydCBzd2Fw cGluZyBwcm9jZXNzLCBxdWl0ZSBwb3NzaWJseSB0aGUgc29ydHMsDQoJaW4g YSBzb3J0IG9mIGhpZGVvdXMgcm91bmQgcm9iaW4gZGVhdGggc3BpcmFsIHRo YXQgd2lsbCBicmluZyB5b3VyIG1hY2hpbmUNCgl0byBpdHMga25lZXMgYXMg dGhlIHdvcnN0IHBvc3NpYmxlIHRpbWUsIG1pZGRheSB1bmRlciBsb2FkLiAg c29ydF9tZW0gaXMNCglvbmUgb2YgdGhlIHNtYWxsICJmb290IGd1bnMiIGlu IHRoZSBwb3N0Z3Jlc3FsLmNvbmYgZmlsZSB0aGF0IHBlb3BsZSB0ZW5kDQoJ dG8gcGljayB1cCBhbmQgZ28gImh1aCwgd2hhdCdzIHRoaXMgZG8/IiByaWdo dCBiZWZvcmUgY3JhbmtpbmcgaXQgdXAuDQoJDQoJDQoNCg== From pgsql-performance-owner@postgresql.org Tue Oct 21 16:52: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 028F3D1B538 for ; Tue, 21 Oct 2003 19:52: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 37695-03 for ; Tue, 21 Oct 2003 16:52:02 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 462EAD1B518 for ; Tue, 21 Oct 2003 16:52:00 -0300 (ADT) 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="utf-8" Content-Transfer-Encoding: base64 Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 14:59:01 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04B6769F@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] Tuning for mid-size server Thread-Index: AcOX+AwqwB/SQM3VSBiovkWWG7GECwADBgH/ From: "Anjan Dave" To: "Josh Berkus" , "Richard Huxton" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/555 X-Sequence-Number: 4303 Sm9zaCwNCiANClRoZSBhcHAgc2VydmVycyBhcmUgc2VwZXJhdGUgZHVhbC1j cHUgYm94ZXMgd2l0aCAyR0IgUkFNIG9uIGVhY2guDQogDQpZZXMsIGZyb20g YWxsIHRoZSByZXNwb25zZXMgaSBoYXZlIHNlZW4sIGkgd2lsbCBiZSByZWR1 Y2luZyB0aGUgbnVtYmVycyB0byB3aGF0IGhhcyBiZWVuIHN1Z2dlc3RlZC4N CiANClRoYW5rcyB0byBhbGwsDQphbmphbg0KDQoJLS0tLS1PcmlnaW5hbCBN ZXNzYWdlLS0tLS0gDQoJRnJvbTogSm9zaCBCZXJrdXMgW21haWx0bzpqb3No QGFnbGlvZGJzLmNvbV0gDQoJU2VudDogVHVlIDEwLzIxLzIwMDMgMToyMiBQ TSANCglUbzogQW5qYW4gRGF2ZTsgUmljaGFyZCBIdXh0b247IHBnc3FsLXBl cmZvcm1hbmNlQHBvc3RncmVzcWwub3JnIA0KCUNjOiANCglTdWJqZWN0OiBS ZTogW1BFUkZPUk1dIFR1bmluZyBmb3IgbWlkLXNpemUgc2VydmVyDQoJDQoJ DQoNCglBbmphbiwNCgkNCgk+IEZyb20gd2hhdCBJIGtub3csIHRoZXJlIGlz IGEgY2FjaGUtcm93LXNldCBmdW5jdGlvbmFsaXR5IHRoYXQgZG9lc24ndA0K CT4gZXhpc3Qgd2l0aCB0aGUgbmV3ZXIgcG9zdGdyZXMuLi4NCgkNCglXaGF0 PyAgUG9zdGdyZVNRTCBoYXMgYWx3YXlzIHVzZWQgdGhlIGtlcm5lbCBjYWNo ZSBmb3IgcXVlcmllcy4NCgkNCgk+IENvbmN1cnJlbnQgdXNlcnMgd2lsbCBz dGFydCBmcm9tIDEgdG8gYSBoaWdoIG9mIDUwMDAgb3IgbW9yZSwgYW5kIGNv dWxkDQoJPiByYW1wIHVwIHJhcGlkbHkuIFNvIGZhciwgd2l0aCBpbmNyZWFz ZWQgdXNlcnMsIHdlIGhhdmUgZ29uZSB1cCB0bw0KCT4gc3RhcnRpbmcgdGhl IEpWTSAocmVzaW4gc3RhcnR1cCkgd2l0aCAxMDI0bWVncyBtaW4gYW5kIG1h eCAocmVjb21tZW5kZWQNCgk+IGJ5IFN1bikgLSBvbiB0aGUgYXBwIHNpZGUu DQoJDQoJV2VsbCwganVzdCBrZWVwIGluIG1pbmQgd2hlbiB0dW5pbmcgdGhh dCB5b3VyIGNhbGN1bGF0aW9ucyBzaG91bGQgYmUgYmFzZWQgb24NCgkqYXZh aWxhYmxlKiBSQU0sIG1lYW5pbmcgUkFNIG5vdCB1c2VkIGJ5IEFwYWNoZSBv ciB0aGUgSlZNLg0KCQ0KCVdpdGggdGhhdCBtYW55IGNvbmN1cnJlbnQgcmVx dWVzdHMsIHlvdSdsbCB3YW50IHRvIGJlICp2ZXJ5KiBjb25zZXJ2YXRpdmUg d2l0aA0KCXNvcnRfbWVtOyBJIG1pZ2h0IHN0aWNrIHRvIHRoZSBkZWZhdWx0 IG9mIDEwMjQgaWYgSSB3ZXJlIHlvdSwgb3IgZXZlbiBsb3dlcg0KCWl0IHRv IDUxMmsuDQoJDQoJLS0NCglKb3NoIEJlcmt1cw0KCUFnbGlvIERhdGFiYXNl IFNvbHV0aW9ucw0KCVNhbiBGcmFuY2lzY28NCgkNCg0K From pgsql-performance-owner@postgresql.org Tue Oct 21 16:01: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 93339D1B51A for ; Tue, 21 Oct 2003 19:01: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 26981-09 for ; Tue, 21 Oct 2003 16:00:37 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id 63951D1B510 for ; Tue, 21 Oct 2003 16:00:35 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Tue, 21 Oct 2003 14:00:07 -0500 Subject: Re: PostgreSQL data on a NAS device ? From: Will LaShell To: "scott.marlowe" Cc: Alexander Priem , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-drtyNg+zlfVY3IZReOW+" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 21 Oct 2003 12:00:05 -0700 Message-Id: <1066762807.29522.3.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/552 X-Sequence-Number: 4300 --=-drtyNg+zlfVY3IZReOW+ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-10-21 at 08:40, scott.marlowe wrote: > So that brings up my question, which is better, the Perc4 or Perc3=20 > controllers, and what's the difference between them? I find Dell's=20 > tendency to hide other people's hardware behind their own model numbers= =20 > mildly bothersome, as it makes it hard to comparison shop. Perc4 has n LSI 1030 chip http://docs.us.dell.com/docs/storage/perc4di/en/ug/features.htm Perc3 depending on the model can be a couple of things but I think they are all U160 controllers and not U320 Will --=-drtyNg+zlfVY3IZReOW+ 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/lYI1Zr3R5kgOZd0RAln+AKCKcQyF9uLv3K4Ac6UP+wOlkTpJpwCeOQ3/ 9/qG7gZzGIRWG7+IYtMV3eU= =DTGI -----END PGP SIGNATURE----- --=-drtyNg+zlfVY3IZReOW+-- From pgsql-performance-owner@postgresql.org Tue Oct 21 16: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 6C69DD1B51A for ; Tue, 21 Oct 2003 19:01: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 27788-07 for ; Tue, 21 Oct 2003 16:01:21 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 34DDCD1B50C for ; Tue, 21 Oct 2003 16:01:19 -0300 (ADT) 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 h9LJ0tit005233 for ; Tue, 21 Oct 2003 15:00:55 -0400 (EDT) To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server In-reply-to: <20031021174852.GG11421@libertyrms.info> References: <200310211012.15845.josh@agliodbs.com> <20031021174852.GG11421@libertyrms.info> Comments: In-reply-to Andrew Sullivan message dated "Tue, 21 Oct 2003 13:48:52 -0400" Date: Tue, 21 Oct 2003 15:00:55 -0400 Message-ID: <5232.1066762855@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/553 X-Sequence-Number: 4301 Andrew Sullivan writes: > On Tue, Oct 21, 2003 at 10:12:15AM -0700, Josh Berkus wrote: >> So what is the ceiling on 32-bit processors for RAM? > ... Remember that, back in the old days on the > pre-386s, accessing the extended or expanded memory (anyone remember > which was which?) involved some fairly serious work, and not > everything was seamless. I expect something similar is at work here. Right. A 32-bit processor can only (conveniently) allow any individual process to access 4G worth of address space. However the total RAM in the system can be more --- the kernel can set up the hardware address mappings to let different user processes use different up-to-4G segments of that RAM. And the kernel can also use excess RAM for disk buffer cache. So there's plenty of value in more-than-4G RAM, as long as you're not expecting any single user process to need more than 4G. This is no problem at all for Postgres, in which individual backend processes don't usually get very large, and we'd just as soon let most of the RAM go to kernel disk buffers anyway. I think that some hardware configurations have problems with using RAM above the first 4G for disk buffers, because of disk controller hardware that can't cope with physical DMA addresses wider than 32 bits. The solution here is to buy a better disk controller. If you google for "bounce buffers" you can learn more about this. What goes around comes around I guess --- I remember playing these same kinds of games to use more than 64K RAM in 16-bit machines, 25-odd years ago... regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 21 16:44: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 3410CD1B52D for ; Tue, 21 Oct 2003 19:44: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 36457-06 for ; Tue, 21 Oct 2003 16:43:48 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id DC6AFD1B510 for ; Tue, 21 Oct 2003 16:43:46 -0300 (ADT) 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 h9LJhkNu070630 for ; Tue, 21 Oct 2003 19:43:46 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9LJSMIJ068272 for pgsql-performance@postgresql.org; Tue, 21 Oct 2003 19:28:22 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 15:27:02 -0400 Organization: cbbrowne Computing Inc Lines: 49 Message-ID: References: <200310211012.15845.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:kBl63msqseGPX2PQuCJS12M2oSw= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/554 X-Sequence-Number: 4302 In the last exciting episode, josh@agliodbs.com (Josh Berkus) wrote: > So what is the ceiling on 32-bit processors for RAM? Most of the > 64-bit vendors are pushing Athalon64 and G5 as "breaking the 4GB > barrier", and even I can do the math on 2^32. All these 64-bit > vendors, then, are talking about the limit on ram *per application* > and not per machine? I have been seeing ia-32 servers with 8GB of RAM; it looks as though there are ways of having them support ("physically, in theory, if you could get a suitable motherboard") as much as 64GB. But that certainly doesn't get you past 2^32 bytes per process, and possibly not past 2^31 bytes/process. From Linux kernel help: CONFIG_NOHIGHMEM: Linux can use up to 64 Gigabytes of physical memory on x86 systems. However, the address space of 32-bit x86 processors is only 4 Gigabytes large. That means that, if you have a large amount of physical memory, not all of it can be "permanently mapped" by the kernel. The physical memory that's not permanently mapped is called "high memory". And that leaves open the question of how much shared memory you can address. That presumably has to fit into the 4GB, and if your PostgreSQL processes had (by some fluke) 4GB of shared memory, there wouldn't be any "local" memory for sort memory and the likes. Add to that the consideration that there are reports of Linux "falling over" when you get to right around 2GB/4GB. I ran a torture test a while back that _looked_ like it was running into that; I can't verify that, unfortunately. I don't see there being a whole lot of use of having more than about 8GB on an ia-32 system; what with shared memory maxing out at somewhere between 1 and 2GB, that suggests having ~8GB in total. I'd add another PG cluster if I had 16GB... -- let name="aa454" and tld="freenet.carleton.ca" in name ^ "@" ^ tld;; http://www.ntlug.org/~cbbrowne/postgresql.html "A statement is either correct or incorrect. To be *very* incorrect is like being *very* dead ... " -- Herbert F. Spirer Professor of Information Management University of Conn. (DATAMATION Letters, Sept. 1, 1984) From pgsql-performance-owner@postgresql.org Tue Oct 21 17:49: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 1665CD1B4FD for ; Tue, 21 Oct 2003 20:48: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 41712-10 for ; Tue, 21 Oct 2003 17:48:29 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id BC033D1B4F8 for ; Tue, 21 Oct 2003 17:48:23 -0300 (ADT) 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 h9LKl7Ok019232; Tue, 21 Oct 2003 14:47:07 -0600 (MDT) Date: Tue, 21 Oct 2003 14:36:01 -0600 (MDT) From: "scott.marlowe" To: Will LaShell Cc: Alexander Priem , Subject: RAID controllers etc... was: PostgreSQL data on a NAS device ? In-Reply-To: <1066762807.29522.3.camel@lyric.ofsloans.com> 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: 200310/557 X-Sequence-Number: 4305 On 21 Oct 2003, Will LaShell wrote: > On Tue, 2003-10-21 at 08:40, scott.marlowe wrote: > > > So that brings up my question, which is better, the Perc4 or Perc3 > > controllers, and what's the difference between them? I find Dell's > > tendency to hide other people's hardware behind their own model numbers > > mildly bothersome, as it makes it hard to comparison shop. > > Perc4 has n LSI 1030 chip > http://docs.us.dell.com/docs/storage/perc4di/en/ug/features.htm > > > Perc3 > depending on the model can be a couple of things but I think they are > all U160 controllers and not U320 Thanks. I googled around and found this page: http://www.domsch.com/linux/ Which says what each model is. It looks like the "RAID" controller they wanna charge me for is about $500 or so, so I'm guessing it's the medium range Elite 1600 type controller, i.e. U160, which is plenty for the machine / drive number we'll be using. Has anyone played around with the latest ones to get a feel for them? I want a battery backed controller that runs well under linux and also BSD that isn't gonna break the bank. I'd heard bad stories about the performance of the Adaptec RAID controllers, but it seems the newer ones aren't bad from what I've found googling. From pgsql-performance-owner@postgresql.org Tue Oct 21 17:55: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 3BB0ED1B500 for ; Tue, 21 Oct 2003 20:55: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 47580-07 for ; Tue, 21 Oct 2003 17:55:05 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id E550BD1B4FD for ; Tue, 21 Oct 2003 17:55:02 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AC3Wy-0007p8-00 for ; Tue, 21 Oct 2003 16:55:04 -0400 Received: by dba2 (Postfix, from userid 1019) id DB80ACD6A; Tue, 21 Oct 2003 16:55:04 -0400 (EDT) Date: Tue, 21 Oct 2003 16:55:04 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Message-ID: <20031021205504.GJ11421@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <2F2E24372F10744588A27DEECC85FE04B6769D@vt-pe2550-001.vantage.vantage.com> <200310211015.57569.josh@agliodbs.com> <20031021175016.GH11421@libertyrms.info> <200310211151.02751.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200310211151.02751.josh@agliodbs.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/558 X-Sequence-Number: 4306 On Tue, Oct 21, 2003 at 11:51:02AM -0700, Josh Berkus wrote: > Of course, if you have anecdotal evidence to the contrary, then the > only way to work this would be to have OSDL help us sort it out. Nope. I too have such anecdotal evidence that 25% is way too high. It also seems to depend pretty heavily on what you're trying to optimise for and what platform you have. But I'm glad to hear (again) that people seem to think the 25% too high for most cases. I don't feel so much like I'm tilting against windmills. 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 Tue Oct 21 18:24: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 D325ED1B508 for ; Tue, 21 Oct 2003 21: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 56394-04 for ; Tue, 21 Oct 2003 18:23:38 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5E524D1B4E1 for ; Tue, 21 Oct 2003 18:23:35 -0300 (ADT) 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 h9LLMNDd021434; Tue, 21 Oct 2003 15:22:23 -0600 (MDT) Date: Tue, 21 Oct 2003 15:11:17 -0600 (MDT) From: "scott.marlowe" To: Andrew Sullivan Cc: Subject: Re: Tuning for mid-size server In-Reply-To: <20031021205504.GJ11421@libertyrms.info> 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: 200310/559 X-Sequence-Number: 4307 On Tue, 21 Oct 2003, Andrew Sullivan wrote: > On Tue, Oct 21, 2003 at 11:51:02AM -0700, Josh Berkus wrote: > > > Of course, if you have anecdotal evidence to the contrary, then the > > only way to work this would be to have OSDL help us sort it out. > > Nope. I too have such anecdotal evidence that 25% is way too high. > It also seems to depend pretty heavily on what you're trying to > optimise for and what platform you have. But I'm glad to hear > (again) that people seem to think the 25% too high for most cases. I > don't feel so much like I'm tilting against windmills. I think where it makes sense is when you have something like a report server where the result sets may be huge, but the parellel load is load, i.e. 5 or 10 users tossing around 100 Meg or more at time. If you've got 5,000 users running queries that are indexed and won't be using that much memory each, then there's usually no advantage to going over a certain number of buffers, and that certain number may be as low as 1000 for some applications. From pgsql-performance-owner@postgresql.org Tue Oct 21 18:28: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 3977FD1B500 for ; Tue, 21 Oct 2003 21:28: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 56325-04 for ; Tue, 21 Oct 2003 18:28:00 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id 2DC5CD1B508 for ; Tue, 21 Oct 2003 18:27:57 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Tue, 21 Oct 2003 16:27:58 -0500 Subject: Re: RAID controllers etc... was: PostgreSQL data on a NAS device ? From: Will LaShell To: "scott.marlowe" Cc: Alexander Priem , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-3BYlKxF0qFIEsYoNIEDn" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 21 Oct 2003 14:27:56 -0700 Message-Id: <1066771678.29522.25.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/560 X-Sequence-Number: 4308 --=-3BYlKxF0qFIEsYoNIEDn Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-10-21 at 13:36, scott.marlowe wrote: > On 21 Oct 2003, Will LaShell wrote: >=20 > > On Tue, 2003-10-21 at 08:40, scott.marlowe wrote: > > > > > So that brings up my question, which is better, the Perc4 or Perc3=20 > > > controllers, and what's the difference between them? I find Dell's= =20 > > > tendency to hide other people's hardware behind their own model numbe= rs=20 > > > mildly bothersome, as it makes it hard to comparison shop. > >=20 > > Perc4 has n LSI 1030 chip > > http://docs.us.dell.com/docs/storage/perc4di/en/ug/features.htm > >=20 > >=20 > > Perc3 > > depending on the model can be a couple of things but I think they are > > all U160 controllers and not U320 >=20 > Thanks. I googled around and found this page: >=20 > http://www.domsch.com/linux/ >=20 > Which says what each model is. It looks like the "RAID" controller they= =20 > wanna charge me for is about $500 or so, so I'm guessing it's the medium= =20 > range Elite 1600 type controller, i.e. U160, which is plenty for the=20 > machine / drive number we'll be using.=20=20 >=20 > Has anyone played around with the latest ones to get a feel for them? I= =20 > want a battery backed controller that runs well under linux and also BSD= =20 > that isn't gonna break the bank. I'd heard bad stories about the=20 > performance of the Adaptec RAID controllers, but it seems the newer ones= =20 > aren't bad from what I've found googling. We own 2 Elite 1650 and we love them. It would be nice to have had U320 capable controllers but the cards are completely reliable. I recommend the LSI controllers to everyone because I've never had a problem with them. --=-3BYlKxF0qFIEsYoNIEDn 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/laTcZr3R5kgOZd0RAvsiAJwP89+BGL1e4ycKaACdJrtR8bbL4wCfeLO3 rsJWwFBRE0D6G5fH3Cs11Z4= =JcEz -----END PGP SIGNATURE----- --=-3BYlKxF0qFIEsYoNIEDn-- From pgsql-performance-owner@postgresql.org Tue Oct 21 18:35: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 2163FD1B508 for ; Tue, 21 Oct 2003 21:35: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 56359-06 for ; Tue, 21 Oct 2003 18:34:30 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 3F155D1B509 for ; Tue, 21 Oct 2003 18:34:28 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3803239; Tue, 21 Oct 2003 14:35:09 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "scott.marlowe" , Andrew Sullivan Subject: Re: Tuning for mid-size server Date: Tue, 21 Oct 2003 14:32:16 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310211432.16551.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/562 X-Sequence-Number: 4310 Scott, > I think where it makes sense is when you have something like a report=20 > server where the result sets may be huge, but the parellel load is load,= =20 > i.e. 5 or 10 users tossing around 100 Meg or more at time. I've found that that question makes the difference between using 6% & 12% .= ..=20 particularly large data transformations ... but not higher than that. And= =20 I've had ample opportunity to test on 2 reporting servers. For one thing= ,=20 with very large reports one tends to have a lot of I/O binding, which is=20 handled by the kernel. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 21 18:34: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 C9D2AD1B510 for ; Tue, 21 Oct 2003 21:34: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 57004-04 for ; Tue, 21 Oct 2003 18:34:08 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id F2890D1B4E1 for ; Tue, 21 Oct 2003 18:34:05 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AC48m-0000Az-00 for ; Tue, 21 Oct 2003 17:34:08 -0400 Received: by dba2 (Postfix, from userid 1019) id 4CB23CD6A; Tue, 21 Oct 2003 17:34:08 -0400 (EDT) Date: Tue, 21 Oct 2003 17:34:08 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Tuning for mid-size server Message-ID: <20031021213408.GA12200@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20031021205504.GJ11421@libertyrms.info> 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: 200310/561 X-Sequence-Number: 4309 On Tue, Oct 21, 2003 at 03:11:17PM -0600, scott.marlowe wrote: > I think where it makes sense is when you have something like a report > server where the result sets may be huge, but the parellel load is load, > i.e. 5 or 10 users tossing around 100 Meg or more at time. In our case, we were noticing that truss showed an unbelievable amount of time spent by the postmaster doing open() calls to the OS (this was on Solaris 7). So we thought, "Let's try a 2G buffer size." 2G was more than enough to hold the entire data set under question. Once the buffer started to fill, even plain SELECTs started taking a long time. The buffer algorithm is just not that clever, was my conclusion. (Standard disclaimer: not a long, controlled test. It's just a bit of gossip.) 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 Tue Oct 21 21:24: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 28CE9D1B4E6 for ; Wed, 22 Oct 2003 00:24: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 78073-06 for ; Tue, 21 Oct 2003 21:24:28 -0300 (ADT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 15BFFD1B4E3 for ; Tue, 21 Oct 2003 21:24:23 -0300 (ADT) Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h9M0O5o19190; Tue, 21 Oct 2003 17:24:06 -0700 Message-Id: <200310220024.h9M0O5o19190@mail.osdl.org> Date: Tue, 21 Oct 2003 17:24:02 -0700 (PDT) From: markw@osdl.org Subject: analyzing postgresql performance for dbt-2 To: pgsql-performance@postgresql.org Cc: osdldbt-general@lists.sourceforge.net 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=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200310/563 X-Sequence-Number: 4311 I'm running our DBT-2 workload against PostgreSQL 7.3.4 and I'm having some trouble figuring out what I should be looking for when I'm trying to tune the database. I have results for a decent baseline, but when I try to increase the load on the database, the performance drops. Nothing in the graphs (in the links listed later) sticks out to me so I'm wondering if there are other database statitics I should try to collect. Any suggestions would be great and let me know if I can answer any other questions. Here are a pair of results where I just raise the load on the database, where increasing the load increases the area of the database touched in addition to increasing the transaction rate. The overall metric increases somewhat, but the response time for most of the interactions also increases significantly: http://developer.osdl.org/markw/dbt2-pgsql/158/ [baseline] - load of 100 warehouses - metric 1249.65 http://developer.osdl.org/markw/dbt2-pgsql/149/ - load of 140 warehouses - metric 1323.90 Both of these runs had wal_buffers set to 8, checkpoint_segments 200, and checkpoint_timeout 1800. So far I've only tried various wal_buffers and checkpoint_segments settings in the next set of results for a load of 140 warehouses. http://developer.osdl.org/markw/dbt2-pgsql/148/ - metric 1279.26 - wal_buffers 8 - checkpoint_segments 100 - checkpoint_timeout 300 http://developer.osdl.org/markw/dbt2-pgsql/149/ - metric 1323.90 - wal_buffers 8 - checkpoint_segments 200 - checkpoint_timeout 1800 http://developer.osdl.org/markw/dbt2-pgsql/150/ - metric 1281.13 - wal_buffers 8 - checkpoint_segments 300 - checkpoint_timeout 1800 http://developer.osdl.org/markw/dbt2-pgsql/151/ - metric 1311.99 - wal_buffers 32 - checkpoint_segments 200 - checkpoint_timeout 1800 http://developer.osdl.org/markw/dbt2-pgsql/152/ - metric 1268.37 - wal_buffers 64 - checkpoint_segments 200 - checkpoint_timeout 1800 http://developer.osdl.org/markw/dbt2-pgsql/154/ - metric 1314.62 - wal_buffers 16 - checkpoint_segments 200 - checkpoint_timeout 1800 Thanks! -- Mark Wong - - markw@osdl.org Open Source Development Lab Inc - A non-profit corporation 12725 SW Millikan Way - Suite 400 - Beaverton, OR 97005 (503) 626-2455 x 32 (office) (503) 626-2436 (fax) From pgsql-performance-owner@postgresql.org Tue Oct 21 21:36: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 E67B5D1B4FE for ; Wed, 22 Oct 2003 00:36: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 85788-01 for ; Tue, 21 Oct 2003 21:36:05 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id A2D5AD1B4E9 for ; Tue, 21 Oct 2003 21:36:00 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9M0Zul27091; Tue, 21 Oct 2003 20:35:56 -0400 (EDT) From: Bruce Momjian Message-Id: <200310220035.h9M0Zul27091@candle.pha.pa.us> Subject: Re: analyzing postgresql performance for dbt-2 In-Reply-To: <200310220024.h9M0O5o19190@mail.osdl.org> To: markw@osdl.org Date: Tue, 21 Oct 2003 20:35:56 -0400 (EDT) Cc: pgsql-performance@postgresql.org, osdldbt-general@lists.sourceforge.net 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: 200310/564 X-Sequence-Number: 4312 markw@osdl.org wrote: > I'm running our DBT-2 workload against PostgreSQL 7.3.4 and I'm having > some trouble figuring out what I should be looking for when I'm trying > to tune the database. I have results for a decent baseline, but when I > try to increase the load on the database, the performance drops. > Nothing in the graphs (in the links listed later) sticks out to me so > I'm wondering if there are other database statitics I should try to > collect. Any suggestions would be great and let me know if I can answer > any other questions. > > Here are a pair of results where I just raise the load on the > database, where increasing the load increases the area of the database > touched in addition to increasing the transaction rate. The overall > metric increases somewhat, but the response time for most of the > interactions also increases significantly: > > http://developer.osdl.org/markw/dbt2-pgsql/158/ [baseline] > - load of 100 warehouses > - metric 1249.65 > > http://developer.osdl.org/markw/dbt2-pgsql/149/ > - load of 140 warehouses > - metric 1323.90 I looked at these charts and they looked normal to me. It looked like your the load increased until your computer was saturated. Is there something I am missing? -- 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 Oct 21 23:11: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 6FE28D1B501 for ; Wed, 22 Oct 2003 02: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 95851-05 for ; Tue, 21 Oct 2003 23:10:43 -0300 (ADT) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 73AB5D1B4E9 for ; Tue, 21 Oct 2003 23:10:39 -0300 (ADT) Received: (from markw@localhost) by mail.osdl.org (8.11.6/8.11.6) id h9M2AXD06282; Tue, 21 Oct 2003 19:10:33 -0700 Date: Tue, 21 Oct 2003 19:10:33 -0700 From: Mark Wong To: Bruce Momjian Cc: pgsql-performance@postgresql.org, osdldbt-general@lists.sourceforge.net Subject: Re: analyzing postgresql performance for dbt-2 Message-ID: <20031021191033.A5484@osdlab.pdx.osdl.net> References: <200310220024.h9M0O5o19190@mail.osdl.org> <200310220035.h9M0Zul27091@candle.pha.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200310220035.h9M0Zul27091@candle.pha.pa.us>; from pgman@candle.pha.pa.us on Tue, Oct 21, 2003 at 08:35:56PM -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/565 X-Sequence-Number: 4313 On Tue, Oct 21, 2003 at 08:35:56PM -0400, Bruce Momjian wrote: > markw@osdl.org wrote: > > I'm running our DBT-2 workload against PostgreSQL 7.3.4 and I'm having > > some trouble figuring out what I should be looking for when I'm trying > > to tune the database. I have results for a decent baseline, but when I > > try to increase the load on the database, the performance drops. > > Nothing in the graphs (in the links listed later) sticks out to me so > > I'm wondering if there are other database statitics I should try to > > collect. Any suggestions would be great and let me know if I can answer > > any other questions. > > > > Here are a pair of results where I just raise the load on the > > database, where increasing the load increases the area of the database > > touched in addition to increasing the transaction rate. The overall > > metric increases somewhat, but the response time for most of the > > interactions also increases significantly: > > > > http://developer.osdl.org/markw/dbt2-pgsql/158/ [baseline] > > - load of 100 warehouses > > - metric 1249.65 > > > > http://developer.osdl.org/markw/dbt2-pgsql/149/ > > - load of 140 warehouses > > - metric 1323.90 > > I looked at these charts and they looked normal to me. It looked like > your the load increased until your computer was saturated. Is there > something I am missing? I've run some i/o tests so I'm pretty sure I haven't saturated that. And it looks like I have almost 10% more processor time left. I do agree that it appears something might be saturated, I just don't know where to look... Thanks, Mark From pgsql-performance-owner@postgresql.org Wed Oct 22 05:11: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 03DAAD1B527 for ; Wed, 22 Oct 2003 08:11: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 55533-09 for ; Wed, 22 Oct 2003 05:10:43 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 4D0A7D1B525 for ; Wed, 22 Oct 2003 05:10:40 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Wed, 22 Oct 2003 10:10:39 +0200 Message-ID: <017c01c39874$63feb110$b696a8c0@APR> From: "Alexander Priem" To: "Will LaShell" , "scott.marlowe" Cc: References: <1066771678.29522.25.camel@lyric.ofsloans.com> Subject: Re: RAID controllers etc... was: PostgreSQL data on a NAS device ? Date: Wed, 22 Oct 2003 10:13:35 +0200 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.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: 200310/566 X-Sequence-Number: 4314 So I guess the PERC4/Di RAID controller is pretty good. It seems that RedHat9 supports it out-of-the-box (driver 1.18f), but I gather from the sites mentioned before that upgrading this driver to 1.18i would be better... From pgsql-performance-owner@postgresql.org Wed Oct 22 07: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 67420D1B545 for ; Wed, 22 Oct 2003 10:09: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 77004-02 for ; Wed, 22 Oct 2003 07:09:06 -0300 (ADT) Received: from lorraine.ipl.co.uk (lorraine.ipl.co.uk [195.112.52.123]) by svr1.postgresql.org (Postfix) with ESMTP id E78F8D1B535 for ; Wed, 22 Oct 2003 07:08:56 -0300 (ADT) Received: from HFPORT.dmr.co.uk (pennsoft.gotadsl.co.uk [81.6.232.68]) by lorraine.ipl.co.uk (8.12.9/8.12.9) with ESMTP id h9MA8hGB002015 for ; Wed, 22 Oct 2003 11:08:43 +0100 Message-Id: <5.1.0.14.0.20031022110951.085d0d70@mailserver.ipl.co.uk> X-Sender: hf1@mailserver.ipl.co.uk X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Wed, 22 Oct 2003 11:09:55 +0100 To: pgsql-performance@postgresql.org From: Hilary Forbes Subject: Processors vs Memory 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= X-Spam-Level: X-Archive-Number: 200310/567 X-Sequence-Number: 4315 If I have a fixed amount of money to spend as a general rule is it better to buy one processor and lots of memory or two processors and less memory for a system which is transactional based (in this case it's handling reservations). I realise the answer will be a generalised one but all the performance bits I've read seem to talk about adjusting memory allocation. The client has received the general advice from their hardware supplier that 2 Xeon processors and less memory is better but for postgresql I'm thinking they might be better off with a single processor and loads of memory. The OS is Red Hat Linux. How long is a piece of string I guess but all comments welcome! TAI Hilary Hilary Forbes ------------- DMR Computer Limited: http://www.dmr.co.uk/ Direct line: 01689 889950 Switchboard: (44) 1689 860000 Fax: (44) 1689 860330 E-mail: hforbes@dmr.co.uk ********************************************************** From pgsql-performance-owner@postgresql.org Wed Oct 22 07: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 70CF7D1B538 for ; Wed, 22 Oct 2003 10:26: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 84018-01 for ; Wed, 22 Oct 2003 07:25:39 -0300 (ADT) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id F358DD1B4EF for ; Wed, 22 Oct 2003 07:25:35 -0300 (ADT) 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.42 $ on Novell NetWare via secured & encrypted transport (TLS); Wed, 22 Oct 2003 04:25:29 -0600 Message-ID: <3F965B12.5010901@myrealbox.com> Date: Wed, 22 Oct 2003 15:55:22 +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: Hilary Forbes Cc: pgsql-performance@postgresql.org Subject: Re: Processors vs Memory References: <5.1.0.14.0.20031022110951.085d0d70@mailserver.ipl.co.uk> In-Reply-To: <5.1.0.14.0.20031022110951.085d0d70@mailserver.ipl.co.uk> 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: 200310/568 X-Sequence-Number: 4316 Hilary Forbes wrote: > If I have a fixed amount of money to spend as a general rule >is it better to buy one processor and lots of memory or two >processors and less memory for a system which is transactional >based (in this case it's handling reservations). I realise the >answer will be a generalised one but all the performance bits >I've read seem to talk about adjusting memory allocation. >The client has received the general advice from their hardware >supplier that 2 Xeon processors and less memory is better but >for postgresql I'm thinking they might be better off with a single >processor and loads of memory. The OS is Red Hat Linux. Well it depends. If your projected database size is say 2 gigs, then you should buy 2Gigsof RAM and spend rest of the money on processor. But if your database size(max of currrent and projected) is 100GB, obviously you can not buy 100GB of memory that cheaply. So you should look for fast storage. The order of priority is IO, memory and CPU. If database is just big enough to fit in a gig or two, you should get RAM first. Processor is hardly ever a concern w.r.t database unless you are doing a lot in database business logic. HTH Shridhar From pgsql-performance-owner@postgresql.org Wed Oct 22 07:26: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 23AA2D1B520 for ; Wed, 22 Oct 2003 10:26: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 71248-10 for ; Wed, 22 Oct 2003 07:25:59 -0300 (ADT) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id 991A7D1B52C for ; Wed, 22 Oct 2003 07:25:55 -0300 (ADT) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9MAPoh0014730 for ; Wed, 22 Oct 2003 18:25:51 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9MAPnJT011728 for ; Wed, 22 Oct 2003 18:25:49 +0800 (SGT) Subject: Postgresql performance To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Wed, 22 Oct 2003 18:25:51 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/22/2003 06:25:52 PM 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=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME X-Spam-Level: * X-Archive-Number: 200310/569 X-Sequence-Number: 4317 Hi Currently we are running Postgresql v7.3.2 on Redhat Linux OS v9.0. We have Windows2000 client machines inserting records into the Postgresql tables via ODBC. After a few weeks of usage, when we do a \d at the sql prompt, there was a duplicate object name, ie it can be a duplicate row of index or table. When we do a \d table_name, it will show a duplication of column names inside the table. It doesnt affect the insertion/updating of the tables, but when we do a pg_dump -Da -t > /exp/.sql, it will not do a proper backup/dump. Do we need to apply any patches or maintenace? Please be informed that NEC Singapore Pte Ltd is now known as NEC Solutions Asia Pacific Pte Ltd. Our address and contact numbers remain. Email: chewtc@ap.nec.com.sg http://www.nec.com.sg/ap Thank you, REgards. From pgsql-performance-owner@postgresql.org Wed Oct 22 11:03: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 66AC6D1B555 for ; Wed, 22 Oct 2003 14:03: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 15995-04 for ; Wed, 22 Oct 2003 11:03:18 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1EED5D1B560 for ; Wed, 22 Oct 2003 11:03:14 -0300 (ADT) 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 h9ME36it011086; Wed, 22 Oct 2003 10:03:06 -0400 (EDT) To: CHEWTC@ap.nec.com.sg Cc: pgsql-performance@postgresql.org Subject: Re: Postgresql performance In-reply-to: References: Comments: In-reply-to CHEWTC@ap.nec.com.sg message dated "Wed, 22 Oct 2003 18:25:51 +0800" Date: Wed, 22 Oct 2003 10:03:05 -0400 Message-ID: <11085.1066831385@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/570 X-Sequence-Number: 4318 CHEWTC@ap.nec.com.sg writes: > Currently we are running Postgresql v7.3.2 on Redhat Linux OS v9.0. We have > Windows2000 client machines inserting records into the Postgresql tables > via ODBC. > After a few weeks of usage, when we do a \d at the sql prompt, there was a > duplicate object name, ie it can be a duplicate row of index or table. > When we do a \d table_name, it will show a duplication of column names > inside the table. Are you sure you are using 7.3 psql? This sounds like something that could happen with a pre-7.3 (not schema aware) psql, if there are multiple occurrences of the same table name in different schemas. > It doesnt affect the insertion/updating of the tables, but when we do a > pg_dump -Da -t > /exp/.sql, it will not > do a proper backup/dump. I'd wonder about whether you have the right pg_dump, too. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 22 11:49: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 61498D1B56B for ; Wed, 22 Oct 2003 14:49: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 26069-03 for ; Wed, 22 Oct 2003 11:48:36 -0300 (ADT) Received: from ns.fairind.com (unknown [65.161.19.65]) by svr1.postgresql.org (Postfix) with ESMTP id 14D25D1B565 for ; Wed, 22 Oct 2003 11:48:30 -0300 (ADT) Received: from encounter.fairfield.com by ns.fairind.com via smtpd (for svr1.postgresql.org [200.46.204.71]) with ESMTP; Wed, 22 Oct 2003 09:48:35 -0500 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: slow select Date: Wed, 22 Oct 2003 09:48:19 -0500 Message-ID: <906E2C446A276048A1BE283F17BCB12CDB40E6@encounter.fairind.fairfield.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: slow select Thread-Index: AcOYq3GmtpskPAC5EdiZ6gBQBHwzDQ== From: "Medora Schauer" To: "postgresql" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_RFCI X-Spam-Level: * X-Archive-Number: 200310/571 X-Sequence-Number: 4319 I'm using pg 7.3.4 to do a select involving a join on 2 tables.=20=20 The query is taking 15 secs which seems extreme to me considering=20 the indices that exist on the two tables. EXPLAIN ANALYZE shows=20 that the indices aren't being used. I've done VACUUM ANALYZE on the=20 db with no change in results. Shouldn't the indices be used? Below is what I believe to be the relevant information. I haven't included the definitions of the tables involved in the foreign key definititions because I don't think they matter.=20=20 Any help will be greatly appreciated. CREATE TABLE shotpoint (=20 shot_line_num FLOAT4, \ shotpoint FLOAT4,=20 x FLOAT4,=20 y FLOAT4,=20 template_id INT4,=20 num_chans INT4) CREATE TABLE shot_record (=20 shot_line_num FLOAT4,=20 shotpoint FLOAT4,=20 index INT2,=20 dev INT4,=20 dev_offset INT8,=20 bin INT4,=20 shot_time INT8,=20 record_length INT4, nav_x FLOAT4, nav_y FLOAT4, num_rus INT4, status INT4 DEFAULT 0,=20 reel_num INT4, file_num INT4, nav_status INT2, nav_shot_line FLOAT4, nav_shotpoint FLOAT4, nav_depth FLOAT4, sample_skew INT4,=20 trace_count INT4,=20=20 PRIMARY KEY (shot_line_num, shotpoint, index))=20 ALTER TABLE shotpoint ADD CONSTRAINT shot_line_fk=20 FOREIGN KEY (shot_line_num)=20 REFERENCES shot_line(shot_line_num) CREATE UNIQUE INDEX shotpoint_idx=20 ON shotpoint(shot_line_num, shotpoint) ALTER TABLE shot_record ADD CONSTRAINT shot_record_shotpoint_index_fk= =20 FOREIGN KEY (shot_line_num, shotpoint)=20 REFERENCES shotpoint(shot_line_num, shotpoint) =20 EXPLAIN ANALYZE SELECT r.shot_line_num, r.shotpoint, index,=20 shot_time,=20 record_length, dev,=20 dev_offset, num_rus, bin, template_id, trace_count FROM shot_record r, shotpoint p=20 WHERE p.shot_line_num =3D r.shot_line_num=20 AND p.shotpoint =3D r.shotpoint;=20 =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 Merge Join (cost=3D49902.60..52412.21 rows=3D100221 width=3D58) (actual ti= me=3D12814.28..15000.65 rows=3D100425 loops=3D1) Merge Cond: (("outer".shot_line_num =3D "inner".shot_line_num) AND ("out= er".shotpoint =3D "inner".shotpoint)) -> Sort (cost=3D13460.90..13711.97 rows=3D100425 width=3D46) (actual t= ime=3D3856.94..4157.01 rows=3D100425 loops=3D1) Sort Key: r.shot_line_num, r.shotpoint -> Seq Scan on shot_record r (cost=3D0.00..2663.25 rows=3D100425= width=3D46) (actual time=3D18.00..1089.00 rows=3D100425 loops=3D1) -> Sort (cost=3D36441.70..37166.96 rows=3D290106 width=3D12) (actual t= ime=3D8957.19..9224.09 rows=3D100749 loops=3D1) Sort Key: p.shot_line_num, p.shotpoint -> Seq Scan on shotpoint p (cost=3D0.00..5035.06 rows=3D290106 w= idth=3D12) (actual time=3D7.55..2440.06 rows=3D290106 loops=3D1) Total runtime: 15212.05 msec *********************************************************************** Medora Schauer Sr. Software Engineer Fairfield Industries 14100 Southwest Freeway Suite 600 Sugar Land, Tx 77478-3469 USA mschauer@fairfield.com phone: 281-275-7664 fax : 281-275-7551 *********************************************************************** From pgsql-performance-owner@postgresql.org Wed Oct 22 11:58: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 265CCD1B57A for ; Wed, 22 Oct 2003 14:58: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 24752-07 for ; Wed, 22 Oct 2003 11:57:58 -0300 (ADT) Received: from web12603.mail.yahoo.com (web12603.mail.yahoo.com [216.136.173.226]) by svr1.postgresql.org (Postfix) with SMTP id BB764D1B55F for ; Wed, 22 Oct 2003 11:57:52 -0300 (ADT) Message-ID: <20031022145757.80993.qmail@web12603.mail.yahoo.com> Received: from [207.235.65.10] by web12603.mail.yahoo.com via HTTP; Wed, 22 Oct 2003 07:57:57 PDT Date: Wed, 22 Oct 2003 07:57:57 -0700 (PDT) From: Simon Sadedin Subject: poor cpu utilization on dual cpu box To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1367658132-1066834677=:80464" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_40_50 X-Spam-Level: X-Archive-Number: 200310/572 X-Sequence-Number: 4320 --0-1367658132-1066834677=:80464 Content-Type: text/plain; charset=us-ascii Folks, I�m hoping someone can give me some pointers to resolving an issue with postgres and it�s ability to utilize multiple CPUs effectively. The issue is that no matter how much query load we throw at our server it seems almost impossible to get it to utilize more than 50% cpu on a dual-cpu box. For a single connection we can use all of one CPU, but multiple connections fail to increase the overall utilization (although they do cause it to spread across CPUs). The platform is a dual CPU 2.8Ghz P4 Xeon Intel box (hyperthreading disabled) running a fairly standard Redhat 9 distribution. We are using postgres on this platform with a moderate sized data set (some hundreds of megs of data). The tests perform no updates and simply hit the server with a single large complex query via a multithreaded java/jdbc client. To avoid network distortion we run the client on the localhost (its cpu load is minimal). We are running with shared buffers large enough to hold the entire database and sort memory of 64m, should easily be enough to prevent sorting to disk. At this point I�ve tried everything I can think of to diagnose this - checking the pg_locks table indicates that even under heavy load there are no ungranted locks, so it would appear not to be a locking issue. Vmstat/iostat show no excessive figures for network or io waits. The only outlandish figure is that context switches which spike up to 250,000/sec (seems large). By all indications, postgres is waiting internally as if it is somehow singlethreaded. However the documentation clearly indicates this should not be so. Can anyone give me some pointers as to why postgres would be doing this? Is postgres really multi-process capable or are the processes ultimately waiting on each other to run queries or access shared memory? On a second note, has anyone got some tips on how to profile postgres in this kind of situation? I have tried using gprof, but because postgres spawns its processes dynamically I always end up profiling the postmaster (not very useful). Thanking in advance for any help! Cheers, Simon. Ps. posted this to general, but then realised this is a better forum - sorry for the cross. --------------------------------- Do you Yahoo!? The New Yahoo! Shopping - with improved product search --0-1367658132-1066834677=:80464 Content-Type: text/html; charset=us-ascii

Folks,

 

I�m hoping someone can give me some pointers to resolving an issue with postgres and it�s ability to utilize multiple CPUs effectively.

 

The issue is that no matter how much query load we throw at our server it seems almost impossible to get it to utilize more than 50% cpu on a dual-cpu box.  For a single connection we can use all of one CPU, but multiple connections fail to increase the overall utilization (although they do cause it to spread across CPUs).

 

The platform is a dual CPU 2.8Ghz P4 Xeon Intel box (hyperthreading disabled)  running a fairly standard Redhat 9 distribution.  We are using postgres on this platform with a moderate sized data set (some hundreds of megs of data).  The tests perform no updates and simply hit the server with a single large complex query via a multithreaded java/jdbc client.  To avoid network distortion we run the client on the localhost (its cpu load is minimal).   We are running with shared buffers large enough to hold the entire database and sort memory of 64m, should easily be enough to prevent sorting to disk. 

 

At this point I�ve tried everything I can think of to diagnose this - checking the pg_locks table indicates that even under heavy load there are no ungranted locks, so it would appear not to be a locking issue.  Vmstat/iostat show no excessive figures for network or io waits.  The only outlandish figure is that context switches which spike up to 250,000/sec (seems large).  By all indications, postgres is waiting internally as if it is somehow singlethreaded.  However the documentation clearly indicates this should not be so.

 

Can anyone give me some pointers as to why postgres would be doing this?   Is postgres really multi-process capable or are the processes ultimately waiting on each other to run queries or access shared memory?

 

On a second note, has anyone got some tips on how to profile postgres in this kind of situation?  I have tried using gprof, but because postgres spawns its processes dynamically I always end up profiling the postmaster (not very useful).

 

Thanking in advance for any help!

 

Cheers,

 

Simon.

 

Ps. posted this to general, but then realised this is a better forum - sorry for the cross.

 


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search --0-1367658132-1066834677=:80464-- From pgsql-performance-owner@postgresql.org Wed Oct 22 12:30: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 DB88ED1B559 for ; Wed, 22 Oct 2003 15:30: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 27790-07 for ; Wed, 22 Oct 2003 12:29:32 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id 8CECAD1B568 for ; Wed, 22 Oct 2003 12:29:13 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Wed, 22 Oct 2003 10:28:56 -0500 Subject: Re: RAID controllers etc... was: PostgreSQL data on a From: Will LaShell To: Alexander Priem Cc: "scott.marlowe" , pgsql-performance@postgresql.org In-Reply-To: <017c01c39874$63feb110$b696a8c0@APR> References: <1066771678.29522.25.camel@lyric.ofsloans.com> <017c01c39874$63feb110$b696a8c0@APR> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-24nlsN6Elk3aXIt4DBIX" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 22 Oct 2003 08:28:48 -0700 Message-Id: <1066836536.29522.28.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/573 X-Sequence-Number: 4321 --=-24nlsN6Elk3aXIt4DBIX Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Heya On Wed, 2003-10-22 at 01:13, Alexander Priem wrote: > So I guess the PERC4/Di RAID controller is pretty good. It seems that > RedHat9 supports it out-of-the-box (driver 1.18f), but I gather from the > sites mentioned before that upgrading this driver to 1.18i would be > better... Actually upgrading to the Megaraid_2 driver would be even better. There are a -ton- of performance enhancements with it. Depending on your performance needs and testing capabilities, I would highly recommend trying it out. Will --=-24nlsN6Elk3aXIt4DBIX 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/lqIwZr3R5kgOZd0RAtYbAJ4+3h3ZhWKebiVT0eMfTOlUXSRP2gCgj/wZ UpX73u8dt9BYkA2QRJerJxc= =XFSx -----END PGP SIGNATURE----- --=-24nlsN6Elk3aXIt4DBIX-- From pgsql-performance-owner@postgresql.org Wed Oct 22 13:08: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 DB645D1B562 for ; Wed, 22 Oct 2003 16: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 36000-10 for ; Wed, 22 Oct 2003 13:07:27 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id D9F08D1B4EF for ; Wed, 22 Oct 2003 13:07:26 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3806501; Wed, 22 Oct 2003 09:08:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: CHEWTC@ap.nec.com.sg, pgsql-performance@postgresql.org Subject: Re: Postgresql performance Date: Wed, 22 Oct 2003 09:06:35 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310220906.35297.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/574 X-Sequence-Number: 4322 NEC, > After a few weeks of usage, when we do a \d at the sql prompt, there was a > duplicate object name, ie it can be a duplicate row of index or table. > When we do a \d table_name, it will show a duplication of column names > inside the table. I think the version of PSQL and pg_dump which you are using do not match the back-end database version. Correct this. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 13:12: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 049EED1B567 for ; Wed, 22 Oct 2003 16:12: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 44110-02 for ; Wed, 22 Oct 2003 13:12:02 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id EFA29D1B538 for ; Wed, 22 Oct 2003 13:12:01 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3806524; Wed, 22 Oct 2003 09:12:40 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Simon Sadedin , pgsql-performance@postgresql.org Subject: Re: poor cpu utilization on dual cpu box Date: Wed, 22 Oct 2003 09:11:14 -0700 User-Agent: KMail/1.4.3 References: <20031022145757.80993.qmail@web12603.mail.yahoo.com> In-Reply-To: <20031022145757.80993.qmail@web12603.mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310220911.14853.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/575 X-Sequence-Number: 4323 Simon, > The issue is that no matter how much query load we throw at our server it > seems almost impossible to get it to utilize more than 50% cpu on a > dual-cpu box. For a single connection we can use all of one CPU, but > multiple connections fail to increase the overall utilization (although > they do cause it to spread across CPUs). This is perfectly normal. It's a rare x86 machine (read fiber channel) where you don't saturate the I/O or the RAM *long* before you saturate the CPU. Transactional databases are an I/O intensive operation, not a CPU-intensive one. > We are running with shared buffers large enough to hold the > entire database Which is bad. This is not what shared buffers are for. See: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-admin-owner@postgresql.org Wed Oct 22 13:22:44 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7ED91D1B56D; Wed, 22 Oct 2003 16:22: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 44258-03; Wed, 22 Oct 2003 13:22:11 -0300 (ADT) Received: from host2.hostseguro.com (133-188-198-200.hostseguro.com [200.198.188.133]) by svr1.postgresql.org (Postfix) with ESMTP id 581DCD1B562; Wed, 22 Oct 2003 13:22:09 -0300 (ADT) Received: from cpanel by host2.hostseguro.com with local (Exim 4.20) id 1ACLjt-00075J-W2; Wed, 22 Oct 2003 14:21:37 -0200 Received: from 200.180.185.118 ([200.180.185.118]) by sistemica.info (IMP) with HTTP for ; Wed, 22 Oct 2003 14:21:37 -0200 Message-ID: <1066839697.3f96ae91e3108@sistemica.info> Date: Wed, 22 Oct 2003 14:21:37 -0200 From: Rhaoni Chiu Pereira To: Josh Berkus , PostgreSQL ADMIN , PostgreSQL Performance Subject: Re: [PERFORM] Low Insert/Update Performance References: <1066659206.3f93ed86b9907@sistemica.info> <200310201007.48534.josh@agliodbs.com> <1066756132.3f95682499d8d@sistemica.info> <200310211013.53997.josh@agliodbs.com> In-Reply-To: <200310211013.53997.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 200.180.185.118 X-MailScanner-Information: Verificado pelo McAfee VirusScan / Scanned by McAfee VirusScan X-MailScanner: Nao infectado / Found to be clean X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2.hostseguro.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32001 32001] / [47 12] X-AntiAbuse: Sender Address Domain - sistemica.info X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=4.6 tagged_above=0.0 required=5.0 tests=IN_REP_TO, RCVD_IN_DSBL, RCVD_IN_RFCI, REFERENCES, USER_AGENT_IMP X-Spam-Level: **** X-Archive-Number: 200310/277 X-Sequence-Number: 10838 Hi List; Here follow the update query, explain analyze of it , my postgresql.conf and my db configuration. This is my first PostgreSQL DB so I would like to know if its performance is normal ! If there is some postgresql.conf's parameter that you think will optmize the database just tell me !!! QUERY: update ftnfco00 set empfil = 0, data_entrega = NULL, situacao_nf = 'N', cod_fiscal = 61010000, base_calc_icm_trib = '264.1'::float8, nf_emitida = 'S', tipo_cad_clicre ='C', cod_cliente = '55380'::float8, cod_repres = 8, cod_tipo_cliente = 1, estado_cliente = 'PR', pais_cliente = 978, classif_cliente = '', cod_suframa = ' ', ordem_compra = ' ', banco_cobranca = 0, situacao_comissao = '0', perc_comissao = '6'::float8, emitir_bloqueto = 'N', cod_tipo_venda = 0, prazo_pgto_01 = 68, prazo_pgto_02 = 0, prazo_pgto_03 = 0, prazo_pgto_04 = 0, prazo_pgto_05 = 0, prazo_pgto_06 = 0, prazo_pgto_07 = 0, prazo_pgto_08 = 0, prazo_pgto_09 = 0, prazo_pgto_desc_duplic = 0, perc_desc_duplic = '0'::float8, qtde_fisica = '5'::float8, vlr_liquido = '264.1'::float8, vlr_ipi = '0'::float8, vlr_compl_nf = 0, vlr_frete = '26.4'::float8, vlr_acresc_fin_emp = 0, vlr_acresc_fin_tab = 0, vlr_dolar_vcto_dupl = 1, vlr_dolar_dia_fatur = 1, vlr_icm = '31.69'::float8, vlr_ipi_consignacao = 0, perc_juro_dia = '0.15'::float8, cod_texto_padrao = 19, cod_transp = 571, cod_transp_redesp = 0, placa_transp = '', peso_liquido = '5.832'::float8, peso_bruto = '6.522'::float8, qtde_volumes = 5, proxima_nf = '0'::float8, lista_preco = '03RS', lista_preco_basico = ' ', atu_guia_embarque = 'N', vlr_pis_cofins = 0, qtde_duzias = 5, obs_nf = 'ORDEM DE COMPRA 40851583', margem_comercial = 0, margem_operac = 0 where emp = 909 and fil = 101 and nota_fiscal = '57798'::float8 and serie = 'UNICA' and data_emissao = cast('2003-01-03 00:00:00'::timestamp as timestamp) EXPLAIN ANALYZE: QUERY PLAN $ -------------------------------------------------------------------------------- ---------------------------------------------$ Index Scan using ftnfco06 on ftnfco00 (cost=0.00..20.20 rows=1 width=535) (actual time=1.14..1.27 rows=1 loops=1) Index Cond: ((emp = 909::numeric) AND (fil = 101::numeric) AND (data_emissao = '2003-01-03 00:00:00'::timestamp without ti$ Filter: (((nota_fiscal)::double precision = 57798::double precision) AND (serie = 'UNICA'::character varying)) Total runtime: 3.56 msec (4 rows) postgresql.conf: # Connection Parameters # tcpip_socket = true #ssl = false max_connections = 10 #superuser_reserved_connections = 2 port = 5432 #hostname_lookup = false #show_source_port = false #unix_socket_directory = '' #unix_socket_group = '' #unix_socket_permissions = 0777 # octal #virtual_host = '' #krb_server_keyfile = '' # # Shared Memory Size # shared_buffers = 10000 # min max_connections*2 or 16, 8KB each max_fsm_relations = 2000 # min 10, fsm is free space map, ~40 bytes max_fsm_pages = 20000 # min 1000, fsm is free space map, ~6 bytes #max_locks_per_transaction = 64 # min 10 #wal_buffers = # min 4, typically 8KB each # # Non-shared Memory Sizes # sort_mem = 8000 # min 64, size in KB vacuum_mem = 16192 # min 1024, size in KB # # Write-ahead log (WAL) # checkpoint_segments = 9 # in logfile segments, min 1, 16MB each #checkpoint_timeout = 300 # range 30-3600, in seconds # #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 # fsync = false #wal_sync_method = fsync # the default varies across platforms: # # fsync, fdatasync, open_sync, or open_datasync #wal_debug = 0 # range 0-16 # # Optimizer Parameters # enable_seqscan = false enable_indexscan = true enable_tidscan = true enable_sort = true enable_nestloop = true enable_mergejoin = true enable_hashjoin = true effective_cache_size = 16000 # 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) default_statistics_target = 1000 # range 1-1000 # # GEQO Optimizer Parameters # #geqo = true #geqo_selection_bias = 2.0 # range 1.5-2.0 #geqo_threshold = 11 #geqo_pool_size = 0 # default based on tables in statement, # range 128-1024 #geqo_effort = 1 #geqo_generations = 0 #geqo_random_seed = -1 # auto-compute seed # # Message display # #server_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, log, fatal, # panic #client_min_messages = notice # Values, in order of decreasing detail: # debug5, debug4, debug3, debug2, debug1, # log, info, notice, warning, error #silent_mode = false #log_connections = false #log_pid = false #log_statement = false #log_duration = false log_timestamp = true #log_min_error_statement = error # Values in order of increasing severity: # debug5, debug4, debug3, debug2, debug1, # info, notice, warning, error, panic(off) #debug_print_parse = false #debug_print_rewritten = false #debug_print_plan = false #debug_pretty_print = false #explain_pretty_print = true # requires USE_ASSERT_CHECKING #debug_assertions = true # # Syslog # #syslog = 0 # range 0-2 #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' # # Statistics # #show_parser_stats = false #show_planner_stats = false #show_executor_stats = false #show_statement_stats = false # requires BTREE_BUILD_STATS #show_btree_build_stats = false # # Access statistics collection # #stats_start_collector = true #stats_reset_on_server_start = true #stats_command_string = false #stats_row_level = false #stats_block_level = false # # Lock Tracing # #trace_notify = false # requires LOCK_DEBUG #trace_locks = false #trace_userlocks = false #trace_lwlocks = false #debug_deadlocks = false #trace_lock_oidmin = 16384 #trace_lock_table = 0 # # Misc # #autocommit = true #dynamic_library_path = '$libdir' search_path = 'vendas' #datestyle = 'iso, us' #timezone = unknown # actually, defaults to TZ environment setting #australian_timezones = false #client_encoding = sql_ascii # actually, defaults to database encoding #authentication_timeout = 60 # 1-600, in seconds #deadlock_timeout = 1000 # in milliseconds #default_transaction_isolation = 'read committed' #max_expr_depth = 10000 # min 10 #max_files_per_process = 1000 # min 25 #password_encryption = true #sql_inheritance = true #transform_null_equals = false #statement_timeout = 0 # 0 is disabled, in milliseconds #db_user_namespace = false # # Locale settings # # (initialized by initdb -- may be changed) LC_MESSAGES = 'en_US.UTF-8' LC_MONETARY = 'en_US.UTF-8' LC_NUMERIC = 'en_US.UTF-8' LC_TIME = 'en_US.UTF-8' db configuration: Pentium 4 1.7 GHz , 512 MB RAM DDR , HD 7200 RPM , RH 9 , PostgreSQL 7.3.2-3 Atenciosamente, Rhaoni Chiu Pereira Sist�mica Computadores Visite-nos na Web: http://sistemica.info Fone/Fax : +55 51 3328 1122 Citando Josh Berkus : <> Rhaoni, <> <> > The delphi program does just one commit for all queries . <> > I was wandering if ther is some configuration parameters to be changed to <> > improve the performance ? <> <> To help you, we'll need to to trap a query and run an EXPLAIN ANALYZE on <> it. <> <> -- <> Josh Berkus <> Aglio Database Solutions <> San Francisco <> From pgsql-performance-owner@postgresql.org Wed Oct 22 13:24: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 731B6D1B511 for ; Wed, 22 Oct 2003 16:24: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 44110-04 for ; Wed, 22 Oct 2003 13:24:04 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 84A3DD1B538 for ; Wed, 22 Oct 2003 13:24:03 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3806582; Wed, 22 Oct 2003 09:24:41 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Medora Schauer" , "postgresql" Subject: Re: slow select Date: Wed, 22 Oct 2003 09:23:15 -0700 User-Agent: KMail/1.4.3 References: <906E2C446A276048A1BE283F17BCB12CDB40E6@encounter.fairind.fairfield.com> In-Reply-To: <906E2C446A276048A1BE283F17BCB12CDB40E6@encounter.fairind.fairfield.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310220923.15932.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/577 X-Sequence-Number: 4325 Medora, > I'm using pg 7.3.4 to do a select involving a join on 2 tables. > The query is taking 15 secs which seems extreme to me considering > the indices that exist on the two tables. EXPLAIN ANALYZE shows > that the indices aren't being used. I've done VACUUM ANALYZE on the > db with no change in results. Shouldn't the indices be used? No. You're selecting 100,000 records. For such a large record dump, a seq scan is usually faster. If you don't believe me, try setting enable_seqscan=false and see how long the query takes. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 13:29: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 886BAD1B4EF for ; Wed, 22 Oct 2003 16:29: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 37411-10 for ; Wed, 22 Oct 2003 13:28:46 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 931FAD1B511 for ; Wed, 22 Oct 2003 13:28:45 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3806601; Wed, 22 Oct 2003 09:29:15 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rhaoni Chiu Pereira , PostgreSQL Performance Subject: Re: Low Insert/Update Performance Date: Wed, 22 Oct 2003 09:27:49 -0700 User-Agent: KMail/1.4.3 References: <1066659206.3f93ed86b9907@sistemica.info> <200310211013.53997.josh@agliodbs.com> <1066839697.3f96ae91e3108@sistemica.info> In-Reply-To: <1066839697.3f96ae91e3108@sistemica.info> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310220927.49451.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/578 X-Sequence-Number: 4326 Rhaoni, > Total runtime: 3.56 msec > (4 rows) Well, from that figure it's not the query that's holding you up. You said that the system bogs down when you're doing a whole series of these updates, or just one? If the former, then I'm afraid that it's your disk that's to blame ... large numbers of rapid-fire updates simply won't be fast on a single IDE disk. Try getting a second disk and moving the transaction log to it. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 13:48: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 283DCD1B589 for ; Wed, 22 Oct 2003 16:48: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 47704-02 for ; Wed, 22 Oct 2003 13:48:12 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 2DA13D1B538 for ; Wed, 22 Oct 2003 13:48:11 -0300 (ADT) 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 h9MGlMDd022740; Wed, 22 Oct 2003 10:47:23 -0600 (MDT) Date: Wed, 22 Oct 2003 10:36:10 -0600 (MDT) From: "scott.marlowe" To: Hilary Forbes Cc: Subject: Re: Processors vs Memory In-Reply-To: <5.1.0.14.0.20031022110951.085d0d70@mailserver.ipl.co.uk> 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: 200310/579 X-Sequence-Number: 4327 On Wed, 22 Oct 2003, Hilary Forbes wrote: > If I have a fixed amount of money to spend as a general rule is it > better to buy one processor and lots of memory or two processors and > less memory for a system which is transactional based (in this case > it's handling reservations). I realise the answer will be a generalised > one but all the performance bits I've read seem to talk about adjusting > memory allocation. The client has received the general advice from > their hardware supplier that 2 Xeon processors and less memory is better > but for postgresql I'm thinking they might be better off with a single > processor and loads of memory. The OS is Red Hat Linux. My opinion is that two CPUs is optimal because it allows the OS to operate in parallel to the database. After the second CPU, the only advantage is if you are doing a lot of parallel access. Go for fast I/O first, a RAID1+0 setup is optimal for smaller numbers of drives (works on 4 or 6 drives nicely) and RAID5 is optimal for a larger number of drives (works well on 10 or more drives). Always use hardware RAID with battery backed cache for a heavily updated database. For a reports database software RAID is quite acceptable. There's a limit to how much memory you can throw at the problem if you're on 32 bit hardware, and that limit is about 2 to 4 gig. While you can install more, it usually makes little or no difference. Lastly, don't forget to tune your database and server once you have it up and running: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html From pgsql-performance-owner@postgresql.org Wed Oct 22 13: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 791F5D1B56A for ; Wed, 22 Oct 2003 16: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 48366-01 for ; Wed, 22 Oct 2003 13:59:16 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 09556D1B4EF for ; Wed, 22 Oct 2003 13:59:15 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3806762; Wed, 22 Oct 2003 09:59:53 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rhaoni Chiu Pereira Subject: Re: Low Insert/Update Performance Date: Wed, 22 Oct 2003 09:58:28 -0700 User-Agent: KMail/1.4.3 References: <1066659206.3f93ed86b9907@sistemica.info> <200310220927.49451.josh@agliodbs.com> <1066841444.3f96b564d6d93@sistemica.info> In-Reply-To: <1066841444.3f96b564d6d93@sistemica.info> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310220958.28201.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/580 X-Sequence-Number: 4328 Rhaoni, > First of all , thank's for your atention and fast answer. The system > really bogs down when I'm doing a whole series of these updates. That would be consistent with a single-disk problem. > Take a > look at my postgresql.conf I'm afraid of putting some parameters wrong ( > too high or too low ). And sorry if it sounds stupid but how can I move the > transaction log to this second disk ? 1) Install the 2nd disk. 2) With PostgreSQL shut down, copy the PGDATA/pg_xlog directory to the 2nd disk. 3) delete the old pg_xlog directory 4) Symlink or Mount the new pg_xlog directory under PGDATA as PGDATA/pg_xlog. 5) Restart Postgres. What I am interested in is your original assertion that this ran faster on Oracle. Was Oracle installed on this particular machine, or a different one? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 14: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 ADE65D1B561 for ; Wed, 22 Oct 2003 17: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 38955-10 for ; Wed, 22 Oct 2003 14:03:03 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 2ED3AD1B4EF for ; Wed, 22 Oct 2003 14:03:02 -0300 (ADT) 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 h9MH2vit017146; Wed, 22 Oct 2003 13:02:57 -0400 (EDT) To: Josh Berkus Cc: Simon Sadedin , pgsql-performance@postgresql.org Subject: Re: poor cpu utilization on dual cpu box In-reply-to: <200310220911.14853.josh@agliodbs.com> References: <20031022145757.80993.qmail@web12603.mail.yahoo.com> <200310220911.14853.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 22 Oct 2003 09:11:14 -0700" Date: Wed, 22 Oct 2003 13:02:56 -0400 Message-ID: <17145.1066842176@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/581 X-Sequence-Number: 4329 Josh Berkus writes: >> We are running with shared buffers large enough to hold the >> entire database > Which is bad. This is not what shared buffers are for. See: > http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html In fact, that may be the cause of the performance issue. The high context-swap rate suggests heavy contention for shared-memory data structures. The first explanation that occurs to me is that too much time is being spent managing the buffer hashtable, causing that to become a serialization bottleneck. Try setting shared_buffers to 10000 or so and see if it gets better. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 22 15:00: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 A3361D1B561 for ; Wed, 22 Oct 2003 18:00: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 58483-03 for ; Wed, 22 Oct 2003 15:00:10 -0300 (ADT) Received: from web12608.mail.yahoo.com (web12608.mail.yahoo.com [216.136.173.231]) by svr1.postgresql.org (Postfix) with SMTP id 300EFD1B55E for ; Wed, 22 Oct 2003 15:00:07 -0300 (ADT) Message-ID: <20031022175808.20661.qmail@web12608.mail.yahoo.com> Received: from [207.235.65.10] by web12608.mail.yahoo.com via HTTP; Wed, 22 Oct 2003 10:58:08 PDT Date: Wed, 22 Oct 2003 10:58:08 -0700 (PDT) From: Simon Sadedin Subject: Re: poor cpu utilization on dual cpu box To: Josh Berkus , pgsql-performance@postgresql.org In-Reply-To: <200310220911.14853.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: 200310/582 X-Sequence-Number: 4330 The suggestion that we are saturating the memory bus makes a lot of sense. We originally started with a low setting for shared buffers and resized it to fit all our tables (since we have memory to burn). That improved stand alone performance but not concurrent performance - this would explain that phenomenon somewhat. Will investigate further down this track. Thanks to everyone who responded! Cheers, Simon. Josh Berkus wrote:Simon, > The issue is that no matter how much query load we throw at our server it > seems almost impossible to get it to utilize more than 50% cpu on a > dual-cpu box. For a single connection we can use all of one CPU, but > multiple connections fail to increase the overall utilization (although > they do cause it to spread across CPUs). This is perfectly normal. It's a rare x86 machine (read fiber channel) where you don't saturate the I/O or the RAM *long* before you saturate the CPU. Transactional databases are an I/O intensive operation, not a CPU-intensive one. > We are running with shared buffers large enough to hold the > entire database Which is bad. This is not what shared buffers are for. See: http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html -- Josh Berkus Aglio Database Solutions San Francisco ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com From pgsql-performance-owner@postgresql.org Wed Oct 22 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 1F861D1B56A for ; Wed, 22 Oct 2003 18:45: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 67809-04 for ; Wed, 22 Oct 2003 15:44:54 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 5C9D3D1B4FB for ; Wed, 22 Oct 2003 15:44:53 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id C06A53E4C for ; Wed, 22 Oct 2003 14:44:53 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 12012-04 for ; Wed, 22 Oct 2003 14:44:53 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 4D77C3E29 for ; Wed, 22 Oct 2003 14:44:53 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9MIirAO021411 for pgsql-performance@postgresql.org; Wed, 22 Oct 2003 14:44:53 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: vacuum locking Date: Wed, 22 Oct 2003 14:44:52 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 18 Message-ID: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066848293 93105 216.194.193.105 (22 Oct 2003 18:44:53 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Wed, 22 Oct 2003 18:44:53 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:iHDix0eB3KgLOVcuX1LWtxh2Z6A= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/583 X-Sequence-Number: 4331 >>>>> "RN" == Rob Nagler writes: RN> Vendor: DELL Model: PERCRAID Mirror Rev: V1.0 RN> Type: Direct-Access ANSI SCSI revision: 02 AMI or Adaptec based? If AMI, make sure it has write-back cache enabled (and you have battery backup!), and disable the 'readahead' feature if you can. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Wed Oct 22 15:46: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 69114D1B571 for ; Wed, 22 Oct 2003 18:46: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 66920-07 for ; Wed, 22 Oct 2003 15:46:27 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id D3A4ED1B8AE for ; Wed, 22 Oct 2003 15:46:25 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 0E2C73E30 for ; Wed, 22 Oct 2003 14:46:27 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 12012-04-3 for ; Wed, 22 Oct 2003 14:46:26 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 9587B3E29 for ; Wed, 22 Oct 2003 14:46:26 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9MIkQjV056489 for pgsql-performance@postgresql.org; Wed, 22 Oct 2003 14:46:26 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: vacuum locking Date: Wed, 22 Oct 2003 14:46:26 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 18 Message-ID: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <16272.30527.120343.547492@jump.bivio.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066848386 93105 216.194.193.105 (22 Oct 2003 18:46:26 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Wed, 22 Oct 2003 18:46:26 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:4jXxDs0YqRKv22bP2LviMmzba1U= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/584 X-Sequence-Number: 4332 >>>>> "RN" == Rob Nagler writes: RN> This solution doesn't really fix the fact that VACUUM consumes the RN> disk while it is running. I want to avoid the erratic performance on RN> my web server when VACUUM is running. What's the disk utilization proir to running vacuum? If it is hovering around 95% or more of capacity, of course you're gonna overwhelm it. This ain't Star Trek -- the engines can't run at 110%, Cap'n! -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Wed Oct 22 17:57: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 4AE30D1B51A for ; Wed, 22 Oct 2003 20:57: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 91061-03 for ; Wed, 22 Oct 2003 17:56:39 -0300 (ADT) Received: from ns.fairind.com (unknown [65.161.19.65]) by svr1.postgresql.org (Postfix) with ESMTP id 4614AD1B57E for ; Wed, 22 Oct 2003 17:56:32 -0300 (ADT) Received: from encounter.fairfield.com by ns.fairind.com via smtpd (for svr1.postgresql.org [200.46.204.71]) with ESMTP; Wed, 22 Oct 2003 15:56:35 -0500 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: Re: slow select Date: Wed, 22 Oct 2003 15:56:33 -0500 Message-ID: <906E2C446A276048A1BE283F17BCB12CDB422A@encounter.fairind.fairfield.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] slow select Thread-Index: AcOYuStYXgs/k+xTR3u6JUshFw0zFQAJQFkQ From: "Medora Schauer" To: "Josh Berkus" , "postgresql" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=QUOTED_EMAIL_TEXT, RCVD_IN_RFCI X-Spam-Level: X-Archive-Number: 200310/585 X-Sequence-Number: 4333 =20 >=20 > Medora, >=20 > > I'm using pg 7.3.4 to do a select involving a join on 2 tables. > > The query is taking 15 secs which seems extreme to me considering > > the indices that exist on the two tables. EXPLAIN ANALYZE shows > > that the indices aren't being used. I've done VACUUM ANALYZE on the > > db with no change in results. Shouldn't the indices be used? >=20 > No. You're selecting 100,000 records. For such a large=20 > record dump, a seq=20 > scan is usually faster. >=20 > If you don't believe me, try setting enable_seqscan=3Dfalse and=20 > see how long the=20 > query takes. I did as you suggested (set enable_seqscan =3D false) and the query now tak= es 6 sec (vs 15 secs before) : Merge Join (cost=3D0.00..287726.10 rows=3D100221 width=3D58) (actual time= =3D61.60..5975.63 rows=3D100425 loops=3D1) Merge Cond: (("outer".shot_line_num =3D "inner".shot_line_num) AND ("out= er".shotpoint =3D "inner".shotpoint)) -> Index Scan using hsot_record_idx on shot_record r (cost=3D0.00..123= 080.11 rows=3D100425 width=3D46) (actual time=3D24.15..2710.31 rows=3D10042= 5 loops=3D1) -> Index Scan using shotpoint_idx on shotpoint p (cost=3D0.00..467924.= 54 rows=3D290106 width=3D12) (actual time=3D37.38..1379.64 rows=3D100749 lo= ops=3D1) Total runtime: 6086.32 msec So why did were the indices not used before when they yield a better plan? From pgsql-performance-owner@postgresql.org Wed Oct 22 18:05: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 595A8D1B4E5 for ; Wed, 22 Oct 2003 21:05: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 90219-05 for ; Wed, 22 Oct 2003 18:05:28 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 428EFD1B4EF for ; Wed, 22 Oct 2003 18:05:26 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3807877; Wed, 22 Oct 2003 14:06:05 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Medora Schauer" , "postgresql" Subject: Re: slow select Date: Wed, 22 Oct 2003 14:03:12 -0700 User-Agent: KMail/1.4.3 References: <906E2C446A276048A1BE283F17BCB12CDB422A@encounter.fairind.fairfield.com> In-Reply-To: <906E2C446A276048A1BE283F17BCB12CDB422A@encounter.fairind.fairfield.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310221403.12570.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/586 X-Sequence-Number: 4334 Medora, > So why did were the indices not used before when they yield a better plan? Your .conf settings, most likely. I'd lower your random_page_cost and rais= e=20 your effective_cache_size. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 18:16: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 2E6AFD1B515 for ; Wed, 22 Oct 2003 21:16: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 88460-09 for ; Wed, 22 Oct 2003 18:16:15 -0300 (ADT) Received: from ns.fairind.com (unknown [65.161.19.65]) by svr1.postgresql.org (Postfix) with ESMTP id 13B61D1B525 for ; Wed, 22 Oct 2003 18:16:12 -0300 (ADT) Received: from encounter.fairfield.com by ns.fairind.com via smtpd (for svr1.postgresql.org [200.46.204.71]) with ESMTP; Wed, 22 Oct 2003 16:16:14 -0500 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: Re: slow select Date: Wed, 22 Oct 2003 16:16:08 -0500 Message-ID: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] slow select Thread-Index: AcOY4Dv1tO0d/+B8QEebUKBRpp82lwAAI2mg From: "Medora Schauer" To: , "postgresql" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=QUOTED_EMAIL_TEXT, RCVD_IN_RFCI X-Spam-Level: X-Archive-Number: 200310/587 X-Sequence-Number: 4335 Josh, > > So why did were the indices not used before when they yield=20 > a better plan? >=20 > Your .conf settings, most likely. I'd lower your=20 > random_page_cost and raise=20 > your effective_cache_size. Increasing effective_cache_size to 10000 did it. The query now takes 4 secs. I left random_page_cost at the default value of 4.=20=20 I thought, mistakenly apparently, that our database was relatively=20 itty bitty and so haven't messed with the .conf file. Guess I=20 better take a look at all the settings (I know where the docs are). Thanks for your help, Medora *********************************************************************** Medora Schauer Sr. Software Engineer Fairfield Industries *********************************************************************** From pgsql-performance-owner@postgresql.org Wed Oct 22 18:37: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 30CF1D1B557 for ; Wed, 22 Oct 2003 21:37: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 99232-04 for ; Wed, 22 Oct 2003 18:37:01 -0300 (ADT) Received: from lakemtao02.cox.net (lakemtao02.cox.net [68.1.17.243]) by svr1.postgresql.org (Postfix) with ESMTP id 7D3C5D1B515 for ; Wed, 22 Oct 2003 18:36:55 -0300 (ADT) Received: from lhosts ([68.11.66.83]) by lakemtao02.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031022213654.GTYN17750.lakemtao02.cox.net@lhosts> for ; Wed, 22 Oct 2003 17:36:54 -0400 Subject: Re: Tuning for mid-size server From: Ron Johnson To: PgSQL Performance ML In-Reply-To: References: <200310211012.15845.josh@agliodbs.com> Content-Type: text/plain Message-Id: <1066858611.12532.223.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Wed, 22 Oct 2003 16:36:51 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/588 X-Sequence-Number: 4336 On Tue, 2003-10-21 at 14:27, Christopher Browne wrote: > In the last exciting episode, josh@agliodbs.com (Josh Berkus) wrote: > > So what is the ceiling on 32-bit processors for RAM? Most of the > > 64-bit vendors are pushing Athalon64 and G5 as "breaking the 4GB > > barrier", and even I can do the math on 2^32. All these 64-bit > > vendors, then, are talking about the limit on ram *per application* > > and not per machine? > > I have been seeing ia-32 servers with 8GB of RAM; it looks as though > there are ways of having them support ("physically, in theory, if you > could get a suitable motherboard") as much as 64GB. > > But that certainly doesn't get you past 2^32 bytes per process, and > possibly not past 2^31 bytes/process. > > >From Linux kernel help: > > CONFIG_NOHIGHMEM: > > Linux can use up to 64 Gigabytes of physical memory on x86 > systems. However, the address space of 32-bit x86 processors is > only 4 Gigabytes large. That means that, if you have a large > amount of physical memory, not all of it can be "permanently > mapped" by the kernel. The physical memory that's not permanently > mapped is called "high memory". > > And that leaves open the question of how much shared memory you can > address. That presumably has to fit into the 4GB, and if your > PostgreSQL processes had (by some fluke) 4GB of shared memory, there > wouldn't be any "local" memory for sort memory and the likes. > > Add to that the consideration that there are reports of Linux "falling > over" when you get to right around 2GB/4GB. I ran a torture test a > while back that _looked_ like it was running into that; I can't verify > that, unfortunately. Well thank goodness that Linux & Postgres work so well on Alpha and long-mode AMD64. -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA "Fear the Penguin!!" From pgsql-performance-owner@postgresql.org Wed Oct 22 18:45: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 38FDED1B515 for ; Wed, 22 Oct 2003 21:45: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 00867-02 for ; Wed, 22 Oct 2003 18:45:13 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id E737FD1B538 for ; Wed, 22 Oct 2003 18:45:10 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3808096; Wed, 22 Oct 2003 14:45:50 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Medora Schauer" , "postgresql" Subject: Re: slow select Date: Wed, 22 Oct 2003 14:42:56 -0700 User-Agent: KMail/1.4.3 References: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> In-Reply-To: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310221442.56816.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/589 X-Sequence-Number: 4337 Medora, > Increasing effective_cache_size to 10000 did it.=20=20 That would be 78MB RAM. If you have more than that available, you can=20 increase it further. Ideally, it should be about 2/3 to 3/4 of available= =20 RAM. >The query now > takes 4 secs. I left random_page_cost at the default value of 4.=20=20 > I thought, mistakenly apparently, that our database was relatively=20 > itty bitty and so haven't messed with the .conf file.=20 Actually, for a itty bitty database on a fast machine, you definitely want = to=20 lower random_page_cost. It's a large database that would make you cautious= =20 about this. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 20: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 A7D97D1B4EC for ; Wed, 22 Oct 2003 23:51: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 20637-01 for ; Wed, 22 Oct 2003 20:51:24 -0300 (ADT) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 88C5ED1B4F2 for ; Wed, 22 Oct 2003 20:51:19 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id RAB15191 for ; Wed, 22 Oct 2003 17:50:58 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16279.4988.496000.539525@gargle.gargle.HOWL> Date: Wed, 22 Oct 2003 17:32:12 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Newsgroups: ml.postgres.performance In-Reply-To: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/590 X-Sequence-Number: 4338 Vivek Khera writes: > AMI or Adaptec based? Adaptec, I think. AIC-7899 LVD SCSI is what dmidecode says, and Red Hat/Adaptec aacraid driver, Aug 18 2003 is what comes up when it boots. I haven't be able to use the aac utilities with this driver, however, so it's hard to interrogate the device. > If AMI, make sure it has write-back cache enabled (and you have > battery backup!), and disable the 'readahead' feature if you can. I can't do this so easily. It's at a colo, and it's production. I doubt this has anything to do with this problem, anyway. We're talking about hundreds of megabytes of data. > What's the disk utilization proir to running vacuum? If it is > hovering around 95% or more of capacity, of course you're gonna > overwhelm it. Here's the vmstat 5 at a random time: procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 0 0 0 272372 38416 78220 375048 0 3 2 0 0 0 2 2 0 0 0 0 272372 30000 78320 375660 0 0 34 274 382 284 5 1 94 0 1 0 272372 23012 78372 375924 0 0 25 558 445 488 8 2 90 1 0 0 272368 22744 78472 376192 0 6 125 594 364 664 9 3 88 And here's it during vacuum: procs memory swap io system cpu r b w swpd free buff cache si so bi bo in cs us sy id 1 2 1 277292 9620 72028 409664 46 32 4934 4812 1697 966 8 4 88 0 3 0 277272 9588 72096 412964 61 0 7303 2478 1391 976 3 3 94 2 2 0 277336 9644 72136 393264 1326 32 2827 2954 1693 1519 8 3 89 The pages are growing proportionately with the number of tuples, btw. Here's a vacuum snippet from a few days ago after a clean import, running every 15 minutes: INFO: Removed 2192 tuples in 275 pages. CPU 0.06s/0.01u sec elapsed 0.91 sec. INFO: Pages 24458: Changed 260, Empty 0; Tup 1029223: Vac 2192, Keep 3876, UnUsed 26. Total CPU 2.91s/2.22u sec elapsed 65.74 sec. And here's the latest today, running every 2 hours: INFO: Removed 28740 tuples in 1548 pages. CPU 0.08s/0.06u sec elapsed 3.73 sec. INFO: Pages 27277: Changed 367, Empty 0; Tup 1114178: Vac 28740, Keep 1502, UnUsed 10631. Total CPU 4.78s/4.09u sec elapsed 258.10 sec. The big tables/indexes are taking longer, but it's a big CPU/elapsed time savings to vacuum every two hours vs every 15 minutes. There's still the problem that when vacuum is running interactive performance drops dramatically. A query that takes a couple of seconds to run when the db isn't being vacuumed will take minutes when vacuum is running. It's tough for me to correlate exactly, but I suspect that while postgres is vacuuming an index or table, nothing else runs. In between relations, other stuff gets to run, and then vacuum hogs all the resources again. This could be for disk reasons or simply because postgres locks the index or table while it is being vacuumed. Either way, the behavior is unacceptable. Users shouldn't have to wait minutes while the database picks up after itself. The concept of vacuuming seems to be problematic. I'm not sure why the database simply can't garbage collect incrementally. AGC is very tricky, especially AGC that involves gigabytes of data on disk. Incremental garbage collection seems to be what other databases do, and it's been my experience that other databases don't have the type of unpredictable behavior I'm seeing with Postgres. I'd rather the database be a little bit slower on average than have to figure out the best time to inconvenience my users. Since my customer already has Oracle, we'll be running tests in the coming month(s :-) with Oracle to see how it performs under the same load and hardware. I'll keep this group posted. Rob From pgsql-performance-owner@postgresql.org Wed Oct 22 22:28: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 D1CBFD1B4F8 for ; Thu, 23 Oct 2003 01: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 29496-10 for ; Wed, 22 Oct 2003 22:28:04 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B31A0D1B4F2 for ; Wed, 22 Oct 2003 22:28:00 -0300 (ADT) 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 h9N1Rlit025481; Wed, 22 Oct 2003 21:27:47 -0400 (EDT) To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-reply-to: <16279.4988.496000.539525@gargle.gargle.HOWL> References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> Comments: In-reply-to Rob Nagler message dated "Wed, 22 Oct 2003 17:32:12 -0600" Date: Wed, 22 Oct 2003 21:27:47 -0400 Message-ID: <25480.1066872467@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/591 X-Sequence-Number: 4339 Rob Nagler writes: > Here's the vmstat 5 at a random time: > procs memory swap io system cpu > r b w swpd free buff cache si so bi bo in cs us sy id > 0 0 0 272372 38416 78220 375048 0 3 2 0 0 0 2 2 0 > 0 0 0 272372 30000 78320 375660 0 0 34 274 382 284 5 1 94 > 0 1 0 272372 23012 78372 375924 0 0 25 558 445 488 8 2 90 > 1 0 0 272368 22744 78472 376192 0 6 125 594 364 664 9 3 88 > And here's it during vacuum: > procs memory swap io system cpu > r b w swpd free buff cache si so bi bo in cs us sy id > 1 2 1 277292 9620 72028 409664 46 32 4934 4812 1697 966 8 4 88 > 0 3 0 277272 9588 72096 412964 61 0 7303 2478 1391 976 3 3 94 > 2 2 0 277336 9644 72136 393264 1326 32 2827 2954 1693 1519 8 3 89 The increased I/O activity is certainly to be expected, but what I find striking here is that you've got substantial swap activity in the second trace. What is causing that? Not VACUUM I don't think. It doesn't have any huge memory demand. But swapping out processes could account for the perceived slowdown in interactive response. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 22 22:47: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 D7934D1B4F8 for ; Thu, 23 Oct 2003 01:47: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 40144-01 for ; Wed, 22 Oct 2003 22:46:50 -0300 (ADT) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id 4E502D1B525 for ; Wed, 22 Oct 2003 22:46:41 -0300 (ADT) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9N1kUh0004227 for ; Thu, 23 Oct 2003 09:46:33 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9N1kUJT002674 for ; Thu, 23 Oct 2003 09:46:30 +0800 (SGT) Subject: Re: Postgresql performance To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Thu, 23 Oct 2003 09:46:32 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/23/2003 09:46:33 AM 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.7 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, QUOTED_EMAIL_TEXT X-Spam-Level: X-Archive-Number: 200310/592 X-Sequence-Number: 4340 Hi The Postgresql package came from the Redhat v9.0 CDROM. I have checked the version using psql --version and it showed v7.3.2 How to check the pg_dump version? Thank you, REgards. Josh Berkus cc: Subject: Re: [PERFORM] Postgresql performance 23/10/2003 12:06 AM NEC, > After a few weeks of usage, when we do a \d at the sql prompt, there was a > duplicate object name, ie it can be a duplicate row of index or table. > When we do a \d table_name, it will show a duplication of column names > inside the table. I think the version of PSQL and pg_dump which you are using do not match the back-end database version. Correct this. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 22 22:48: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 3EA91D1B518 for ; Thu, 23 Oct 2003 01:48: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 31714-09 for ; Wed, 22 Oct 2003 22:47:57 -0300 (ADT) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id 5084AD1B525 for ; Wed, 22 Oct 2003 22:47:52 -0300 (ADT) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9N1lsh0004312 for ; Thu, 23 Oct 2003 09:47:55 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9N1lsJT002773 for ; Thu, 23 Oct 2003 09:47:54 +0800 (SGT) Subject: Re: Postgresql performance To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Thu, 23 Oct 2003 09:47:56 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/23/2003 09:47:57 AM 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.2 tagged_above=0.0 required=5.0 tests=EMAIL_ATTRIBUTION, NO_REAL_NAME, QUOTED_EMAIL_TEXT X-Spam-Level: X-Archive-Number: 200310/593 X-Sequence-Number: 4341 Hi The Postgresql package came from the Redhat v9.0 CDROM. I have checked the version using psql --version and it showed v7.3.2 The duplication of table names is in the same schema. How to check the pg_dump version? Thank you, REgards. Tom Lane cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Postgresql performance 22/10/2003 10:03 PM CHEWTC@ap.nec.com.sg writes: > Currently we are running Postgresql v7.3.2 on Redhat Linux OS v9.0. We have > Windows2000 client machines inserting records into the Postgresql tables > via ODBC. > After a few weeks of usage, when we do a \d at the sql prompt, there was a > duplicate object name, ie it can be a duplicate row of index or table. > When we do a \d table_name, it will show a duplication of column names > inside the table. Are you sure you are using 7.3 psql? This sounds like something that could happen with a pre-7.3 (not schema aware) psql, if there are multiple occurrences of the same table name in different schemas. > It doesnt affect the insertion/updating of the tables, but when we do a > pg_dump -Da -t > /exp/.sql, it will not > do a proper backup/dump. I'd wonder about whether you have the right pg_dump, too. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 23 03:15: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 B88E5D1B4FD for ; Thu, 23 Oct 2003 06:15: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 89710-01 for ; Thu, 23 Oct 2003 03:15:04 -0300 (ADT) Received: from relay.icomedias.com (relay.icomedias.com [62.99.232.66]) by svr1.postgresql.org (Postfix) with ESMTP id C245CD1B4E6 for ; Thu, 23 Oct 2003 03:15:01 -0300 (ADT) Received: from loki.icomedias.com ([10.192.17.128]) by relay.icomedias.com (8.12.10/8.12.10) with ESMTP id h9N6Eu5A026552 for ; Thu, 23 Oct 2003 08:14:56 +0200 From: Mario Weilguni To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Thu, 23 Oct 2003 08:14:56 +0200 User-Agent: KMail/1.5.4 References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> In-Reply-To: <16279.4988.496000.539525@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310230814.56738.mweilguni@sime.com> X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/594 X-Sequence-Number: 4342 Am Donnerstag, 23. Oktober 2003 01:32 schrieb Rob Nagler: > The concept of vacuuming seems to be problematic. I'm not sure why > the database simply can't garbage collect incrementally. AGC is very > tricky, especially AGC that involves gigabytes of data on disk. > Incremental garbage collection seems to be what other databases do, > and it's been my experience that other databases don't have the type > of unpredictable behavior I'm seeing with Postgres. I'd rather the > database be a little bit slower on average than have to figure out the > best time to inconvenience my users. I think oracle does not do garbage collect, it overwrites the tuples directly and stores the old tuples in undo buffers. Since most transactions are commits, this is a big win. From pgsql-performance-owner@postgresql.org Thu Oct 23 04:01: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 1C2FAD1B4E5 for ; Thu, 23 Oct 2003 07:01: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 92114-02 for ; Thu, 23 Oct 2003 04:00:53 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id 823A8D1B4E6 for ; Thu, 23 Oct 2003 04:00:50 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886; Thu, 23 Oct 2003 09:00:48 +0200 Message-ID: <008701c39933$cd421df0$b696a8c0@APR> From: "Alexander Priem" To: "Will LaShell" Cc: "scott.marlowe" , References: <1066771678.29522.25.camel@lyric.ofsloans.com> <017c01c39874$63feb110$b696a8c0@APR> <1066836536.29522.28.camel@lyric.ofsloans.com> Subject: Re: RAID controllers etc... was: PostgreSQL data on aNAS device ? Date: Thu, 23 Oct 2003 09:03:46 +0200 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.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: 200310/595 X-Sequence-Number: 4343 I have been searching (www.lsil.com) for this megaraid_2 driver you mentioned. What kind of MegaRaid card does the Perc4/Di match? Elite1600? Elite1650? I picked Elite1600 and the latest driver I found was version 2.05.00. Is this one OK for RedHat 9? The README file present only mentions RedHat8... Kind regards, Alexander. From pgsql-performance-owner@postgresql.org Thu Oct 23 05:38: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 E4ED6D1B501 for ; Thu, 23 Oct 2003 08:38: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 09050-02 for ; Thu, 23 Oct 2003 05:38:04 -0300 (ADT) Received: from mail.cict.nl (vnd-7521.mxs.adsl.euronet.nl [62.234.149.33]) by svr1.postgresql.org (Postfix) with ESMTP id AD10ED1B4EC for ; Thu, 23 Oct 2003 05:37:59 -0300 (ADT) Received: from APR ([192.168.150.182]) by mail.cict.nl (Merak 6.0.5) with SMTP id DUC73886 for ; Thu, 23 Oct 2003 10:38:00 +0200 Message-ID: <00f701c39941$614bfe00$b696a8c0@APR> From: "Alexander Priem" To: References: <1066771678.29522.25.camel@lyric.ofsloans.com> <017c01c39874$63feb110$b696a8c0@APR> <1066836536.29522.28.camel@lyric.ofsloans.com> <008701c39933$cd421df0$b696a8c0@APR> Subject: RedHat Enterprise Linux ES 3 ?!?! Date: Thu, 23 Oct 2003 10:40:58 +0200 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.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.6 tagged_above=0.0 required=5.0 tests=MANY_EXCLAMATIONS, PLING_QUERY, REFERENCES X-Spam-Level: X-Archive-Number: 200310/596 X-Sequence-Number: 4344 Hi guys, This basically continues the other thread about the PERC4 RAID controller, but since it is a bit off-topic I thought to start another thread. Thanks for all your help so far :) Earlier today I read about the newly released RedHat Enterprise Linux ES version 3. This version should include out-of-the-box megaraid_2 drivers, so it would support the Dell PERC4/Di RAID controller. However, it is very much more expensive than RedHat Linux 9. RH Linux 9 is free and the Enterpise ES edition will cost between 400 and several 1.000's of dollars, depending on the support you want to go with it. Do any of you guys have experience with the previous version of Enterprise Linux (that would be version 2.1) or even better, are any of you already using version 3? Would you recommend this over RedHat Linux 9? I think that with RH Linux 9 it would be easier to get all the latest versions of components I need (RPMs for PostgreSQL, Apache, Samba etc.), while my guess would be that Enterprise Linux would be more difficult to upgrade... Also, I cannot find any list of packages included in Enterprise Linux 2.1 / 3. Does anyone know if PostgreSQL is included and if so, what version? Kind regards, Alexander Priem. From pgsql-performance-owner@postgresql.org Thu Oct 23 07:14: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 8EDFDD1B52D for ; Thu, 23 Oct 2003 10:14: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 17871-06 for ; Thu, 23 Oct 2003 07:14:26 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 39A36D1B529 for ; Thu, 23 Oct 2003 07:14:23 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1ACcU5-0007gY-00 for ; Thu, 23 Oct 2003 06:14:25 -0400 Received: by dba2 (Postfix, from userid 1019) id B5300CD6A; Thu, 23 Oct 2003 06:14:25 -0400 (EDT) Date: Thu, 23 Oct 2003 06:14:25 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Message-ID: <20031023101425.GC16878@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> <25480.1066872467@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25480.1066872467@sss.pgh.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/597 X-Sequence-Number: 4345 On Wed, Oct 22, 2003 at 09:27:47PM -0400, Tom Lane wrote: > trace. What is causing that? Not VACUUM I don't think. It doesn't have > any huge memory demand. But swapping out processes could account for What about if you've set vacuum_mem too high? 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 Oct 24 15:00: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 6E84FD1B510 for ; Thu, 23 Oct 2003 12:18: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 44627-02 for ; Thu, 23 Oct 2003 09:17:44 -0300 (ADT) Received: from fed1mtao07.cox.net (fed1mtao07.cox.net [68.6.19.124]) by svr1.postgresql.org (Postfix) with ESMTP id C29E1D1B4F2 for ; Thu, 23 Oct 2003 09:17:25 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao07.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031023121725.YNHM13061.fed1mtao07.cox.net@toolsmythes01> for ; Thu, 23 Oct 2003 08:17:25 -0400 Reply-To: From: "John Pagakis" To: Subject: Performance Concern Date: Thu, 23 Oct 2003 05:21:03 -0700 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.6604 (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-Spam-Status: No, hits=2.5 tagged_above=0.0 required=5.0 tests=BANG_QUOTE, MSGID_GOOD_EXCHANGE X-Spam-Level: ** X-Archive-Number: 200310/623 X-Sequence-Number: 4371 Greetings. I have a table that will require 100,000 rows initially. Assume the following (some of the field names have been changed for confidentiality reasons): CREATE TABLE baz ( baz_number CHAR(15) NOT NULL, customer_id CHAR(39), foobar_id INTEGER, is_cancelled BOOL DEFAULT false NOT NULL, create_user VARCHAR(60) NOT NULL, create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, last_update_user VARCHAR(60) NOT NULL, last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, CONSTRAINT PK_baz PRIMARY KEY (baz_number) ); ALTER TABLE baz ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); ALTER TABLE baz ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); Using JDBC, it took approximately one hour to insert 100,000 records. I have an algorithm to generate a unique baz_number - it is a mixture of alpha and numerics. There is a purchase table; one purchase can have many associated baz records, but the baz records will be pre-allocated - baz.customer_id allows null. The act of purchasing a baz will cause baz.customer_id to be populated from the customer_id (key) field in the purchase table. If it took an hour to insert 100,000 records, I can only imagine how much time it will take if one customer were to attempt to purchase all 100,000 baz. Certainly too long for a web page. I've not had to deal with this kind of volume in Postgres before; I have my suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) but I'd *LOVE* any thoughts. Would I be better off making the key an identity field and not indexing on baz_number? Thanks in advance for any help. __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "The best way to make your dreams come true is to wake up." -- Paul Valery This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com From pgsql-performance-owner@postgresql.org Thu Oct 23 10:18: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 B028DD1B517 for ; Thu, 23 Oct 2003 13:18: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 47320-07 for ; Thu, 23 Oct 2003 10:17:47 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 4373FD1B510 for ; Thu, 23 Oct 2003 10:17:43 -0300 (ADT) 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 h9NDHfit029065; Thu, 23 Oct 2003 09:17:41 -0400 (EDT) To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-reply-to: <20031023101425.GC16878@libertyrms.info> References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> <25480.1066872467@sss.pgh.pa.us> <20031023101425.GC16878@libertyrms.info> Comments: In-reply-to Andrew Sullivan message dated "Thu, 23 Oct 2003 06:14:25 -0400" Date: Thu, 23 Oct 2003 09:17:41 -0400 Message-ID: <29064.1066915061@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/598 X-Sequence-Number: 4346 Andrew Sullivan writes: > On Wed, Oct 22, 2003 at 09:27:47PM -0400, Tom Lane wrote: >> trace. What is causing that? Not VACUUM I don't think. It doesn't have >> any huge memory demand. But swapping out processes could account for > What about if you've set vacuum_mem too high? Maybe, but only if it actually had reason to use a ton of memory --- that is, it were recycling a very large number of tuples in a single table. IIRC that didn't seem to be the case here. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 23 10:25: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 BF517D1B4FE for ; Thu, 23 Oct 2003 13:25: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 47288-10 for ; Thu, 23 Oct 2003 10:25:06 -0300 (ADT) Received: from mta4.srv.hcvlny.cv.net (mta4.srv.hcvlny.cv.net [167.206.5.70]) by svr1.postgresql.org (Postfix) with ESMTP id B7885D1B520 for ; Thu, 23 Oct 2003 10:24:46 -0300 (ADT) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta4.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HN700447P8PDV@mta4.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Thu, 23 Oct 2003 09:24:26 -0400 (EDT) Date: Thu, 23 Oct 2003 09:26:49 -0400 From: Allen Landsidel Subject: My own performance/tuning q&a X-Sender: bsdasym@pop.hotpop.com To: pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031023090320.0242d6c8@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 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: 200310/599 X-Sequence-Number: 4347 Asked and answered on the list probably a thousand times, but what else is there to discuss on the performance list? :) I recently built a rather powerful machine to be used in a heavily accessed database.. the machine is a dual AthlonMP 2800+, 2GB of PC2100 ECC, and a 4x18GB RAID-0 using 15k rpm fujitsu MAS drives on a 4ch u160 ICP-Vortex card with 256MB of cache. The box runs FreeBSD, tracking RELENG_4 (-STABLE) and PostGreSQL 7.3.4 from ports (7.3.4_1) There are a few databases running on the machine, but for now, the one that is the most performance sensitive is also arguably the worst designed. The access pattern on a day to day basis looks basically like this: 1. ~75k rows aggregate are inserted into two different tables, 70/30 split between two tables. The 70% going to the smaller table (containing just two integers) and the 30% going into a larger table containing a rather largish (~4KB) text field and more integer types; no searching of any kind is done on this text field, it appears in no where clauses, and is not indexed. 2. As these rows are inserted, other processes see them and for each row: a. A new row containing just one field is inserted, that row being an FK into the 30% table mentioned above. b. A row in a 3rd table is updated; this table never gets deleted from, and rarely sees inserts, it's just a status table, but it has nearly a million rows. The updated row is an integer. c. The 30% table itself is updated. 3. When these processes finish their processing, the rows in both the 70/30 tables and the table from 2a are deleted; The 2b table has a row again updated. There is only one process that does all the inserting, from a web backend. Steps 2 and 3 are done by several other backend processes on different machines, "fighting" to pick up the newly inserted rows and process them. Not the most efficient design, but modifying the current code isn't an option; rest assured that this is being redesigned and new code is being written, but the developer who wrote the original left us with his spaghetti-python mess and no longer works for us. I run a 'vacuum analyze verbose' on the database in question every hour, and a reindex on every table in the database every six hours, 'vacuum full' is run manually as required perhaps anywhere from once a week to once a month. I realize the analyze may not be running often enough and the reindex more often than need be, but I don't think these are adversely affecting performance very much; degredation over time does not appear to be an issue. So on with the question. Given the above machine with the above database and access pattern, I've configured the system with the following options. I'm just wondering what some of you more experierenced pg tuners have to say. I can provide more information such as ipcs, vmstat, iostat, etc output on request but I figure this message is getting long enough already.. Thanks for any input. Kernel and postgres information follows. Related kernel configuration options: ... cpu I686_CPU maxusers 256 ... options MAXDSIZ="(1024UL*1024*1024)" options MAXSSIZ="(512UL*1024*1024)" options DFLDSIZ="(512UL*1024*1024)" ... options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues options SYSVSEM #SYSV-style semaphores options SHMMAXPGS=65536 options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)" options SHMSEG=256 options SEMMNI=384 options SEMMNS=768 options SEMMNU=384 options SEMMAP=384 ... relevant postgresql.conf options: max_connections = 128 shared_buffers = 20000 max_fsm_relations = 10000 max_fsm_pages = 2000000 max_locks_per_transaction = 64 wal_buffers = 128 sort_mem = 262144 # we have some large queries running at times vacuum_mem = 131072 checkpoint_segments = 16 checkpoint_timeout = 300 commit_delay = 1000 commit_siblings = 32 fsync = true wal_fsync_method = fsync effective_cache_size = 49152 # 384MB, this could probably be higher random_page_cost = 1.7 cpu_tuble_cost = 0.005 cpu_index_tuple_cost = 0.0005 cpu_operator_cost = 0.0012 geqo_threshold = 20 stats_start_collector = true stats_reset_on_server_start = off stats_command_string = true stats_row_level = true stats_block_level = true From pgsql-performance-owner@postgresql.org Thu Oct 23 10:27: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 A77AED1B4F2 for ; Thu, 23 Oct 2003 13:27: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 47150-08 for ; Thu, 23 Oct 2003 10:26:56 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9DB68D1B527 for ; Thu, 23 Oct 2003 10:26:52 -0300 (ADT) 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 h9NDQuit029124; Thu, 23 Oct 2003 09:26:56 -0400 (EDT) To: Mario Weilguni Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-reply-to: <200310230814.56738.mweilguni@sime.com> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> Comments: In-reply-to Mario Weilguni message dated "Thu, 23 Oct 2003 08:14:56 +0200" Date: Thu, 23 Oct 2003 09:26:55 -0400 Message-ID: <29123.1066915615@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/600 X-Sequence-Number: 4348 Mario Weilguni writes: > I think oracle does not do garbage collect, it overwrites the tuples directly > and stores the old tuples in undo buffers. Since most transactions are > commits, this is a big win. ... if all tuples are the same size, and if you never have any transactions that touch enough tuples to overflow your undo segment (or even just sit there for a long time, preventing you from recycling undo-log space; this is the dual of the VACUUM-can't-reclaim-dead-tuple problem). And a few other problems that any Oracle DBA can tell you about. I prefer our system. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 23 10:55:21 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 15258D1B50E for ; Thu, 23 Oct 2003 13:55: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 56364-06 for ; Thu, 23 Oct 2003 10:54:45 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id F042BD1B520 for ; Thu, 23 Oct 2003 10:54:40 -0300 (ADT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1ACfvJ-000471-00 for ; Thu, 23 Oct 2003 09:54:45 -0400 Received: by dba2 (Postfix, from userid 1019) id 6ACECCD6D; Thu, 23 Oct 2003 09:54:45 -0400 (EDT) Date: Thu, 23 Oct 2003 09:54:45 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Message-ID: <20031023135445.GC17402@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> <25480.1066872467@sss.pgh.pa.us> <20031023101425.GC16878@libertyrms.info> <29064.1066915061@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29064.1066915061@sss.pgh.pa.us> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/601 X-Sequence-Number: 4349 On Thu, Oct 23, 2003 at 09:17:41AM -0400, Tom Lane wrote: > > Maybe, but only if it actually had reason to use a ton of memory --- > that is, it were recycling a very large number of tuples in a single > table. IIRC that didn't seem to be the case here. Ah, that's what I was trying to ask. I didn't know if the memory was actually taken by vacuum at the beginning (like shared memory is) or what-all happened. 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 Oct 23 12:25: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 90BC0D1B525 for ; Thu, 23 Oct 2003 15:25: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 72212-04 for ; Thu, 23 Oct 2003 12:25:18 -0300 (ADT) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 77A10D1B51E for ; Thu, 23 Oct 2003 12:25:14 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB18911 for ; Thu, 23 Oct 2003 09:25:08 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16279.61590.158000.290397@gargle.gargle.HOWL> Date: Thu, 23 Oct 2003 09:15:34 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <29123.1066915615@sss.pgh.pa.us> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/602 X-Sequence-Number: 4350 Tom Lane writes: > ... if all tuples are the same size, and if you never have any Incorrect. If the tuples smaller, Oracle does the right thing. If there's enough space in the page, it shifts the tuples to make room. That's what pctfree, pctused and pctincrease allow you to control. It's all in memory so its fast, and I don't think it has to update any indices. > transactions that touch enough tuples to overflow your undo segment That's easily configured, and hasn't been a problem in the databases I've managed. > (or even just sit there for a long time, preventing you from recycling That's probably bad software or a batch system--which is tuned differently. Any OLTP system has to be able to partition its problems to keep transactions short and small. If it doesn't, it will not be usable. > undo-log space; this is the dual of the VACUUM-can't-reclaim-dead-tuple > problem). And a few other problems that any Oracle DBA can tell you > about. I prefer our system. Oracle seems to make the assumption that data changes, which is why it manages free space within each page as well as within free lists. The database will be bigger but you get much better performance on DML. It is very good at caching so reads are fast. Postgres seems to make the assumption that updates and deletes are rare. A delete/insert policy for updates means that a highly indexed table requires lots of disk I/O when the update happens and the concomitant garbage collection when vacuum runs. But then MVCC makes the assumption that there's lots of DML. I don't understand the philosphical split here. I guess I don't understand what application profiles/statistics makes you prefer Postgres' approach over Oracle's. > The increased I/O activity is certainly to be expected, but what I find > striking here is that you've got substantial swap activity in the second > trace. What is causing that? Not VACUUM I don't think. It doesn't have > any huge memory demand. But swapping out processes could account for > the perceived slowdown in interactive response. The box is a bit memory starved, and we'll be addressing that shortly. I don't think it accounts for 3 minute queries, but perhaps it might. vacuum_mem is 32mb, btw. Rob From pgsql-performance-owner@postgresql.org Thu Oct 23 12:28: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 AD78CD1B4E4 for ; Thu, 23 Oct 2003 15: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 73791-05 for ; Thu, 23 Oct 2003 12:28:01 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id E3770D1B517 for ; Thu, 23 Oct 2003 12:27:59 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Thu, 23 Oct 2003 10:27:45 -0500 Subject: Re: RedHat Enterprise Linux ES 3 ?!?! From: Will LaShell To: Alexander Priem Cc: pgsql-performance@postgresql.org In-Reply-To: <00f701c39941$614bfe00$b696a8c0@APR> References: <1066771678.29522.2 5.camel@lyric.ofsloans.com> <017c01c39874$63feb110$b696a8c0@APR> <1066836536.29522.28.camel@lyric.ofsloans.com> <008701c39933$cd421df0$b696a8c0@APR> <00f701c39941$614bfe00$b696a8c0@APR> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-kMMi7Dl5FyTCQnwqmKJ/" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 23 Oct 2003 08:27:43 -0700 Message-Id: <1066922865.30146.47.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/603 X-Sequence-Number: 4351 --=-kMMi7Dl5FyTCQnwqmKJ/ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-10-23 at 01:40, Alexander Priem wrote: > Hi guys, >=20 > This basically continues the other thread about the PERC4 RAID controller, > but since it is a bit off-topic I thought to start another thread. Thanks > for all your help so far :) >=20 > Earlier today I read about the newly released RedHat Enterprise Linux ES > version 3. This version should include out-of-the-box megaraid_2 drivers,= so > it would support the Dell PERC4/Di RAID controller. >=20 > However, it is very much more expensive than RedHat Linux 9. RH Linux 9 is > free and the Enterpise ES edition will cost between 400 and several 1.000= 's > of dollars, depending on the support you want to go with it. >=20 > Do any of you guys have experience with the previous version of Enterprise > Linux (that would be version 2.1) or even better, are any of you already > using version 3? >=20 > Would you recommend this over RedHat Linux 9? I think that with RH Linux 9 > it would be easier to get all the latest versions of components I need (R= PMs > for PostgreSQL, Apache, Samba etc.), while my guess would be that Enterpr= ise > Linux would be more difficult to upgrade... The reason to get RHEL over RH9 or the upcoming Fedora releases is for stability. They have a -much- longer stability period, release cycle, and support lifetime. You get RHEL if you want a distribution that you can get commercial support for, install the server and then not touch it. For production machines of this nature you'll pretty much never have the latest and greatest packages. Instead you'll have the most completely stable packages. The two distribution types are really apples and oranges. They are both fruit ( they are both linux distros ) but they sure taste different. > Also, I cannot find any list of packages included in Enterprise Linux 2.1= / > 3. Does anyone know if PostgreSQL is included and if so, what version? You have two options as I understand it for PG under RHEL. You can install the PG source from Postgres themselves, or you can use the Postgresql Red Hat Edition. Bruce I think can give you more information on this product. http://sources.redhat.com/rhdb/index.html This is the link to it. >=20 > Kind regards, > Alexander Priem. Hope this helps, Will --=-kMMi7Dl5FyTCQnwqmKJ/ 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/l/NvZr3R5kgOZd0RAnqxAJ9slhP2vnHcqa/72AE492i7r6RyvACcDFdP pGPhLugoY0SEHwBT5fpqcGI= =b99O -----END PGP SIGNATURE----- --=-kMMi7Dl5FyTCQnwqmKJ/-- From pgsql-performance-owner@postgresql.org Thu Oct 23 12:42: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 5E933D1B50C for ; Thu, 23 Oct 2003 15:42: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 78271-01 for ; Thu, 23 Oct 2003 12:41:58 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id A289BD1B532 for ; Thu, 23 Oct 2003 12:41:56 -0300 (ADT) 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 h9NFelDd013413; Thu, 23 Oct 2003 09:40:47 -0600 (MDT) Date: Thu, 23 Oct 2003 09:29:28 -0600 (MDT) From: "scott.marlowe" To: Alexander Priem Cc: Will LaShell , Subject: Re: RAID controllers etc... was: PostgreSQL data on aNAS In-Reply-To: <008701c39933$cd421df0$b696a8c0@APR> 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: 200310/604 X-Sequence-Number: 4352 On Thu, 23 Oct 2003, Alexander Priem wrote: > I have been searching (www.lsil.com) for this megaraid_2 driver you > mentioned. > > What kind of MegaRaid card does the Perc4/Di match? Elite1600? Elite1650? > > I picked Elite1600 and the latest driver I found was version 2.05.00. Is > this one OK for RedHat 9? The README file present only mentions RedHat8... I would guess it's a MegaRaid320-2 card, listed here: http://www.lsilogic.com/products/stor_prod/raid/3202.html Since the Elite1600/1650 seem to be U160 cards and the Perc/4Di would seem to be listed as a U320 card at this page: http://www.domsch.com/linux/ From pgsql-performance-owner@postgresql.org Thu Oct 23 12:44: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 5FFC5D1B50E for ; Thu, 23 Oct 2003 15:44: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 78253-04 for ; Thu, 23 Oct 2003 12:44:21 -0300 (ADT) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 0EDA0D1B4E6 for ; Thu, 23 Oct 2003 12:44:19 -0300 (ADT) 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 h9NEi9cM007595; Thu, 23 Oct 2003 10:44:10 -0400 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 h9NFiAl10953; Thu, 23 Oct 2003 11:44:11 -0400 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 V3JRQJTS; Thu, 23 Oct 2003 11:44:09 -0400 Subject: Re: RedHat Enterprise Linux ES 3 ?!?! From: Robert Treat To: Will LaShell Cc: Alexander Priem , pgsql-performance@postgresql.org In-Reply-To: <1066922865.30146.47.camel@lyric.ofsloans.com> References: <1066922865.30146.47.camel@lyric.ofsloans.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 23 Oct 2003 11:44:10 -0400 Message-Id: <1066923850.2063.11568.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/605 X-Sequence-Number: 4353 On Thu, 2003-10-23 at 11:27, Will LaShell wrote: > > Also, I cannot find any list of packages included in Enterprise Linux > 2.1 / > > 3. Does anyone know if PostgreSQL is included and if so, what version? > > You have two options as I understand it for PG under RHEL. You can > install the PG source from Postgres themselves, or you can use the > Postgresql Red Hat Edition. Bruce I think can give you more information > on this product. http://sources.redhat.com/rhdb/index.html This is the > link to it. > Bruce works for SRA, not Red Hat, so he's probably not your best option to talk to on PRHE... While there are Red Hat employees floating around these lists, I'd first suggest reading over the website and then either emailing the PRHE lists or one of it's team members depending on the specifics of any questions. Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Thu Oct 23 13:25: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 B9659D1B51A for ; Thu, 23 Oct 2003 16:25: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 78718-09 for ; Thu, 23 Oct 2003 13:24:57 -0300 (ADT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by svr1.postgresql.org (Postfix) with ESMTP id CE233D1B4ED for ; Thu, 23 Oct 2003 13:24:56 -0300 (ADT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Thu, 23 Oct 2003 11:24:53 -0500 Subject: Re: RedHat Enterprise Linux ES 3 ?!?! From: Will LaShell To: Robert Treat Cc: Alexander Priem , pgsql-performance@postgresql.org In-Reply-To: <1066923850.2063.11568.camel@camel> References: <1066922865.30146.47.camel@lyric.ofsloans.com> <1066923850.2063.11568.camel@camel> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-yBYeHTM9XTDidw98z8uE" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-11) Date: 23 Oct 2003 09:24:50 -0700 Message-Id: <1066926292.30146.51.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/606 X-Sequence-Number: 4354 --=-yBYeHTM9XTDidw98z8uE Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-10-23 at 08:44, Robert Treat wrote: > On Thu, 2003-10-23 at 11:27, Will LaShell wrote: > > > Also, I cannot find any list of packages included in Enterprise Linux > > 2.1 / > > > 3. Does anyone know if PostgreSQL is included and if so, what version? > >=20 > > You have two options as I understand it for PG under RHEL. You can > > install the PG source from Postgres themselves, or you can use the > > Postgresql Red Hat Edition. Bruce I think can give you more information > > on this product. http://sources.redhat.com/rhdb/index.html This is the > > link to it. > >=20 >=20 > Bruce works for SRA, not Red Hat, so he's probably not your best option > to talk to on PRHE... While there are Red Hat employees floating around Gah that's right. *beats self* > these lists, I'd first suggest reading over the website and then either > emailing the PRHE lists or one of it's team members depending on the > specifics of any questions. Don't forget you can always call the RedHat sales people as well. They usually have good product knowledge especially since you are talking about the Advanced Server lines. > Robert Treat > --=20 > Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL Will --=-yBYeHTM9XTDidw98z8uE 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/mADSZr3R5kgOZd0RAuL/AKCWhU0KeMqNYzemzkUq1LcBo6K6BACggR1o hYZNsU7ePh0qEHpGOSDooOY= =4jGO -----END PGP SIGNATURE----- --=-yBYeHTM9XTDidw98z8uE-- From pgsql-performance-owner@postgresql.org Thu Oct 23 14:00: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 925E0D1B51E for ; Thu, 23 Oct 2003 17:00: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 86287-10 for ; Thu, 23 Oct 2003 14:00:26 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id CD61AD1B4EF for ; Thu, 23 Oct 2003 14:00:22 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9NGuWG27218; Thu, 23 Oct 2003 12:56:32 -0400 (EDT) From: Bruce Momjian Message-Id: <200310231656.h9NGuWG27218@candle.pha.pa.us> Subject: Re: RedHat Enterprise Linux ES 3 ?!?! In-Reply-To: <1066923850.2063.11568.camel@camel> To: Robert Treat Date: Thu, 23 Oct 2003 12:56:32 -0400 (EDT) Cc: Will LaShell , Alexander Priem , 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: 200310/607 X-Sequence-Number: 4355 Robert Treat wrote: > On Thu, 2003-10-23 at 11:27, Will LaShell wrote: > > > Also, I cannot find any list of packages included in Enterprise Linux > > 2.1 / > > > 3. Does anyone know if PostgreSQL is included and if so, what version? > > > > You have two options as I understand it for PG under RHEL. You can > > install the PG source from Postgres themselves, or you can use the > > Postgresql Red Hat Edition. Bruce I think can give you more information > > on this product. http://sources.redhat.com/rhdb/index.html This is the > > link to it. > > > > Bruce works for SRA, not Red Hat, so he's probably not your best option > to talk to on PRHE... While there are Red Hat employees floating around > these lists, I'd first suggest reading over the website and then either > emailing the PRHE lists or one of it's team members depending on the > specifics of any questions. Way off topic, but let's do Red Hat a favor for employing PostgreSQL folks --- here is a nice URL I read yesterday on the topic: http://news.com.com/2100-7344-5094774.html?tag=nl -- 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 Fri Oct 24 15:01: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 A0A02D1B522 for ; Thu, 23 Oct 2003 18:19: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 07516-01 for ; Thu, 23 Oct 2003 15:18:51 -0300 (ADT) Received: from web41215.mail.yahoo.com (web41215.mail.yahoo.com [66.218.93.48]) by svr1.postgresql.org (Postfix) with SMTP id BE0A8D1B50E for ; Thu, 23 Oct 2003 15:18:49 -0300 (ADT) Message-ID: <20031023181831.40095.qmail@web41215.mail.yahoo.com> Received: from [68.4.186.147] by web41215.mail.yahoo.com via HTTP; Thu, 23 Oct 2003 11:18:31 PDT Date: Thu, 23 Oct 2003 11:18:31 -0700 (PDT) From: Rob Messer Subject: Use of multipart index with "IN" To: pgsql-performance@postgresql.org In-Reply-To: <20030805222609.GF94710@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/624 X-Sequence-Number: 4372 I have a reporting system that does regular queries on a table with a multipart index. I am running version 7.3.4. Here is the table definition: Table "public.ds_rec_fld" Column | Type | Modifiers ---------------+-------------------------+----------- dsid | character varying(20) | not null recid | integer | not null field_name | character varying(20) | not null option_tag | character varying(10) | not null option_value | integer | field_text | character varying(2000) | field_type_cd | character varying(8) | Indexes: ds_rf_ndx1 btree (recid, field_name, option_value) Normally queries are done using recid and field_name, so Postgresql returns rows very quickly as expected. Here is a sample explain analyze output for a typical query: db=> explain analyze db-> select field_name, option_tag from ds_rec_fld where recid = 3000 and field_name = 'Q3A1'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- Index Scan using ds_rf_ndx1 on ds_rec_fld (cost=0.00..163.09 rows=40 width=38) (actual time=0.06..0.07 rows=1 loops=1) Index Cond: ((recid = 3001) AND (field_name = 'Q3A1'::character varying)) Total runtime: 0.12 msec (3 rows) The problem comes in when we are selecting multiple field_name values in one query. The normal SQL syntax we have been using is like this: select field_name, option_tag from ds_rec_fld where recid = 3001 and field_name in ('Q3A1', 'Q3A9'); This is just a simplified example, at times there can be a lot of field_name values in one query in the "in" clause. Here postgresql refuses to use the full index, instead doing a filter based on part of the first recid part of index. Here is the explain analyze output: Index Scan using ds_rf_ndx1 on ds_rec_fld (cost=0.00..30425.51 rows=80 width=38) (actual time=0.18..1.08 rows=2 loops=1) Index Cond: (recid = 3001) Filter: ((field_name = 'Q3A1'::character varying) OR (field_name = 'Q3A9'::character varying)) Total runtime: 1.12 msec (4 rows) So, 10 times longer. This is an issue because at times we are iterating through thousands of recid values. I did a vacuum analyze, adjusted random_page_cost, etc. all to no avail. I also noticed that the problem goes away when I reformat the query like this: select field_name, option_tag from ds_rec_fld where (recid = 3001 and field_name = 'Q3A1') or (recid = 3001 and field_name = 'Q3A9') Here is the explain analyze output for this: Index Scan using ds_rf_ndx1, ds_rf_ndx1 on ds_rec_fld (cost=0.00..326.57 rows=80 width=38) (actual time=0.07..0.10 rows=2 loops=1) Index Cond: (((recid = 3001) AND (field_name = 'Q3A1'::character varying)) OR ((recid = 3001) AND (field_name = 'Q3A9'::character varying))) Total runtime: 0.16 msec (3 rows) Much better. So I have partially solved my own problem, but there are other places that this is not this simple to fix. Therefore, my question is, is there some way to force postgresql to use the full index and still stick with the shorter "field_name in ('...', '...')" syntax? If anyone has any thoughts please let me know. Also it strikes me that perhaps the optimizer could be tweaked to treat the first case like the second one. Thanks in advance, Rob __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com From pgsql-performance-owner@postgresql.org Thu Oct 23 17:53: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 F37ADD1B538 for ; Thu, 23 Oct 2003 20:53: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 35736-02 for ; Thu, 23 Oct 2003 17:53:07 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 3EDF5D1B511 for ; Thu, 23 Oct 2003 17:53:05 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id D40CA3E34 for ; Thu, 23 Oct 2003 16:53:06 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 42288-03 for ; Thu, 23 Oct 2003 16:53:06 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 4BF343E2D for ; Thu, 23 Oct 2003 16:53:06 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9NKr6EO015939 for pgsql-performance@postgresql.org; Thu, 23 Oct 2003 16:53:06 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: vacuum locking Date: Thu, 23 Oct 2003 16:53:05 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 37 Message-ID: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066942386 45861 216.194.193.105 (23 Oct 2003 20:53:06 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Thu, 23 Oct 2003 20:53:06 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:btiQIYMSsvu14LH6dWGA7eJ3EwM= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/608 X-Sequence-Number: 4356 >>>>> "RN" == Rob Nagler writes: RN> Vivek Khera writes: >> AMI or Adaptec based? RN> Adaptec, I think. AIC-7899 LVD SCSI is what dmidecode says, and RN> Red Hat/Adaptec aacraid driver, Aug 18 2003 is what comes up when it Cool. No need to diddle with it, then. The Adaptec work quite well, especially if you have battery backup. Anyhow, it seems that as Tom mentioned, you are going into swap when your vacuum runs, so I'll suspect you're just at the edge of total memory utilization, and then you go over the top. Another theory is that the disk capacity is near saturation, the vacuum causes it to slow down just a smidge, and then your application opens additional connections to handle the incoming requests which don't complete fast enough, causing more memory usage with the additional postmasters created. Again, you suffer the slow spiral of death due to resource shortage. I'd start by getting full diagnosis of overall what your system is doing during the vacuum (eg, additional processes created) then see if adding RAM will help. Also, how close are you to the capacity of your disk bandwidth? I don't see that in your numbers. I know in freebsd I can run "systat -vmstat" and it gives me a percentage of utilization that lets me know when I'm near the capacity. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Thu Oct 23 17:54: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 07E22D1B510 for ; Thu, 23 Oct 2003 20: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 33987-10 for ; Thu, 23 Oct 2003 17:54:27 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 5697DD1B4F2 for ; Thu, 23 Oct 2003 17:54:25 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 7E73E3E34 for ; Thu, 23 Oct 2003 16:54:27 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 42288-03-2 for ; Thu, 23 Oct 2003 16:54:27 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 01DF93E2D for ; Thu, 23 Oct 2003 16:54:27 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9NKsQJD018461 for pgsql-performance@postgresql.org; Thu, 23 Oct 2003 16:54:26 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: slow select Date: Thu, 23 Oct 2003 16:54:26 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 17 Message-ID: References: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> <200310221442.56816.josh@agliodbs.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066942466 45861 216.194.193.105 (23 Oct 2003 20:54:26 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Thu, 23 Oct 2003 20:54:26 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:efcDUtOREWDuVCRdZJq9zu3qH6Y= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/609 X-Sequence-Number: 4357 >>>>> "JB" == Josh Berkus writes: JB> Medora, >> Increasing effective_cache_size to 10000 did it. JB> That would be 78MB RAM. If you have more than that available, you can JB> increase it further. Ideally, it should be about 2/3 to 3/4 of available JB> RAM. Assuming your OS will use that much RAM for the cache... the whole world's not Linux :-) -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Thu Oct 23 18:14: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 6FFE0D1B4EC for ; Thu, 23 Oct 2003 21:14: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 34204-10 for ; Thu, 23 Oct 2003 18:14:12 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 53333D1B4E4 for ; Thu, 23 Oct 2003 18:14:10 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id A0BDA3E2D for ; Thu, 23 Oct 2003 17:14:12 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 15355-02-2 for ; Thu, 23 Oct 2003 17:14:11 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id CE3933E23 for ; Thu, 23 Oct 2003 17:14:11 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9NLEBiE018696 for pgsql-performance@postgresql.org; Thu, 23 Oct 2003 17:14:11 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: My own performance/tuning q&a Date: Thu, 23 Oct 2003 17:14:11 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 98 Message-ID: References: <6.0.0.22.0.20031023090320.0242d6c8@pop.hotpop.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066943651 17547 216.194.193.105 (23 Oct 2003 21:14:11 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Thu, 23 Oct 2003 21:14:11 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:kszcR+LcJ5Z4iLiinjMNdw0Lss0= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/610 X-Sequence-Number: 4358 >>>>> "AL" == Allen Landsidel writes: AL> I recently built a rather powerful machine to be used in a heavily AL> accessed database.. the machine is a dual AthlonMP 2800+, 2GB of AL> PC2100 ECC, and a 4x18GB RAID-0 using 15k rpm fujitsu MAS drives on a AL> 4ch u160 ICP-Vortex card with 256MB of cache. The only recommendation I'd make is to switch from RAID0 to RAID10, unless you can afford the downtime (and loss of data) when one of your drives takes a vacation. Also, is your RAID card cache battery backed up? If no, then you lose the ability to use write-back and this costs *dearly* in performance. AL> The box runs FreeBSD, tracking RELENG_4 (-STABLE) and PostGreSQL 7.3.4 AL> from ports (7.3.4_1) An excellent choice. :-) [[ ... ]] AL> I run a 'vacuum analyze verbose' on the database in question every AL> hour, and a reindex on every table in the database every six hours, AL> 'vacuum full' is run manually as required perhaps anywhere from once a AL> week to once a month. I realize the analyze may not be running often AL> enough and the reindex more often than need be, but I don't think AL> these are adversely affecting performance very much; degredation over AL> time does not appear to be an issue. Personally, I don't think you need to reindex that much. And I don't think you need to vacuum full *ever* if you vacuum often like you do. Perhaps reducing the vacuum frequency may let you reach a steady state of disk usage? Depending on how many concurrent actions you process, perhaps you can use a temporary table for each, so you don't have to delete many rows when you're done. On my busy tables, I vacuum every 6 hours. The vacuum analyze is run on the entire DB nightly. I reindex every month or so my most often updated tables that show index bloat. Watch for bloat by monitoring the size of your indexes: SELECT relname,relpages FROM pg_class WHERE relname LIKE 'some_table%' ORDER BY relname; AL> Related kernel configuration options: AL> ... AL> cpu I686_CPU AL> maxusers 256 let the system autoconfigure maxusers... AL> ... AL> options MAXDSIZ="(1024UL*1024*1024)" AL> options MAXSSIZ="(512UL*1024*1024)" AL> options DFLDSIZ="(512UL*1024*1024)" above are ok at defaults. AL> options SHMMAXPGS=65536 perhaps bump this and increase your shared buffers. I find that if you do lots of writes, having a few more shared buffers helps. AL> options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)" you don't need to explicitly set this... it is automatically set based on the above setting. AL> relevant postgresql.conf options: AL> max_fsm_pages = 2000000 this may be overkill. I currently run with 1000000 AL> effective_cache_size = 49152 # 384MB, this could probably be higher the current recommendation for freebsd is to set this to: `sysctl -n vfs.hibufspace` / 8192 where 8192 is the blocksize used by postgres. You may also want to increase the max buffer space used by FreeBSD, which apparently is capped at 200M (I think) by dafault. I'll have to look up how to bump that, as most likely you have plenty of RAM sitting around unused. What does "top" say about that when you're busy? -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 24 03:18: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 6AB1BD1B511 for ; Fri, 24 Oct 2003 06:18: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 25495-06 for ; Fri, 24 Oct 2003 03:17:39 -0300 (ADT) Received: from relay.icomedias.com (relay.icomedias.com [62.99.232.66]) by svr1.postgresql.org (Postfix) with ESMTP id 77FE4D1B517 for ; Fri, 24 Oct 2003 03:17:31 -0300 (ADT) Received: from loki.icomedias.com ([10.192.17.128]) by relay.icomedias.com (8.12.10/8.12.10) with ESMTP id h9O6HO5A020337 for ; Fri, 24 Oct 2003 08:17:24 +0200 From: Mario Weilguni To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Fri, 24 Oct 2003 08:17:22 +0200 User-Agent: KMail/1.5.4 References: <16272.318.870000.93584@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> In-Reply-To: <29123.1066915615@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310240817.22586.mweilguni@sime.com> X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/611 X-Sequence-Number: 4359 Am Donnerstag, 23. Oktober 2003 15:26 schrieb Tom Lane: > ... if all tuples are the same size, and if you never have any > transactions that touch enough tuples to overflow your undo segment > (or even just sit there for a long time, preventing you from recycling > undo-log space; this is the dual of the VACUUM-can't-reclaim-dead-tuple > problem). And a few other problems that any Oracle DBA can tell you about. > I prefer our system. of course both approaches have advantages, it simply depends on the usage pattern. A case where oracle really rules over postgresql are m<-->n connection tables where each record consist of two foreign keys, the overwrite approach is a big win here. From pgsql-performance-owner@postgresql.org Fri Oct 24 05:30: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 05D5CD1B520 for ; Fri, 24 Oct 2003 08:30: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 49223-04 for ; Fri, 24 Oct 2003 05:29:50 -0300 (ADT) Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) by svr1.postgresql.org (Postfix) with ESMTP id 1A840D1B510 for ; Fri, 24 Oct 2003 05:29:48 -0300 (ADT) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta1.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HN9000M269S14@mta1.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 04:29:54 -0400 (EDT) Date: Fri, 24 Oct 2003 04:32:12 -0400 From: Allen Landsidel Subject: Re: My own performance/tuning q&a In-reply-to: X-Sender: bsdasym@pop.hotpop.com To: pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031024035236.0249a7c0@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <6.0.0.22.0.20031023090320.0242d6c8@pop.hotpop.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/612 X-Sequence-Number: 4360 At 17:14 10/23/2003, Vivek Khera wrote: > >>>>> "AL" == Allen Landsidel writes: > >AL> I recently built a rather powerful machine to be used in a heavily >AL> accessed database.. the machine is a dual AthlonMP 2800+, 2GB of >AL> PC2100 ECC, and a 4x18GB RAID-0 using 15k rpm fujitsu MAS drives on a >AL> 4ch u160 ICP-Vortex card with 256MB of cache. > >The only recommendation I'd make is to switch from RAID0 to RAID10, >unless you can afford the downtime (and loss of data) when one of your >drives takes a vacation. > >Also, is your RAID card cache battery backed up? If no, then you lose >the ability to use write-back and this costs *dearly* in performance. I'm planning to move it to -10 or -5 (or even -50) once we have more money to spend on drives. As it is right now though, I couldn't spare the space.. The box this was moved from was a 2x1000 P3 with a single u160 drive.. Battery backup is something I really should have gotten on the memory but I spaced out when placing the order, it'll come in the future. I'm kind of "living on the edge" here with regard to no bbu on the raid and using raid-0 I know.. but it's for a short time, and I don't think in the scheme of things this is any more failure-prone than the crummy setup it was on before. Backup and backup often, I know that mantra very well and live by it. :) >AL> The box runs FreeBSD, tracking RELENG_4 (-STABLE) and PostGreSQL 7.3.4 >AL> from ports (7.3.4_1) > >An excellent choice. :-) I recognize you from those lists.. didn't notice the Ph.D. before though.. but yes, I'm a huge FreeBSD fan.. I didn't need anyone to talk me into that particular choice. ;) >AL> I run a 'vacuum analyze verbose' on the database in question every >AL> hour, and a reindex on every table in the database every six hours, >AL> 'vacuum full' is run manually as required perhaps anywhere from once a >AL> week to once a month. I realize the analyze may not be running often >AL> enough and the reindex more often than need be, but I don't think >AL> these are adversely affecting performance very much; degredation over >AL> time does not appear to be an issue. > >Personally, I don't think you need to reindex that much. And I don't >think you need to vacuum full *ever* if you vacuum often like you do. >Perhaps reducing the vacuum frequency may let you reach a steady state >of disk usage? Well I had the vacuums running every 15 minutes for a while.. via a simple cron script I wrote just to make sure no more than one vacuum ran at once, and to 'nice' the job.. but performance on the db does suffer a bit during vacuums or so it seems. The performance doesn't degrade noticably after only an hour without a vacuum though, so I'd like to make the state of degraded performance more periodic -- not the general rule during 24/7 operation. I'll monkey around more with running the vacuum more often and see if the performance hit was more imagined than real. >Depending on how many concurrent actions you process, perhaps you can >use a temporary table for each, so you don't have to delete many rows >when you're done. I'd love to but unfortunately the daemons that use the database are a mess, more or less 'unsupported' at this point.. thankfully they're being replaced along with a lot of performance-hurting SQL. >On my busy tables, I vacuum every 6 hours. The vacuum analyze is run >on the entire DB nightly. I reindex every month or so my most often >updated tables that show index bloat. Watch for bloat by monitoring >the size of your indexes: > >SELECT relname,relpages FROM pg_class WHERE relname LIKE 'some_table%' >ORDER BY relname; Thanks for that tidbit.. maybe I'll cron something else to grab the values once a day or so and archive them in another table for history.. make my life easier. ;) >AL> Related kernel configuration options: > >AL> ... >AL> cpu I686_CPU >AL> maxusers 256 > >let the system autoconfigure maxusers... Are you sure about this? I have always understood that explicitly setting this value was the best thing to do if you knew the maximum number of users you would encounter, as the kernel doesn't have to 'guess' at structure sizes and the like, or grow them later.. >AL> ... >AL> options MAXDSIZ="(1024UL*1024*1024)" >AL> options MAXSSIZ="(512UL*1024*1024)" >AL> options DFLDSIZ="(512UL*1024*1024)" > >above are ok at defaults. These are related to something else.. a linux developer on the system used to the way it'll always allow you access to all the memory on a machine and just kill a random process to give you memory if you allocated more than was free.. ;) He didn't know processes were getting killed, but the defaults turned out to be not high enough. This will get turned back down to default once he's done migrating everything into the new database and his app no longer needs to run there. I just mentioned them in case they could adversely affect performance as-is. >AL> options SHMMAXPGS=65536 > >perhaps bump this and increase your shared buffers. I find that if >you do lots of writes, having a few more shared buffers helps. Any ideas how much of a bump, or does that depend entirely on me and I should just play with it? Would doubling it be too much of a bump? >AL> options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)" > >you don't need to explicitly set this... it is automatically set based >on the above setting. I'm an explicit kind of guy. ;) >AL> relevant postgresql.conf options: > >AL> max_fsm_pages = 2000000 > >this may be overkill. I currently run with 1000000 At only 6 bytes each I thought 12M wasn't too much to spare for the sake of making sure there is enough room there for everything.. I am watching my file sizes and vacuum numbers to try and tune this value but it's an arduous process. >AL> effective_cache_size = 49152 # 384MB, this could probably be higher > >the current recommendation for freebsd is to set this to: > >`sysctl -n vfs.hibufspace` / 8192 > >where 8192 is the blocksize used by postgres. That comes out as 25520.. I have it at 384MB because I wanted to take the 256MB on the RAID controller into account as well. I'm not entirely certain how much of that 256MB is available, and for what kind of cache.. I know the i960 based controllers all need to set aside at least 16MB for their "OS" and it isn't used for cache, not sure about ARM based cards like the ICP.. but I don't think assuming 128MB is too much of a stretch, or even 192MB. >You may also want to increase the max buffer space used by FreeBSD, >which apparently is capped at 200M (I think) by dafault. I'll have >to look up how to bump that, as most likely you have plenty of RAM >sitting around unused. What does "top" say about that when you're >busy? Yes that hibufspace value comes out to 200MB.. (199.375 really, odd) top usually shows me running with that same value.. 199MB.. and most of the time, with maybe 1.2GB free in the Inact area.. I'll see if sysctl lets me write this value, or if it's a kernel config option I missed, unless you have remembered between then and now. I'd really like to have this higher, say around 512MB.. more if I can spare it after watching for a bit. Given this and the above about the controllers onboard cache (not to mention the per-drive cache) do you think I'll still need to lower effective_cache_size? Thanks.. -Allen From pgsql-performance-owner@postgresql.org Fri Oct 24 06:07: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 29359D1B517 for ; Fri, 24 Oct 2003 09:07: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 56424-01 for ; Fri, 24 Oct 2003 06:07:09 -0300 (ADT) Received: from anchor-post-37.mail.demon.net (anchor-post-37.mail.demon.net [194.217.242.87]) by svr1.postgresql.org (Postfix) with ESMTP id E2560D1B51B for ; Fri, 24 Oct 2003 06:07:01 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1ACxuQ-0005hi-0b; Fri, 24 Oct 2003 10:07:03 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 3753716403; Fri, 24 Oct 2003 10:07:02 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 986ED162F1; Fri, 24 Oct 2003 10:07:01 +0100 (BST) From: Richard Huxton To: dedy setiawan Subject: PostgreSQL 7.4 beta for windows Date: Fri, 24 Oct 2003 10:07:01 +0100 User-Agent: KMail/1.5 References: <20031024012156.68376.qmail@web40604.mail.yahoo.com> In-Reply-To: <20031024012156.68376.qmail@web40604.mail.yahoo.com> 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: <200310241007.01167.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/613 X-Sequence-Number: 4361 On Friday 24 October 2003 02:21, you wrote: > Thank You Sir,.... > I'm very Greatfull with your answer , > 1. I don't use Cywig, my postgres is 7.4 , and I only > runs it from command prompt on windows(postmaster); Do you mean the native port from here: http://momjian.postgresql.org/main/writings/pgsql/win32.html Please be aware that this is experimental, and you might expect problems. If not, can you say where you got it from? > 2.I don't know what i must tuning on (is "PGHBACONF" > isn't it ?),and I use it in Delphi ,when I run the > program ,It runs very slow not like i run it with > mySQL ,What is The Problem , Please Help Me.... There are two important files: pg_hba.conf - controls access to the database postgresql.conf - config/tuning See the "performance" section at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php There are two articles there which cover tuning and adds information about the various other settings. > My computer is : > PIII 600B, 256 MB, Postgres 7.4 Beta (without cywig), > delphi version 7, and my connection to DB with > dbexpress, OK - does dbexpress use ODBC, or does it connect directly? > Dedy Styawan > sorry my english is not so good... Your English is fine sir. If you can subscribe to the performance list, details at: http://www.postgresql.org/lists.html That way, others will be able to help too. I've CC'd this to the performance list ready for you. -- Richard Huxton Archonet Ltd From pgsql-performance-owner@postgresql.org Fri Oct 24 12:19: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 3BDB4D1B510 for ; Fri, 24 Oct 2003 15:19: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 11409-06 for ; Fri, 24 Oct 2003 12:19:07 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 49ED8D1B504 for ; Fri, 24 Oct 2003 12:19:07 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 2508A369D2; Fri, 24 Oct 2003 11:19:06 -0400 (EDT) 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 1AD3iU-0000aj-00; Fri, 24 Oct 2003 11:19:06 -0400 To: "Medora Schauer" Cc: "Josh Berkus" , "postgresql" Subject: Re: slow select References: <906E2C446A276048A1BE283F17BCB12CDB422A@encounter.fairind.fairfield.com> In-Reply-To: <906E2C446A276048A1BE283F17BCB12CDB422A@encounter.fairind.fairfield.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Oct 2003 11:19:05 -0400 Message-ID: <871xt2wtna.fsf@stark.dyndns.tv> Lines: 19 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: 200310/614 X-Sequence-Number: 4362 "Medora Schauer" writes: > Merge Join (cost=0.00..287726.10 rows=100221 width=58) (actual time=61.60..5975.63 rows=100425 loops=1) > Merge Cond: (("outer".shot_line_num = "inner".shot_line_num) AND ("outer".shotpoint = "inner".shotpoint)) > -> Index Scan using hsot_record_idx on shot_record r (cost=0.00..123080.11 rows=100425 width=46) (actual time=24.15..2710.31 rows=100425 loops=1) > -> Index Scan using shotpoint_idx on shotpoint p (cost=0.00..467924.54 rows=290106 width=12) (actual time=37.38..1379.64 rows=100749 loops=1) > Total runtime: 6086.32 msec > > So why did were the indices not used before when they yield a better plan? There's another reason. Notice it thinks the second table will return 290k records. In fact it only returns 100k records. So it's optimizing on the assumption that it will have to read 3x as many records as it actually will... I'm not clear if there's anything you can do to improve this estimate though. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 24 12:24: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 54414D1B54C for ; Fri, 24 Oct 2003 15:24: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 15002-03 for ; Fri, 24 Oct 2003 12:24:09 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 1EC6AD1B51E for ; Fri, 24 Oct 2003 12:24:09 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3815237; Fri, 24 Oct 2003 08:24:39 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Vivek Khera , pgsql-performance@postgresql.org Subject: Re: slow select Date: Fri, 24 Oct 2003 08:22:57 -0700 User-Agent: KMail/1.4.3 References: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> <200310221442.56816.josh@agliodbs.com> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310240822.57737.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/615 X-Sequence-Number: 4363 Vivek, > Assuming your OS will use that much RAM for the cache... the whole > world's not Linux :-) It's not? Darn! Actually, what OS's can't use all idle ram for kernel cache? I should note that in my performance docs .... -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 24 12:39: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 CAD27D1B527 for ; Fri, 24 Oct 2003 15:36: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 16520-03 for ; Fri, 24 Oct 2003 12:36:23 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id D84E7D1B533 for ; Fri, 24 Oct 2003 12:36:13 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id BF40236966; Fri, 24 Oct 2003 11:36:12 -0400 (EDT) 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 1AD3z2-0000cd-00; Fri, 24 Oct 2003 11:36:12 -0400 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> In-Reply-To: <16279.61590.158000.290397@gargle.gargle.HOWL> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Oct 2003 11:36:12 -0400 Message-ID: <87vfqeveab.fsf@stark.dyndns.tv> Lines: 48 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: 200310/616 X-Sequence-Number: 4364 Rob Nagler writes: > Incorrect. If the tuples smaller, Oracle does the right thing. If > there's enough space in the page, it shifts the tuples to make room. > That's what pctfree, pctused and pctincrease allow you to control. > It's all in memory so its fast, and I don't think it has to update any > indices. Note that pctfree/pctused are a big performance drain on the usual case. Try setting them to 0/100 on a table that doesn't get updates (like a many-many relation table) and see how much faster it is to insert and scan. > > transactions that touch enough tuples to overflow your undo segment > > That's easily configured, and hasn't been a problem in the databases > I've managed. Judging by the number of FAQ lists out there that explain various quirks of rollback segment configuration I wouldn't say it's so easily configured. > > (or even just sit there for a long time, preventing you from recycling > > That's probably bad software or a batch system--which is tuned > differently. Any OLTP system has to be able to partition its problems > to keep transactions short and small. If it doesn't, it will not be > usable. Both DSS style and OLTP style databases can be accomodated with rollback segments though it seems to me that DSS style databases lose most of the advantage of rollback segments and optimistic commit. The biggest problem is on systems where there's a combination of both users. You need tremendous rollback segments to deal with the huge volume of oltp transactions that can occur during a single DSS query. And the DSS query performance is terrible as it has to check the rollback segments for a large portion of the blocks it reads. > Oracle seems to make the assumption that data changes, Arguably it's the other way around. Postgres's approach wins whenever most of the tuples in a table have been updated, in that case it just has to scan the whole table ignoring old records not visible to the transaction. Oracle has to consult the rollback segment for any recently updated tuple. Oracle's wins in the case where most of the tuples haven't changed so it can just scan the table without consulting lots of rollback segments. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 24 12:43: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 974CFD1B51E for ; Fri, 24 Oct 2003 15:43: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 17140-06 for ; Fri, 24 Oct 2003 12:42:50 -0300 (ADT) Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) by svr1.postgresql.org (Postfix) with ESMTP id D0A03D1B4FB for ; Fri, 24 Oct 2003 12:42:49 -0300 (ADT) Received: by yertle.kcilink.com (Postfix, from userid 100) id 33EDE2178A; Fri, 24 Oct 2003 11:42:44 -0400 (EDT) From: Vivek Khera MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.18548.53239.394135@yertle.int.kciLink.com> Date: Fri, 24 Oct 2003 11:42:44 -0400 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: slow select In-Reply-To: <200310240822.57737.josh@agliodbs.com> References: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> <200310221442.56816.josh@agliodbs.com> <200310240822.57737.josh@agliodbs.com> X-Mailer: VM 7.14 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/617 X-Sequence-Number: 4365 >>>>> "JB" == Josh Berkus writes: JB> Vivek, >> Assuming your OS will use that much RAM for the cache... the whole >> world's not Linux :-) JB> It's not? Darn! :-) JB> Actually, what OS's can't use all idle ram for kernel cache? I JB> should note that in my performance docs .... FreeBSD. Limited by the value of "sysctl vfs.hibufspace" from what I understand. This value is set at boot based on available RAM and some other tuning parameters. From pgsql-performance-owner@postgresql.org Fri Oct 24 12:50: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 E4765D1B558 for ; Fri, 24 Oct 2003 15: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 17926-04 for ; Fri, 24 Oct 2003 12:49:36 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 112B3D1B4E6 for ; Fri, 24 Oct 2003 12:49:36 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id C2C273E4C for ; Fri, 24 Oct 2003 11:49:35 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 37343-02-4 for ; Fri, 24 Oct 2003 11:49:35 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 1263E3E18 for ; Fri, 24 Oct 2003 11:49:35 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9OFnYLa086388 for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 11:49:34 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: My own performance/tuning q&a Date: Fri, 24 Oct 2003 11:49:34 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 53 Message-ID: References: <6.0.0.22.0.20031023090320.0242d6c8@pop.hotpop.com> <6.0.0.22.0.20031024035236.0249a7c0@pop.hotpop.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067010574 85777 216.194.193.105 (24 Oct 2003 15:49:34 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 24 Oct 2003 15:49:34 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:VSZN6tKqJRi5gt3kDCONrbKcBIg= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/618 X-Sequence-Number: 4366 >>>>> "AL" == Allen Landsidel writes: AL> maxusers 256 >> >> let the system autoconfigure maxusers... AL> Are you sure about this? I have always understood that explicitly AL> setting this value was the best thing to do if you knew the maximum Yes, recent freebsd kernels autosize various tables and limits based on existing RAM. It does pretty well. AL> These are related to something else.. a linux developer on the system AL> used to the way it'll always allow you access to all the memory on a Ahhh... I guess we don't believe in multi-user systems ;-) AL> options SHMMAXPGS=65536 >> >> perhaps bump this and increase your shared buffers. I find that if >> you do lots of writes, having a few more shared buffers helps. AL> Any ideas how much of a bump, or does that depend entirely on me and I AL> should just play with it? Would doubling it be too much of a bump? I use 262144 for SHMMAXPGS and SHMALL. I also use about 30000 shared buffers. AL> I'll see if sysctl lets me write this value, or if it's a kernel AL> config option I missed, unless you have remembered between then and you need to bump some header file constant and rebuild the kernel. it also increases the granularity of how the buffer cache is used, so I'm not sure how it affects overall system. nothing like an experiment... AL> Given this and the above about the controllers onboard cache (not to AL> mention the per-drive cache) do you think I'll still need to lower AL> effective_cache_size? It is hard to say. If you tell PG you have more than you do, I don't know what kind of decisions it will make incorrectly. I'd rather be conservative and limit it to the RAM that the system says it will use. The RAM in the controller is not additive to this -- it is redundant to it, since all data goes thru that cache into the main memory. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 24 12: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 8386CD1B51E for ; Fri, 24 Oct 2003 15:52: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 17282-08 for ; Fri, 24 Oct 2003 12:52:12 -0300 (ADT) Received: from svr3.postgresql.org (gborg.postgresql.org [200.46.204.161]) by svr1.postgresql.org (Postfix) with ESMTP id 83540D1B4E6 for ; Fri, 24 Oct 2003 12:52:12 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr3.postgresql.org (8.12.9/8.12.6) with ESMTP id h9OFqAhe099308 for ; Fri, 24 Oct 2003 11:52:12 -0400 (EDT) (envelope-from news@lorax.kciLink.com) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id D50653E7D for ; Fri, 24 Oct 2003 11:50:48 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 37343-02-6 for ; Fri, 24 Oct 2003 11:50:48 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 555513E4C for ; Fri, 24 Oct 2003 11:50:48 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9OFomqD094580 for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 11:50:48 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: My own performance/tuning q&a Date: Fri, 24 Oct 2003 11:50:47 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 15 Message-ID: References: <6.0.0.22.0.20031023090320.0242d6c8@pop.hotpop.com> <6.0.0.22.0.20031024035236.0249a7c0@pop.hotpop.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067010648 85777 216.194.193.105 (24 Oct 2003 15:50:48 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Fri, 24 Oct 2003 15:50:48 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:Q+XW7b5WPE/pzT4oIOn6FuoU3pY= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/619 X-Sequence-Number: 4367 >>>>> "AL" == Allen Landsidel writes: AL> Well I had the vacuums running every 15 minutes for a while.. via a AL> simple cron script I wrote just to make sure no more than one vacuum AL> ran at once, and to 'nice' the job.. but performance on the db does "nice"-ing the client does nothing for the backend server that does the actual work. You need to track down the PID of the backend server running the vacuum and renice *it* to get any effect. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 24 13:45: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 49D82D1B53C for ; Fri, 24 Oct 2003 16:45: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 25782-08 for ; Fri, 24 Oct 2003 13:45:24 -0300 (ADT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id B1E15D1B504 for ; Fri, 24 Oct 2003 13:45:19 -0300 (ADT) 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 h9OGifLD010927; Fri, 24 Oct 2003 10:44:41 -0600 (MDT) Date: Fri, 24 Oct 2003 10:32:52 -0600 (MDT) From: "scott.marlowe" To: Vivek Khera Cc: Subject: Re: My own performance/tuning q&a In-Reply-To: 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: 200310/620 X-Sequence-Number: 4368 On Fri, 24 Oct 2003, Vivek Khera wrote: > >>>>> "AL" == Allen Landsidel writes: > > AL> Well I had the vacuums running every 15 minutes for a while.. via a > AL> simple cron script I wrote just to make sure no more than one vacuum > AL> ran at once, and to 'nice' the job.. but performance on the db does > > "nice"-ing the client does nothing for the backend server that does > the actual work. You need to track down the PID of the backend server > running the vacuum and renice *it* to get any effect. Note that Tom has mentioned problems with possible deadlocks when nicing individual backends before, so proceed with caution here. From pgsql-performance-owner@postgresql.org Fri Oct 24 13:47: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 A5925D1B527 for ; Fri, 24 Oct 2003 16:47: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 28231-01 for ; Fri, 24 Oct 2003 13:47:19 -0300 (ADT) Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) by svr1.postgresql.org (Postfix) with ESMTP id D5E0FD1B50C for ; Fri, 24 Oct 2003 13:47:18 -0300 (ADT) Received: by yertle.kcilink.com (Postfix, from userid 100) id 20F9A2178A; Fri, 24 Oct 2003 12:47:19 -0400 (EDT) From: Vivek Khera MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.22423.26659.54130@yertle.int.kciLink.com> Date: Fri, 24 Oct 2003 12:47:19 -0400 To: pgsql-performance@postgresql.org Subject: Re: My own performance/tuning q&a In-Reply-To: References: X-Mailer: VM 7.14 under 21.4 (patch 12) "Portable Code" XEmacs Lucid X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/621 X-Sequence-Number: 4369 >>>>> "sm" == scott marlowe writes: sm> Note that Tom has mentioned problems with possible deadlocks when nicing sm> individual backends before, so proceed with caution here. I can see possible starvation, but if scheduling changes cause deadlocks, then there's something wrong with the design. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Fri Oct 24 15:23:21 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 5D640D1B525 for ; Fri, 24 Oct 2003 18:23: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 46294-08 for ; Fri, 24 Oct 2003 15:22:49 -0300 (ADT) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id E2E8FD1B52B for ; Fri, 24 Oct 2003 15:22:47 -0300 (ADT) Received: (qmail 18656 invoked from network); 24 Oct 2003 18:23:08 -0000 Received: from unknown (HELO ?10.0.2.9?) (216.208.117.7) by 205.178.180.9 with SMTP; 24 Oct 2003 18:23:08 -0000 Subject: Re: Performance Concern From: Rod Taylor To: john@pagakis.com Cc: Postgresql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-PQqIzLhxzDqOUYXY7DU4" Message-Id: <1067019762.81651.64.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 24 Oct 2003 14:22:42 -0400 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/628 X-Sequence-Number: 4376 --=-PQqIzLhxzDqOUYXY7DU4 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2003-10-23 at 08:21, John Pagakis wrote: > Greetings. >=20 > I have a table that will require 100,000 rows initially. >=20 > Assume the following (some of the field names have been changed for > confidentiality reasons): >=20 > CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) > ); >=20 > ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); >=20 > ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); >=20 >=20 > Using JDBC, it took approximately one hour to insert 100,000 records. I > have an algorithm to generate a unique baz_number - it is a mixture of al= pha > and numerics. Using an int for identification is certainly suggested, however it sounds like you may be short a few indexes on the foreign key'd fields. EXPLAIN ANALYZE output is always nice.. --=-PQqIzLhxzDqOUYXY7DU4 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/mW3x6DETLow6vwwRAtQ3AJ9lePqlsCWUWdrYy7CcwsHSsjxcDQCfZdiT xDGojCdM5Toku/EbJgPO3V0= =/Q3s -----END PGP SIGNATURE----- --=-PQqIzLhxzDqOUYXY7DU4-- From pgsql-performance-owner@postgresql.org Fri Oct 24 15:32: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 248B5D1B50C for ; Fri, 24 Oct 2003 18:32: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 47681-04 for ; Fri, 24 Oct 2003 15:31:41 -0300 (ADT) Received: from harrier.mail.pas.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by svr1.postgresql.org (Postfix) with ESMTP id 56B26D1B538 for ; Fri, 24 Oct 2003 15:31:40 -0300 (ADT) Received: from dpc6682163108.direcpc.com ([66.82.163.108] helo=earthlink.net) by harrier.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1AD6iD-0000fG-00; Fri, 24 Oct 2003 11:31:03 -0700 Message-ID: <3F996FDF.1040307@earthlink.net> Date: Fri, 24 Oct 2003 14:30:55 -0400 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: john@pagakis.com Cc: pgsql-performance@postgresql.org Subject: Re: Performance Concern References: In-Reply-To: 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: 200310/629 X-Sequence-Number: 4377 John, Are you treating each insertion as a separate transaction? If so the performance will suffer. I am doing the same thing in building a data warehouse using PG. I have to load millions of records each night. I do two different things: 1) If I need to keep the insertions inside the java process I turn off auto-commit and every n insertions (5000 seems to give me the best performance for my setup) issue a commit. Make sure you do a final commit in a finally block so you don't miss anything. 2) Dump all the data to a file and then use a psql COPY (columns) FROM 'file path' call to load it. Very fast. --sean John Pagakis wrote: >Greetings. > >I have a table that will require 100,000 rows initially. > >Assume the following (some of the field names have been changed for >confidentiality reasons): > >CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) >); > >ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > >ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > >Using JDBC, it took approximately one hour to insert 100,000 records. I >have an algorithm to generate a unique baz_number - it is a mixture of alpha >and numerics. > >There is a purchase table; one purchase can have many associated baz >records, but the baz records will be pre-allocated - baz.customer_id allows >null. The act of purchasing a baz will cause baz.customer_id to be >populated from the customer_id (key) field in the purchase table. > >If it took an hour to insert 100,000 records, I can only imagine how much >time it will take if one customer were to attempt to purchase all 100,000 >baz. Certainly too long for a web page. > >I've not had to deal with this kind of volume in Postgres before; I have my >suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) >but I'd *LOVE* any thoughts. > >Would I be better off making the key an identity field and not indexing on >baz_number? > >Thanks in advance for any help. > >__________________________________________________________________ >John Pagakis >Email: ih8spam_thebfh@toolsmythe.com > > >"The best way to make your dreams come true is to wake up." > -- Paul Valery > >This signature generated by > ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. > www.spazmodicfrog.com > > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > From pgsql-performance-owner@postgresql.org Fri Oct 24 17:15: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 84D2CD1B52B for ; Fri, 24 Oct 2003 20:14: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 59030-06 for ; Fri, 24 Oct 2003 17:14:28 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id CE5E6D1B504 for ; Fri, 24 Oct 2003 17:14:26 -0300 (ADT) 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 h9OKEQNu058594 for ; Fri, 24 Oct 2003 20:14:26 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9OKA1hk058282 for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 20:10:01 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Performance Concern Date: Fri, 24 Oct 2003 15:10:47 -0400 Organization: Hub.Org Networking Services Lines: 94 Message-ID: <60ekx2cuyw.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:tOiAh5e0L0PrOcKUfHGkbO7vlp8= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/630 X-Sequence-Number: 4378 john@pagakis.com ("John Pagakis") writes: > Greetings. > > I have a table that will require 100,000 rows initially. > > Assume the following (some of the field names have been changed for > confidentiality reasons): > > CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) > ); > > ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > > ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > Using JDBC, it took approximately one hour to insert 100,000 records. I > have an algorithm to generate a unique baz_number - it is a mixture of alpha > and numerics. Question #1: How did you do the inserts? If AUTO-COMMIT was turned on, then that would indicate that you invoked 100,000 transactions, and that would contribute considerably to the process being slow. Put them all in as one transaction and you'd probably see it run in a fraction of the time. Question #2. Do you have indices on purchase(customer_id) and on foobar(foobar_id)? If not, then the foreign key check would be rather inefficient. > There is a purchase table; one purchase can have many associated baz > records, but the baz records will be pre-allocated - baz.customer_id > allows null. The act of purchasing a baz will cause baz.customer_id > to be populated from the customer_id (key) field in the purchase > table. > > If it took an hour to insert 100,000 records, I can only imagine how > much time it will take if one customer were to attempt to purchase > all 100,000 baz. Certainly too long for a web page. I take it that each "baz" is a uniquely identifiable product, akin to (say) an RSA certificate or the like? By the way, if you set up a stored procedure in PostgreSQL that can generate the "baz_number" identifiers, you could probably do the inserts Right Well Fast... Consider the following. I have a stored procedure, genauth(), which generates quasi-random values. (They're passwords, sort of...) cctld=# explain analyze insert into baz (baz_number, create_user, last_update_user) cctld-# select substr(genauth(), 1, 15), 'cbbrowne', 'cbbrowne' from big_table; QUERY PLAN --------------------------------------------------------------------------------------------------------------- Seq Scan on big_table (cost=0.00..789.88 rows=28988 width=0) (actual time=0.20..1713.60 rows=28988 loops=1) Total runtime: 3197.40 msec (2 rows) It took about 3 seconds to insert 28988 rows into baz. (big_table, also renamed, to protect the innocent, has 28988 rows. I didn't care about its contents, just that it had a bunch of rows.) And the above is on a cheap desktop PC with IDE disk. > I've not had to deal with this kind of volume in Postgres before; I > have my suspicions on what is wrong here (could it be using a CHAR( > 15 ) as a key?) but I'd *LOVE* any thoughts. > Would I be better off making the key an identity field and not > indexing on baz_number? That might be something of an improvement, but it oughtn't be cripplingly different to use a text field rather than an integer. What's crippling is submitting 100,000 queries in 100,000 transactions. Cut THAT down to size and you'll see performance return to being reasonable. -- "cbbrowne","@","libertyrms.info" Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Fri Oct 24 17:24: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 0AADBD1B533 for ; Fri, 24 Oct 2003 20:24: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 58151-07 for ; Fri, 24 Oct 2003 17:23:34 -0300 (ADT) Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) by svr1.postgresql.org (Postfix) with ESMTP id 02701D1B4FE for ; Fri, 24 Oct 2003 17:22:23 -0300 (ADT) 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="utf-8" Content-Transfer-Encoding: base64 Subject: Re: PostgreSQL data on a NAS device ? Date: Fri, 24 Oct 2003 15:22:45 -0400 Message-ID: <2F2E24372F10744588A27DEECC85FE04B676B9@vt-pe2550-001.vantage.vantage.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] PostgreSQL data on a NAS device ? Thread-Index: AcOaWQaGRfQBMcaXRDqjSXNdLcfFAAACjCQZ From: "Anjan Dave" To: "William Yu" , X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/631 X-Sequence-Number: 4379 SnVzdCBhbiBpbnRlcmVzdGluZyBjb21wYXJpc29uOg0KIA0KSSBkb24ndCBo YXZlIHRoZSBzcGVjaWZpY3MsIGJ1dCBhICBEZWxsIDIgeCAyLjRHSFovNTEy S0IgTDMgLyAyR0IgUkFNIG1hY2hpbmUgdGltZWQgYSBxdWVyeSBtdWNoIGZh c3RlciB0aGFuIGFuIG9sZGVyIFN1biBFNDAwMCB3aXRoIDYgeCB+MzAwTUha IENQVXMgLyAyR0IgUkFNLiBPbmUgb24gUkgoOCBvciA5LCBkb24ndCByZW1l bWJlcikgYW5kIG9uZSBvbiBTb2xhcmlzIDkuDQogDQotYW5qYW4NCiANCi0t LS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tIA0KRnJvbTogV2lsbGlhbSBZdSBb bWFpbHRvOnd5dUB0YWxpc3lzLmNvbV0gDQpTZW50OiBUdWUgMTAvMjEvMjAw MyAxMjoxMiBQTSANClRvOiBwZ3NxbC1wZXJmb3JtYW5jZUBwb3N0Z3Jlc3Fs Lm9yZyANCkNjOiANClN1YmplY3Q6IFJlOiBbUEVSRk9STV0gUG9zdGdyZVNR TCBkYXRhIG9uIGEgTkFTIGRldmljZSA/DQoNCg0KDQoJPiBJIGhhdmUgbmV2 ZXIgd29ya2VkIHdpdGggYSBYRU9OIENQVSBiZWZvcmUuIERvZXMgYW55b25l IGtub3cgaG93IGl0IHBlcmZvcm1zDQoJPiBydW5uaW5nIFBvc3RncmVTUUwg Ny4zLjQgLyA3LjQgb24gUmVkSGF0IDkgPyBJcyBpdCBmYXN0ZXIgdGhhbiBh IFBlbnRpdW0gND8NCgk+IEkgYmVsaWV2ZSB0aGUgbWFpbiBkaWZmZXJlbmNl IGlzIGNhY2hlIG1lbW9yeSwgcmlnaHQ/IEFzaWRlIGZyb20gY2FjaGUgbWVt LA0KCT4gaXQncyBiYXNpY2FsbHkgYSBQZW50aXVtIDQsIG9yIGFtIEkgd3Jv bmc/DQoJDQoJV2VsbCwgc2VlIHRoZSBwcm9ibGVtIGlzIG9mIGNvdXJzZSwg dGhlcmUncyBzbyBtYW55IGZsYXZvcnMgb2YgUDRzIGFuZA0KCVhlb25zIHRo YXQgaXQncyBoYXJkIHRvIHRlbGwgd2hpY2ggaXMgZmFzdGVyIHVubGVzcyB5 b3Ugc3BlY2lmeSB0aGUNCglleGFjdCBtb2RlbC4gQW5kIGV2ZW4gdGhlbiwg aXQgd291bGQgZGVwZW5kIG9uIHRoZSB3b3JrbG9hZC4gV291bGQgYQ0KCVhl b24vM0dIei8yTUIgTDMvNDAwRlNCIGJlIGZhc3RlciB0aGFuIGEgUDRDLzNH SHovODAwRlNCPyBObyBpZGVhIGFzIG5vDQoJb25lIGhhcyBjb21wbGV0ZSBu dW1iZXIgYnJlYWtkb3ducyBvbiB0aGVzZSBjb21wYXJpc29ucy4gT2ggeWVh aCwgeW91DQoJY291bGQgZ2V0IGEgYmlnIHJvdW5kIG51bWJlciB0aGF0IHNh eXMgb24gU1BFQyBvciBzb21ldGhpbmcgb25lIENQVSBpcw0KCWZhc3RlciB0 aGFuIHRoZSBvdGhlciBidXQgd2hldGhlciB0aGF0J3MgZmFzdGVyIGZvciBQ b3N0Z3JlcyBhbmQgeW91ciBQRw0KCWFwcCBpcyBhIHRvdGFsbHkgZGlmZmVy ZW50IHN0b3J5Lg0KCQ0KCVRoYXQgaW4gbWluZCwgSSB3b3VsZG4ndCB3b3Jy eSBhYm91dCBpdC4gVGhlIENQVSBpcyBwcm9iYWJseSBwbGVudHkgZmFzdA0K CWZvciB3aGF0IHlvdSBuZWVkIHRvIGRvLiBJJ2QgbG9vayBpbnRvIHR3byB0 aGluZ3MgaW4gdGhlIHNlcnZlcjogbWVtb3J5DQoJYW5kIENQVSBleHBhbmRh YmlsaXR5LiBJIGtub3cgeW91IGFscmVhZHkgcGxhbiBvbiA0R0IgYnV0IHlv dSBtYXkgbmVlZA0KCWV2ZW4gbW9yZSBpbiB0aGUgZnV0dXJlLiBGZXcgdGhp bmdzIGNhbiBkcmFtYXRpY2FsbHkgaW1wcm92ZSBwZXJmb3JtYW5jZQ0KCW1v cmUgdGhhbiBtb3ZpbmcgZGlzayBhY2Nlc3MgdG8gZGlzayBjYWNoZS4gQW5k IGlmIHRoZXJlJ3MgYSAybmQgc29ja2V0DQoJd2hlcmUgeW91IGNhbiBwb3Ag YW5vdGhlciBDUFUgaW4sIHRoYXQgd291bGQgbGVhdmUgeW91IGV4dHJhIHJv b20gaWYNCgl5b3VyIHNlcnZlciBiZWNvbWVzIENQVSBsaW1pdGVkLg0KCQ0K CQ0KCS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLShlbmQgb2YgYnJvYWRj YXN0KS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KCVRJUCA2OiBIYXZl IHlvdSBzZWFyY2hlZCBvdXIgbGlzdCBhcmNoaXZlcz8NCgkNCgkgICAgICAg ICAgICAgICBodHRwOi8vYXJjaGl2ZXMucG9zdGdyZXNxbC5vcmcNCgkNCg0K From pgsql-performance-owner@postgresql.org Fri Oct 24 17:51: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 2CB77D1B51B for ; Fri, 24 Oct 2003 20:51: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 67453-08 for ; Fri, 24 Oct 2003 17:50:36 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 4C962D1B52B for ; Fri, 24 Oct 2003 17:50:33 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9OKoYX22829; Fri, 24 Oct 2003 16:50:34 -0400 (EDT) From: Bruce Momjian Message-Id: <200310242050.h9OKoYX22829@candle.pha.pa.us> Subject: Re: My own performance/tuning q&a In-Reply-To: <16281.22423.26659.54130@yertle.int.kciLink.com> To: Vivek Khera Date: Fri, 24 Oct 2003 16:50:34 -0400 (EDT) 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: 200310/633 X-Sequence-Number: 4381 Vivek Khera wrote: > >>>>> "sm" == scott marlowe writes: > > > sm> Note that Tom has mentioned problems with possible deadlocks when nicing > sm> individual backends before, so proceed with caution here. > > I can see possible starvation, but if scheduling changes cause > deadlocks, then there's something wrong with the design. Yes, I think Tom's concern was priority inversion, where a low priority process holds a lock while a higher one waits for 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-performance-owner@postgresql.org Fri Oct 24 18:01: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 1C559D1B52D for ; Fri, 24 Oct 2003 21:01: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 67792-08 for ; Fri, 24 Oct 2003 18:00:32 -0300 (ADT) 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 14900D1B51E for ; Fri, 24 Oct 2003 18:00:26 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9OKwIOC010413; Fri, 24 Oct 2003 23:58:22 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9OKwBJa010411; Fri, 24 Oct 2003 23:58:11 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Performance Concern From: Hannu Krosing To: Christopher Browne Cc: pgsql-performance@postgresql.org In-Reply-To: <60ekx2cuyw.fsf@dev6.int.libertyrms.info> References: <60ekx2cuyw.fsf@dev6.int.libertyrms.info> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1067029090.5995.28.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 24 Oct 2003 23:58:11 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/634 X-Sequence-Number: 4382 Christopher Browne kirjutas R, 24.10.2003 kell 22:10: > That might be something of an improvement, but it oughtn't be > cripplingly different to use a text field rather than an integer. I suspect his slowness comes from not running analyze when it would be time to start using indexes for fk checks - if you run analyze on an empty table and then do 10000 inserts, then all these will run their checks using seqscan, as this is the fastest way to do it on an empty table ;) > What's crippling is submitting 100,000 queries in 100,000 > transactions. Cut THAT down to size and you'll see performance return > to being reasonable. even this should not be too crippling. I 0nce did some testing for insert performance and got about 9000 inserts/sec on 4 CPU Xeon with 2GB ram and RAID-5 (likely with battery backed cache). This 9000 dropped to ~250 when I added a primary key index (to a 60.000.000 record table, so that the pk index fit only partly in memory), all this with separate transactions, but with many clients running concurrently. (btw., the clients were not java/JDBC but Python/psycopg) With just one client you are usually stuck to 1 trx/disk revolution, at least with no battery-backed write cache. even 250/sec should insert 10000 in 40 sec. -------------- Hannu From pgsql-performance-owner@postgresql.org Fri Oct 24 17:50: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 D6745D1B51E for ; Fri, 24 Oct 2003 20:50: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 67871-04 for ; Fri, 24 Oct 2003 17:49:53 -0300 (ADT) Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) by svr1.postgresql.org (Postfix) with ESMTP id AD8A8D1B525 for ; Fri, 24 Oct 2003 17:49:50 -0300 (ADT) Received: from user-784.wfd20.dsl.pol.co.uk ([81.79.115.16] helo=rj) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) id 1AD8sa-0003Pu-57 for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 21:49:52 +0100 From: Richard Jones Reply-To: rj@last.fm Organization: Last.fm Ltd. To: Subject: Memcache Date: Fri, 24 Oct 2003 22:06:10 +0100 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310242206.10911.rj@last.fm> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/632 X-Sequence-Number: 4380 Just thought i'd mention that on top of optimising postgres as much as possible, don't forget how much something like memcached can do for you http://www.danga.com/memcached/ we use it on www.last.fm - most pages only take one or two database hits, compared with 30 to 40 when memcache is turned off. Rich. From pgsql-performance-owner@postgresql.org Fri Oct 24 19:08: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 246EAD1B522 for ; Fri, 24 Oct 2003 22:08: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 77776-10 for ; Fri, 24 Oct 2003 19:08:13 -0300 (ADT) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id A8CD7D1B504 for ; Fri, 24 Oct 2003 19:08:10 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id QAB25042 for ; Fri, 24 Oct 2003 16:08:09 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.41463.449000.639113@gargle.gargle.HOWL> Date: Fri, 24 Oct 2003 16:04:39 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <16272.30527.120343.547492@jump.bivio.com> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/635 X-Sequence-Number: 4383 Stephen writes: > I ran into the same problem with VACUUM on my Linux box. If you are running > Linux, take a look at "elvtune" or read this post: The default values were -r 64 -w 8192. The article said this was "optimal". I just futzed with different values anywere from -w 128 -r 128 to -r 16 -w 8192. None of these mattered much when vacuum is running. This is a RAID1 box with two disks. Even with vacuum and one other postmaster running, it's still got to get a lot of blocks through the I/O system. Rob From pgsql-performance-owner@postgresql.org Fri Oct 24 19:12:55 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 8F37FD1B51B for ; Fri, 24 Oct 2003 22:12: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 82590-02 for ; Fri, 24 Oct 2003 19:12:24 -0300 (ADT) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 3CC8BD1B4E6 for ; Fri, 24 Oct 2003 19:12:21 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id QAB25047 for ; Fri, 24 Oct 2003 16:12:23 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.41629.69000.492473@gargle.gargle.HOWL> Date: Fri, 24 Oct 2003 16:07:25 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <200310240817.22586.mweilguni@sime.com> References: <16272.318.870000.93584@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <200310240817.22586.mweilguni@sime.com> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/636 X-Sequence-Number: 4384 Mario Weilguni writes: > of course both approaches have advantages, it simply depends on the usage > pattern. A case where oracle really rules over postgresql are m<-->n > connection tables where each record consist of two foreign keys, the > overwrite approach is a big win here. That's usually our case. My company almost always has "groupware" problems to solve. Every record has a "realm" (security) foreign key and typically another key. The infrastructure puts the security key on queries to avoid returning the wrong realm's data. Rob From pgsql-performance-owner@postgresql.org Fri Oct 24 19:30: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 CE992D1B4E6 for ; Fri, 24 Oct 2003 22:30: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 86559-04 for ; Fri, 24 Oct 2003 19:30:15 -0300 (ADT) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id C183BD1B4E1 for ; Fri, 24 Oct 2003 19:30:08 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id QAB25057 for ; Fri, 24 Oct 2003 16:30:07 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.42312.682000.932257@gargle.gargle.HOWL> Date: Fri, 24 Oct 2003 16:18:48 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking Newsgroups: ml.postgres.performance In-Reply-To: References: <16272.318.870000.93584@gargle.gargle.HOWL> <3F9006BF.40906@persistent.co.in> <16272.4154.489000.227676@gargle.gargle.HOWL> <200310170936.25997.josh@agliodbs.com> <16272.32044.80671.948532@jump.bivio.com> <16279.4988.496000.539525@gargle.gargle.HOWL> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/637 X-Sequence-Number: 4385 Vivek Khera writes: > Also, how close are you to the capacity of your disk bandwidth? I > don't see that in your numbers. I know in freebsd I can run "systat > -vmstat" and it gives me a percentage of utilization that lets me know > when I'm near the capacity. The vacuum totally consumes the system. It's in a constant "D". As near as I can tell, it's hitting all blocks in the database. The problem is interactive performance when vacuum is in a D state. Even with just two processes doing "stuff" (vacuum and a select, let's say), the select is very slow. My understanding of the problem is that if a query hits the disk hard (and many of my queries do) and vacuum is hitting the disk hard, they contend for the same resource and nobody wins. The query optimizer has lots of problems with my queries and ends up doing silly sorts. As a simple example, one query goes like this: select avg(f1) from t1 group by f2; This results in a plan like: Aggregate (cost=171672.95..180304.41 rows=115086 width=32) -> Group (cost=171672.95..177427.26 rows=1150862 width=32) -> Sort (cost=171672.95..174550.10 rows=1150862 width=32) Sort Key: f2 -> Seq Scan on t1 (cost=0.00..39773.62 rows=1150862 width=32) This is of course stupid, because it sorts a 1M rows, which probably means it has to hit disk (sort_mem can only be so large). Turns out there are only about 20 different values of f2, so it would be much better to aggregate without sorting. This is the type of query which runs while vacuum runs and I'm sure the two are just plain incompatible. vacuum is read intensive and this query is write intensive. Rob From pgsql-performance-owner@postgresql.org Fri Oct 24 20:16: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 1B9EBD1B51E for ; Fri, 24 Oct 2003 23:16: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 87831-10 for ; Fri, 24 Oct 2003 20:15:46 -0300 (ADT) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 5F938D1B527 for ; Fri, 24 Oct 2003 20:15:43 -0300 (ADT) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id RAB25198 for ; Fri, 24 Oct 2003 17:15:38 -0600 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16281.45354.209000.280418@gargle.gargle.HOWL> Date: Fri, 24 Oct 2003 17:09:30 -0600 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <87vfqeveab.fsf@stark.dyndns.tv> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/638 X-Sequence-Number: 4386 Greg Stark writes: > Note that pctfree/pctused are a big performance drain on the usual case. Try > setting them to 0/100 on a table that doesn't get updates (like a many-many > relation table) and see how much faster it is to insert and scan. Right. You can optimize each table independently. The "usual" case doesn't exist in most databases, I've found, which is why Oracle does better. > Judging by the number of FAQ lists out there that explain various quirks of > rollback segment configuration I wouldn't say it's so easily configured. Maybe we just got lucky. :-) > The biggest problem is on systems where there's a combination of both users. As is ours. > You need tremendous rollback segments to deal with the huge volume of oltp > transactions that can occur during a single DSS query. And the DSS query > performance is terrible as it has to check the rollback segments for a large > portion of the blocks it reads. The DSS issues only come into play I think if the queries are long. This is our problem. Postgres does a bad job with DSS, I believe. I mentioned the select avg(f1) from t1 group by f2 in another message. If it were optimized for "standard" SQL, such as, avg, sum, etc., I think it would do a lot better with DSS-type problems. Our problem seems to be that the DSS queries almost always hit disk to sort. > Arguably it's the other way around. Postgres's approach wins whenever most of > the tuples in a table have been updated, in that case it just has to scan the > whole table ignoring old records not visible to the transaction. Oracle has to > consult the rollback segment for any recently updated tuple. Oracle's wins in > the case where most of the tuples haven't changed so it can just scan the > table without consulting lots of rollback segments. I see what you're saying. I'm not a db expert, just a programmer trying to make his queries go faster, so I'll acknowledge that the design is theoretically better. In practice, I'm still stuck. As a simple example, this query select avg(f1) from t1 group by f2 Takes 33 seconds (see explain analyze in another note in this thread) to run on idle hardware with about 1GB available in the cache. It's clearly hitting disk to do the sort. Being a dumb programmer, I changed the query to: select f1 from t1; And wrote the rest in Perl. It takes 4 seconds to run. Why? The Perl doesn't sort to disk, it aggregates in memory. There are 18 rows returned. What I didn't mention is that I originally had: select avg(f1), t2.name from t1, t2 where t2.f2 = t1.f2 group by t2.name; Which is much worse: Aggregate (cost=161046.30..162130.42 rows=8673 width=222) (actual time=72069.10..87455.69 rows=18 loops=1) -> Group (cost=161046.30..161479.95 rows=86729 width=222) (actual time=71066.38..78108.17 rows=963660 loops=1) -> Sort (cost=161046.30..161263.13 rows=86729 width=222) (actual time=71066.36..72445.74 rows=963660 loops=1) Sort Key: t2.name -> Merge Join (cost=148030.15..153932.66 rows=86729 width=222) (actual time=19850.52..27266.40 rows=963660 loops=1) Merge Cond: ("outer".f2 = "inner".f2) -> Sort (cost=148028.59..150437.74 rows=963660 width=58) (actual time=19850.18..21750.12 rows=963660 loops=1) Sort Key: t1.f2 -> Seq Scan on t1 (cost=0.00..32479.60 rows=963660 width=58) (actual time=0.06..3333.39 rows=963660 loops=1) -> Sort (cost=1.56..1.60 rows=18 width=164) (actual time=0.30..737.59 rows=931007 loops=1) Sort Key: t2.f2 -> Seq Scan on t2 (cost=0.00..1.18 rows=18 width=164) (actual time=0.05..0.08 rows=18 loops=1) Total runtime: 87550.31 msec Again, there are about 18 values of f2. The optimizer even knows this (it's a foreign key to t2.f2), but instead it does the query plan in exactly the wrong order. It hits disk probably 3 times as much as the simpler query judging by the amount of time this query takes (33 vs 88 secs). BTW, adding an index to t1.f2 has seriously negative effects on many other DSS queries. I'm still not sure that the sort problem is our only problem when vacuum runs. It's tough to pin down. We'll be adding more memory to see if that helps with the disk contention. Rob From pgsql-performance-owner@postgresql.org Fri Oct 24 21:08: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 3F433D1B51E for ; Sat, 25 Oct 2003 00:08: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 98621-03 for ; Fri, 24 Oct 2003 21:07:58 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id CF477D1B515 for ; Fri, 24 Oct 2003 21:07:54 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id AA03E36B27; Fri, 24 Oct 2003 20:07:57 -0400 (EDT) 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 1ADByH-0003je-00; Fri, 24 Oct 2003 20:07:57 -0400 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <200310240817.22586.mweilguni@sime.com> <16281.41629.69000.492473@gargle.gargle.HOWL> In-Reply-To: <16281.41629.69000.492473@gargle.gargle.HOWL> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Oct 2003 20:07:57 -0400 Message-ID: <87ekx2uqle.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: 200310/639 X-Sequence-Number: 4387 Rob Nagler writes: > Mario Weilguni writes: > > of course both approaches have advantages, it simply depends on the usage > > pattern. A case where oracle really rules over postgresql are m<-->n > > connection tables where each record consist of two foreign keys, the > > overwrite approach is a big win here. I don't understand why you would expect overwriting to win here. What types of updates do you do on these tables? Normally I found using update on such a table was too awkward to contemplate so I just delete all the relation records that I'm replacing for the key I'm working with and insert new ones. This always works out to be cleaner code. In fact I usually leave such tables with no UPDATE grants on them. In that situation I would have actually expected Postgres to do as well as or better than Oracle since that makes them both functionally equivalent. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 24 21:10: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 3740CD1B53B for ; Sat, 25 Oct 2003 00:10: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 05411-01 for ; Fri, 24 Oct 2003 21:10:19 -0300 (ADT) Received: from mta9.srv.hcvlny.cv.net (mta9.srv.hcvlny.cv.net [167.206.5.42]) by svr1.postgresql.org (Postfix) with ESMTP id EB8B4D1B4E1 for ; Fri, 24 Oct 2003 21:10:10 -0300 (ADT) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta9.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNA00HBFDROD2@mta9.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 20:09:25 -0400 (EDT) Date: Fri, 24 Oct 2003 20:11:52 -0400 From: Allen Landsidel Subject: Re: My own performance/tuning q&a In-reply-to: <200310242050.h9OKoYX22829@candle.pha.pa.us> X-Sender: bsdasym@pop.hotpop.com To: pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031024194443.024306b8@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <16281.22423.26659.54130@yertle.int.kciLink.com> <200310242050.h9OKoYX22829@candle.pha.pa.us> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/640 X-Sequence-Number: 4388 Pardon this for looking somewhat "weird" but it seems I'm not getting all the messages to the list.. I've noticed the past few days a lot of them are coming out of order as well.. So, this was copy/pasted from the web archive of the list.. Vivek Khera wrote: > >>>>> "AL" == Allen Landsidel writes: > >AL> maxusers 256 > >> let the system autoconfigure maxusers... > >AL> Are you sure about this? I have always understood that explicitly > >Yes, recent freebsd kernels autosize various tables and limits based >on existing RAM. It does pretty well. I'll disable it then and see how it goes. >AL> These are related to something else.. a linux developer on the system >AL> used to the way it'll always allow you access to all the memory on a > >Ahhh... I guess we don't believe in multi-user systems ;-) No, that's a foreign concept to a lot of people it seems. As a matter of trivia, I first suggested we run this on another server instead and hit the db remotely, as it's only going to be a "run once" type of thing that converts the old system to the new one but was rebuffed. Yesterday during a test run the thing ran over the 1GB limit, failed on some new() or other and dumped core. I couldn't bring the db down at that time to update the kernel, so we ran it on another box that has MAXDSIZ set to 1.5GB and it ran ok, but took about six hours.. so I'll be upping the that value yet again for this one special run this weekend when we do the *real* switch over, then putting it back down once we're all done. I can deal with it since it's not going to be "normal" but simply a one-off type thing. FWIW the same kind of thing has happened to me with this postgres install; Occasionally large atomic queries like DELETE will fail for the same reason (out of memory) if there are a lot of rows to get removed, and TRUNCATE isn't an option since there are FKs on the table in question. This is an annoyance I'd be interested to hear how other people work around, but only a minor one. >I use 262144 for SHMMAXPGS and SHMALL. I also use about 30000 shared >buffers. I believe I had it fairly high once before and didn't notice much of an improvement but I'll fool with numbers around where you suggest. >AL> I'll see if sysctl lets me write this value, or if it's a kernel >AL> config option I missed, unless you have remembered between then and > >you need to bump some header file constant and rebuild the kernel. it >also increases the granularity of how the buffer cache is used, so I'm >not sure how it affects overall system. nothing like an experiment... So far I've found a whole lot of questions about this, but nothing about the constant. The sysctl (vfs.hibufspace I believe is the one) is read only, although I should be able to work around that via /boot/loader.conf if I can't find the kernel option. >AL> Given this and the above about the controllers onboard cache (not to >AL> mention the per-drive cache) do you think I'll still need to lower >AL> effective_cache_size? > >It is hard to say. If you tell PG you have more than you do, I don't >know what kind of decisions it will make incorrectly. I'd rather be >conservative and limit it to the RAM that the system says it will >use. The RAM in the controller is not additive to this -- it is >redundant to it, since all data goes thru that cache into the main >memory. A very good point, I don't know why I thought they may hold different data. I think it could differ somewhat but probably most everything in the controller cache will be duplicated in the OS cache, provided the OS cache is at least as large. A separate reply concatenated here to a message I actually did get delivered via email: At 16:50 10/24/2003, Bruce Momjian wrote: >Vivek Khera wrote: > > >>>>> "sm" == scott marlowe writes: > > > > > > sm> Note that Tom has mentioned problems with possible deadlocks when > nicing > > sm> individual backends before, so proceed with caution here. > > > > I can see possible starvation, but if scheduling changes cause > > deadlocks, then there's something wrong with the design. > >Yes, I think Tom's concern was priority inversion, where a low priority >process holds a lock while a higher one waits for it. 1. Vivek, you were absolutely right about the backend process not being lowered in priority by nice'ing the psql. Yet another thing that "just didn't occur" when I wrote the script. 2. Vivek and Bruce (and even Tom), "VACUUM ANALYZE (VERBOSE)" isn't supposed to lock anything though, right? I can see this being a possible problem for other queries that do lock things, but between Vivek pointing out that the nice isn't *really* affecting the vacuum (as I just run one query db-wide) and the fact that the vacuum doesn't lock, I don't think it's hurting (or helping) in this case. However, I do the same thing with the reindex, so I'll definitely be taking it out there, as that one does lock.. although I would think the worst this would do would be a making the index unavailable and forcing a seq scan.. is that not the case? From pgsql-performance-owner@postgresql.org Fri Oct 24 21:15: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 B81B5D1B535 for ; Sat, 25 Oct 2003 00:15: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 97541-09 for ; Fri, 24 Oct 2003 21:14:35 -0300 (ADT) Received: from fed1mtao08.cox.net (fed1mtao08.cox.net [68.6.19.123]) by svr1.postgresql.org (Postfix) with ESMTP id 414E8D1B558 for ; Fri, 24 Oct 2003 21:14:16 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao08.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031025001413.TSWT8740.fed1mtao08.cox.net@toolsmythes01>; Fri, 24 Oct 2003 20:14:13 -0400 Reply-To: From: "John Pagakis" To: "Rod Taylor" Cc: "Postgresql Performance" Subject: Re: Performance Concern Date: Fri, 24 Oct 2003 17:17:44 -0700 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.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <1067019762.81651.64.camel@jester> Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/641 X-Sequence-Number: 4389 Thanks Rod. While I was waiting for my post to make it I went ahead and made the key an int. It improved it a lot, but was still pretty slow. This is weird: I was testing in a query window thus: UPDATE baz SET customer_id = '1234' WHERE ( SELECT baz_number FROM baz WHERE customer_id IS NULL LIMIT 1000 ); In the version of the table I posted this took 3 1/2 minutes. By making baz_number not part of the key, adding a baz_key of int4 and adjusting the above query for that it dropped to 1 1/2 minutes. But, I realized that was not how my app was going to be updating, so I wrote a little simulation in JAVA that gets a list of baz_keys where the customer_ is null and then iterates through the list one at a time attempting to UPDATE baz SET customer_id = '1234' WHERE baz_key = AND customer_id IS NULL. One thousand iterations took only 37 seconds. It would appear PostgreSQL is tuned towards single updates as opposed to handing a big bunch off to the query engine. Does that seem right? Seems odd to me. Anyway thanks for your response. I'll add some indexes and see if I can't shave that time down even further. __________________________________________________________________ John Pagakis Email: john@pagakis.com "If you can't beat them, arrange to have them beaten." -- George Carlin This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Rod Taylor Sent: Friday, October 24, 2003 11:23 AM To: john@pagakis.com Cc: Postgresql Performance Subject: Re: [PERFORM] Performance Concern On Thu, 2003-10-23 at 08:21, John Pagakis wrote: > Greetings. > > I have a table that will require 100,000 rows initially. > > Assume the following (some of the field names have been changed for > confidentiality reasons): > > CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) > ); > > ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > > ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > > Using JDBC, it took approximately one hour to insert 100,000 records. I > have an algorithm to generate a unique baz_number - it is a mixture of alpha > and numerics. Using an int for identification is certainly suggested, however it sounds like you may be short a few indexes on the foreign key'd fields. EXPLAIN ANALYZE output is always nice.. From pgsql-performance-owner@postgresql.org Sat Oct 25 14:32: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 E215CD1B51B for ; Sat, 25 Oct 2003 00:25: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 98665-07 for ; Fri, 24 Oct 2003 21:24:47 -0300 (ADT) Received: from fed1mtao07.cox.net (fed1mtao07.cox.net [68.6.19.124]) by svr1.postgresql.org (Postfix) with ESMTP id 80CA5D1B51A for ; Fri, 24 Oct 2003 21:24:38 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao07.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031025002434.CNHA3394.fed1mtao07.cox.net@toolsmythes01>; Fri, 24 Oct 2003 20:24:34 -0400 Reply-To: From: "John Pagakis" To: "Sean Shanny" Cc: Subject: Re: Performance Concern Date: Fri, 24 Oct 2003 17:28:06 -0700 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.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <3F996FDF.1040307@earthlink.net> 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=BANG_QUOTE, BAYES_30, EMAIL_ATTRIBUTION, HTML_TAG_BALANCE_TABLE, IN_REP_TO, MSGID_GOOD_EXCHANGE, ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES X-Spam-Level: X-Archive-Number: 200310/650 X-Sequence-Number: 4398 Sean - I believe auto-commit was off (not at the box right now). I'll play with the commit interval; I know commits are expensive operations. Thanks for item 2. I was toying with the notion of pre-creating 100000 bazes off-loading them and then seeing if the COPY would be any faster; you saved me the effort of experimenting. Thanks for the benefit of your experience. __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "Oh, you hate your job? Why didn't you say so? There's a support group for that. It's called EVERYBODY, and they meet at the bar." -- Drew Carey This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com -----Original Message----- From: Sean Shanny [mailto:shannyconsulting@earthlink.net] Sent: Friday, October 24, 2003 11:31 AM To: john@pagakis.com Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Performance Concern John, Are you treating each insertion as a separate transaction? If so the performance will suffer. I am doing the same thing in building a data warehouse using PG. I have to load millions of records each night. I do two different things: 1) If I need to keep the insertions inside the java process I turn off auto-commit and every n insertions (5000 seems to give me the best performance for my setup) issue a commit. Make sure you do a final commit in a finally block so you don't miss anything. 2) Dump all the data to a file and then use a psql COPY
(columns) FROM 'file path' call to load it. Very fast. --sean John Pagakis wrote: >Greetings. > >I have a table that will require 100,000 rows initially. > >Assume the following (some of the field names have been changed for >confidentiality reasons): > >CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) >); > >ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > >ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > >Using JDBC, it took approximately one hour to insert 100,000 records. I >have an algorithm to generate a unique baz_number - it is a mixture of alpha >and numerics. > >There is a purchase table; one purchase can have many associated baz >records, but the baz records will be pre-allocated - baz.customer_id allows >null. The act of purchasing a baz will cause baz.customer_id to be >populated from the customer_id (key) field in the purchase table. > >If it took an hour to insert 100,000 records, I can only imagine how much >time it will take if one customer were to attempt to purchase all 100,000 >baz. Certainly too long for a web page. > >I've not had to deal with this kind of volume in Postgres before; I have my >suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) >but I'd *LOVE* any thoughts. > >Would I be better off making the key an identity field and not indexing on >baz_number? > >Thanks in advance for any help. > >__________________________________________________________________ >John Pagakis >Email: ih8spam_thebfh@toolsmythe.com > > >"The best way to make your dreams come true is to wake up." > -- Paul Valery > >This signature generated by > ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. > www.spazmodicfrog.com > > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > From pgsql-performance-owner@postgresql.org Fri Oct 24 21:32: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 37AB8D1B4E1 for ; Sat, 25 Oct 2003 00:32: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 98967-08 for ; Fri, 24 Oct 2003 21:32:18 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 7C8C9D1B4EB for ; Fri, 24 Oct 2003 21:32:14 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 9430536B1B; Fri, 24 Oct 2003 20:32:17 -0400 (EDT) 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 1ADCLp-0003mB-00; Fri, 24 Oct 2003 20:32:17 -0400 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> In-Reply-To: <16281.45354.209000.280418@gargle.gargle.HOWL> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Oct 2003 20:32:17 -0400 Message-ID: <878ynaupgu.fsf@stark.dyndns.tv> Lines: 114 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: 200310/642 X-Sequence-Number: 4390 Rob Nagler writes: > Greg Stark writes: > > Note that pctfree/pctused are a big performance drain on the usual case. Try > > setting them to 0/100 on a table that doesn't get updates (like a many-many > > relation table) and see how much faster it is to insert and scan. > > Right. You can optimize each table independently. The "usual" case > doesn't exist in most databases, I've found, which is why Oracle does > better. Sorry I was unclear. By "usual case" I meant reading, as opposed to updates. The size of the on-disk representation turns out to be a major determinant in a lot of database applications, since the dominant resource is i/o bandwidth. Try doing a fresh import of a large table with pctfree 0 pctuse 100 and compare how long a select takes on it compared to the original table. > In practice, I'm still stuck. As a simple example, this query > select avg(f1) from t1 group by f2 > > Takes 33 seconds (see explain analyze in another note in this thread) > to run on idle hardware with about 1GB available in the cache. It's > clearly hitting disk to do the sort. Being a dumb programmer, I > changed the query to: I didn't see the rest of the thread so forgive me if you've already seen these suggestions. FIrstly, that type of query will be faster in 7.4 due to implementing a new method for doing groups called hash aggregates. Secondly you could try raising sort_mem. Postgres can't know how much memory it really has before it swaps, so there's a parameter to tell it. And swapping would be much worse than doing disk sorts. You can raise sort_mem to tell it how much memory it's allowed to use before it goes to disk sorts. You can even use ALTER SESSION to raise it in a few DSS sessions but leave it low the many OLTP sessions. If it's high in OLTP sessions then you could quickly hit swap when they all happen to decide to use the maximum amount at the same time. But then you don't want to be doing big sorts in OLTP sessions anyways. Unfortunately there's no way to tell how much memory it thinks it's going to use. I used to use a script to monitor the pgsql_tmp directory in the database to watch for usage. > select f1 from t1; > > And wrote the rest in Perl. It takes 4 seconds to run. Why? The Perl doesn't > sort to disk, it aggregates in memory. There are 18 rows returned. What I > didn't mention is that I originally had: Oof. I expect if you convinced 7.3 to do the sort in memory by a suitable value of sort_mem it would be close, but still slower than perl. 7.4 should be very close since hash aggregates would be more or less equivalent to the perl method. > select avg(f1), t2.name from t1, t2 where t2.f2 = t1.f2 group by t2.name; > > Which is much worse: > > Aggregate (cost=161046.30..162130.42 rows=8673 width=222) (actual time=72069.10..87455.69 rows=18 loops=1) > -> Group (cost=161046.30..161479.95 rows=86729 width=222) (actual time=71066.38..78108.17 rows=963660 loops=1) > -> Sort (cost=161046.30..161263.13 rows=86729 width=222) (actual time=71066.36..72445.74 rows=963660 loops=1) > Sort Key: t2.name > -> Merge Join (cost=148030.15..153932.66 rows=86729 width=222) (actual time=19850.52..27266.40 rows=963660 loops=1) > Merge Cond: ("outer".f2 = "inner".f2) > -> Sort (cost=148028.59..150437.74 rows=963660 width=58) (actual time=19850.18..21750.12 rows=963660 loops=1) > Sort Key: t1.f2 > -> Seq Scan on t1 (cost=0.00..32479.60 rows=963660 width=58) (actual time=0.06..3333.39 rows=963660 loops=1) > -> Sort (cost=1.56..1.60 rows=18 width=164) (actual time=0.30..737.59 rows=931007 loops=1) > Sort Key: t2.f2 > -> Seq Scan on t2 (cost=0.00..1.18 rows=18 width=164) (actual time=0.05..0.08 rows=18 loops=1) > Total runtime: 87550.31 msec > > Again, there are about 18 values of f2. The optimizer even knows this > (it's a foreign key to t2.f2), but instead it does the query plan in > exactly the wrong order. It hits disk probably 3 times as much as the > simpler query judging by the amount of time this query takes (33 vs 88 > secs). BTW, adding an index to t1.f2 has seriously negative effects > on many other DSS queries. Well, first of all it doesn't really because you said to group by t2.name not f1. You might expect it to at least optimize something like this: select avg(f1),t2.name from t1 join t2 using (f2) group by f2 but even then I don't think it actually is capable of using foreign keys as a hint like that. I don't think Oracle does either actually, but I'm not sure. To convince it to do the right thing you would have to do either: SELECT a, t2.name FROM (SELECT avg(f1),f2 FROM t1 GROUP BY f2) AS t1 JOIN t2 USING (f2) Or use a subquery: SELECT a, (SELECT name FROM t2 WHERE t2.f2 = t1.f2) FROM t1 GROUP BY f2 Oh, incidentally, my use of the "JOIN" syntax is a personal preference. Ideally it would produce identical plans but unfortunately that's not always true yet, though 7.4 is closer. I think in the suggestion above it actually would. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 24 21:35: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 CADC3D1B541 for ; Sat, 25 Oct 2003 00:35: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 98621-08 for ; Fri, 24 Oct 2003 21:34:45 -0300 (ADT) Received: from fed1mtao04.cox.net (fed1mtao04.cox.net [68.6.19.241]) by svr1.postgresql.org (Postfix) with ESMTP id C9A75D1B52B for ; Fri, 24 Oct 2003 21:34:36 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao04.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031025003436.COAO21940.fed1mtao04.cox.net@toolsmythes01>; Fri, 24 Oct 2003 20:34:36 -0400 Reply-To: From: "John Pagakis" To: "Sean Shanny" Cc: Subject: Re: Performance Concern Date: Fri, 24 Oct 2003 17:38:05 -0700 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.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <3F996FDF.1040307@earthlink.net> 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=BANG_QUOTE, BAYES_30, EMAIL_ATTRIBUTION, HTML_TAG_BALANCE_TABLE, IN_REP_TO, MSGID_GOOD_EXCHANGE, ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES X-Spam-Level: X-Archive-Number: 200310/643 X-Sequence-Number: 4391 Sean - I believe auto-commit was off (not at the box right now). I'll play with the commit interval; I know commits are expensive operations. Thanks for item 2. I was toying with the notion of pre-creating 100000 bazes off-loading them and then seeing if the COPY would be any faster; you saved me the effort of experimenting. Thanks for the benefit of your experience. __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "Oh, you hate your job? Why didn't you say so? There's a support group for that. It's called EVERYBODY, and they meet at the bar." -- Drew Carey This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Sean Shanny Sent: Friday, October 24, 2003 11:31 AM To: john@pagakis.com Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Performance Concern John, Are you treating each insertion as a separate transaction? If so the performance will suffer. I am doing the same thing in building a data warehouse using PG. I have to load millions of records each night. I do two different things: 1) If I need to keep the insertions inside the java process I turn off auto-commit and every n insertions (5000 seems to give me the best performance for my setup) issue a commit. Make sure you do a final commit in a finally block so you don't miss anything. 2) Dump all the data to a file and then use a psql COPY
(columns) FROM 'file path' call to load it. Very fast. --sean John Pagakis wrote: >Greetings. > >I have a table that will require 100,000 rows initially. > >Assume the following (some of the field names have been changed for >confidentiality reasons): > >CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) >); > >ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > >ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > >Using JDBC, it took approximately one hour to insert 100,000 records. I >have an algorithm to generate a unique baz_number - it is a mixture of alpha >and numerics. > >There is a purchase table; one purchase can have many associated baz >records, but the baz records will be pre-allocated - baz.customer_id allows >null. The act of purchasing a baz will cause baz.customer_id to be >populated from the customer_id (key) field in the purchase table. > >If it took an hour to insert 100,000 records, I can only imagine how much >time it will take if one customer were to attempt to purchase all 100,000 >baz. Certainly too long for a web page. > >I've not had to deal with this kind of volume in Postgres before; I have my >suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) >but I'd *LOVE* any thoughts. > >Would I be better off making the key an identity field and not indexing on >baz_number? > >Thanks in advance for any help. > >__________________________________________________________________ >John Pagakis >Email: ih8spam_thebfh@toolsmythe.com > > >"The best way to make your dreams come true is to wake up." > -- Paul Valery > >This signature generated by > ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. > www.spazmodicfrog.com > > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match From pgsql-performance-owner@postgresql.org Fri Oct 24 22:16:20 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 B7173D1B4EB for ; Sat, 25 Oct 2003 01:16: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 07872-05 for ; Fri, 24 Oct 2003 22:15:46 -0300 (ADT) Received: from harrier.mail.pas.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by svr1.postgresql.org (Postfix) with ESMTP id 4B2E0D1B51A for ; Fri, 24 Oct 2003 22:15:38 -0300 (ADT) Received: from dpc6682163108.direcpc.com ([66.82.163.108] helo=earthlink.net) by harrier.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1ADD1k-0004Me-00 for pgsql-performance@postgresql.org; Fri, 24 Oct 2003 18:15:39 -0700 Message-ID: <3F99CEAF.9000709@earthlink.net> Date: Fri, 24 Oct 2003 21:15:27 -0400 From: Sean Shanny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-performance@postgresql.org Subject: Re: Performance Concern References: In-Reply-To: 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: 200310/644 X-Sequence-Number: 4392 John, One other thing I forgot to mention with solution 2. If you are going to be adding a fair number of records to the table on an ongoing basis you will want to drop indexes first and re-create them after the load is complete. I have tried it both ways and dropping is faster overall. --sean John Pagakis wrote: >Sean - >I believe auto-commit was off (not at the box right now). I'll play with >the commit interval; I know commits are expensive operations. > >Thanks for item 2. I was toying with the notion of pre-creating 100000 >bazes off-loading them and then seeing if the COPY would be any faster; you >saved me the effort of experimenting. Thanks for the benefit of your >experience. > >__________________________________________________________________ >John Pagakis >Email: ih8spam_thebfh@toolsmythe.com > > >"Oh, you hate your job? Why didn't you say so? > There's a support group for that. It's called > EVERYBODY, and they meet at the bar." > -- Drew Carey > >This signature generated by > ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. > www.spazmodicfrog.com > > >-----Original Message----- >From: Sean Shanny [mailto:shannyconsulting@earthlink.net] >Sent: Friday, October 24, 2003 11:31 AM >To: john@pagakis.com >Cc: pgsql-performance@postgresql.org >Subject: Re: [PERFORM] Performance Concern > > >John, > >Are you treating each insertion as a separate transaction? If so the >performance will suffer. I am doing the same thing in building a data >warehouse using PG. I have to load millions of records each night. I >do two different things: > >1) If I need to keep the insertions inside the java process I turn off >auto-commit and every n insertions (5000 seems to give me the best >performance for my setup) issue a commit. Make sure you do a final >commit in a finally block so you don't miss anything. > >2) Dump all the data to a file and then use a psql COPY
>(columns) FROM 'file path' call to load it. Very fast. > >--sean > >John Pagakis wrote: > > > >>Greetings. >> >>I have a table that will require 100,000 rows initially. >> >>Assume the following (some of the field names have been changed for >>confidentiality reasons): >> >>CREATE TABLE baz ( >> baz_number CHAR(15) NOT NULL, >> customer_id CHAR(39), >> foobar_id INTEGER, >> is_cancelled BOOL DEFAULT false NOT NULL, >> create_user VARCHAR(60) NOT NULL, >> create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, >> last_update_user VARCHAR(60) NOT NULL, >> last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, >> CONSTRAINT PK_baz PRIMARY KEY (baz_number) >>); >> >>ALTER TABLE baz >> ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); >> >>ALTER TABLE baz >> ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); >> >> >>Using JDBC, it took approximately one hour to insert 100,000 records. I >>have an algorithm to generate a unique baz_number - it is a mixture of >> >> >alpha > > >>and numerics. >> >>There is a purchase table; one purchase can have many associated baz >>records, but the baz records will be pre-allocated - baz.customer_id allows >>null. The act of purchasing a baz will cause baz.customer_id to be >>populated from the customer_id (key) field in the purchase table. >> >>If it took an hour to insert 100,000 records, I can only imagine how much >>time it will take if one customer were to attempt to purchase all 100,000 >>baz. Certainly too long for a web page. >> >>I've not had to deal with this kind of volume in Postgres before; I have my >>suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) >>but I'd *LOVE* any thoughts. >> >>Would I be better off making the key an identity field and not indexing on >>baz_number? >> >>Thanks in advance for any help. >> >>__________________________________________________________________ >>John Pagakis >>Email: ih8spam_thebfh@toolsmythe.com >> >> >>"The best way to make your dreams come true is to wake up." >> -- Paul Valery >> >>This signature generated by >> ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. >> www.spazmodicfrog.com >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >> >> >> >> >> > > > > From pgsql-performance-owner@postgresql.org Sat Oct 25 04:13: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 4E8FED1B503 for ; Sat, 25 Oct 2003 07:13: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 73222-01 for ; Sat, 25 Oct 2003 04:13:26 -0300 (ADT) Received: from fed1mtao04.cox.net (fed1mtao04.cox.net [68.6.19.241]) by svr1.postgresql.org (Postfix) with ESMTP id 921B0D1B4FB for ; Sat, 25 Oct 2003 04:13:19 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao04.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031025071315.ESZV21940.fed1mtao04.cox.net@toolsmythes01>; Sat, 25 Oct 2003 03:13:15 -0400 Reply-To: From: "John Pagakis" To: "Christopher Browne" , Subject: Re: Performance Concern Date: Sat, 25 Oct 2003 00:16:45 -0700 Message-ID: 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 IMO, Build 9.0.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: <60ekx2cuyw.fsf@dev6.int.libertyrms.info> Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/645 X-Sequence-Number: 4393 Christopher - Thanks. Answer 1: I believe auto commit was off (but I'm not at my dev box right now). I'll double-check that and the commit interval. Answer 2: Ah ha!! No indexes on FKs. I'll try that. Yes, each baz is a uniquely identifiable. I had started a SP to create gen the key but scrapped it when I saw no rand() function in pgpsql. Did I miss something? Turns out switching to ints no improvement on the inserts but a rather large one on the updates. Also, I saw evidence in my testing that Postgres seemed to like doing single updates as opposed to being handed a group of updates; see my response to Rod Taylor's post here (and Rod, if you're reading this: you were *GREAT* in "The Time Machine" !! Answer 3: Oh, there was no question three .... !! Thanks again Christopher!! __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "I am *SINCERE* about life, but I'm not *SERIOUS* about it." -- Alan Watts This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Christopher Browne Sent: Friday, October 24, 2003 12:11 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Performance Concern john@pagakis.com ("John Pagakis") writes: > Greetings. > > I have a table that will require 100,000 rows initially. > > Assume the following (some of the field names have been changed for > confidentiality reasons): > > CREATE TABLE baz ( > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_number) > ); > > ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > > ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); > > Using JDBC, it took approximately one hour to insert 100,000 records. I > have an algorithm to generate a unique baz_number - it is a mixture of alpha > and numerics. Question #1: How did you do the inserts? If AUTO-COMMIT was turned on, then that would indicate that you invoked 100,000 transactions, and that would contribute considerably to the process being slow. Put them all in as one transaction and you'd probably see it run in a fraction of the time. Question #2. Do you have indices on purchase(customer_id) and on foobar(foobar_id)? If not, then the foreign key check would be rather inefficient. > There is a purchase table; one purchase can have many associated baz > records, but the baz records will be pre-allocated - baz.customer_id > allows null. The act of purchasing a baz will cause baz.customer_id > to be populated from the customer_id (key) field in the purchase > table. > > If it took an hour to insert 100,000 records, I can only imagine how > much time it will take if one customer were to attempt to purchase > all 100,000 baz. Certainly too long for a web page. I take it that each "baz" is a uniquely identifiable product, akin to (say) an RSA certificate or the like? By the way, if you set up a stored procedure in PostgreSQL that can generate the "baz_number" identifiers, you could probably do the inserts Right Well Fast... Consider the following. I have a stored procedure, genauth(), which generates quasi-random values. (They're passwords, sort of...) cctld=# explain analyze insert into baz (baz_number, create_user, last_update_user) cctld-# select substr(genauth(), 1, 15), 'cbbrowne', 'cbbrowne' from big_table; QUERY PLAN ---------------------------------------------------------------------------- ----------------------------------- Seq Scan on big_table (cost=0.00..789.88 rows=28988 width=0) (actual time=0.20..1713.60 rows=28988 loops=1) Total runtime: 3197.40 msec (2 rows) It took about 3 seconds to insert 28988 rows into baz. (big_table, also renamed, to protect the innocent, has 28988 rows. I didn't care about its contents, just that it had a bunch of rows.) And the above is on a cheap desktop PC with IDE disk. > I've not had to deal with this kind of volume in Postgres before; I > have my suspicions on what is wrong here (could it be using a CHAR( > 15 ) as a key?) but I'd *LOVE* any thoughts. > Would I be better off making the key an identity field and not > indexing on baz_number? That might be something of an improvement, but it oughtn't be cripplingly different to use a text field rather than an integer. What's crippling is submitting 100,000 queries in 100,000 transactions. Cut THAT down to size and you'll see performance return to being reasonable. -- "cbbrowne","@","libertyrms.info" Christopher Browne (416) 646 3304 x124 (land) ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Sat Oct 25 05:21: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 49B25D1B4FE for ; Sat, 25 Oct 2003 08: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 73222-10 for ; Sat, 25 Oct 2003 05:21:17 -0300 (ADT) 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 8A17AD1B4F1 for ; Sat, 25 Oct 2003 05:21:14 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9P8JXOC011814; Sat, 25 Oct 2003 11:19:34 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9P8JVYb011812; Sat, 25 Oct 2003 11:19:31 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Performance Concern From: Hannu Krosing To: thebfh@toolsmythe.com Cc: Christopher Browne , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1067069971.11729.6.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sat, 25 Oct 2003 11:19:31 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/646 X-Sequence-Number: 4394 John Pagakis kirjutas L, 25.10.2003 kell 10:16: > Christopher - > Thanks. > > Answer 1: > I believe auto commit was off (but I'm not at my dev box right now). I'll > double-check that and the commit interval. > > Answer 2: > Ah ha!! No indexes on FKs. I'll try that. > > Yes, each baz is a uniquely identifiable. I had started a SP to create gen > the key but scrapped it when I saw no rand() function in pgpsql. Did I miss > something? hannu=# select random(); random ------------------ 0.59924242859671 (1 row) \df lists all available functions in psql to generate string keys you could use something like: hannu=# select 'key' || to_hex(cast(random()*1000000000 as int)); ?column? ------------- key1e22d8ea (1 row) ----------------- Hannu From pgsql-performance-owner@postgresql.org Sat Oct 25 06:53: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 A75CAD1B4F1 for ; Sat, 25 Oct 2003 09:53: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 83764-10 for ; Sat, 25 Oct 2003 06:52:56 -0300 (ADT) Received: from fed1mtao07.cox.net (fed1mtao07.cox.net [68.6.19.124]) by svr1.postgresql.org (Postfix) with ESMTP id 30D62D1B4FB for ; Sat, 25 Oct 2003 06:52:43 -0300 (ADT) Received: from toolsmythes01 ([68.98.9.240]) by fed1mtao07.cox.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with SMTP id <20031025095236.FECZ3394.fed1mtao07.cox.net@toolsmythes01>; Sat, 25 Oct 2003 05:52:36 -0400 Reply-To: From: "John Pagakis" To: , Subject: Re: Performance Concern Date: Sat, 25 Oct 2003 02:56:10 -0700 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.6604 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 In-Reply-To: Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=BANG_QUOTE, BAYES_30, IN_REP_TO, MSGID_GOOD_EXCHANGE, ORIGINAL_MESSAGE X-Spam-Level: X-Archive-Number: 200310/647 X-Sequence-Number: 4395 Bear with me all - working my way through this. First of all, thanks for all the terrific advice. I think I focused you on the inserts, when my *REAL* concern is the updates. Initially, I was surmising that if the insert of 100,000 baz took an hour, an update to customer_id of, say 1000 baz, would simply be outrageous. I now have a better feel for how bad it is. I have already learned that making an integer the key of baz as opposed to baz_number - a CHAR( 15 ) - cuts my update cost almost in half, so my reiteration of the example uses this schema change. Please let me start again and perhaps do a little better job of explaining: Assume the following (some of the field names have been changed for confidentiality reasons): CREATE TABLE baz ( baz_key int4 NOT NULL, baz_number CHAR(15) NOT NULL, customer_id CHAR(39), foobar_id INTEGER, is_cancelled BOOL DEFAULT false NOT NULL, create_user VARCHAR(60) NOT NULL, create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, last_update_user VARCHAR(60) NOT NULL, last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, CONSTRAINT PK_baz PRIMARY KEY (baz_key) ); ALTER TABLE baz ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); ALTER TABLE baz ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); There is a purchase table; one purchase can have many associated baz records, but the 100,00 baz records will be pre-allocated - baz.customer_id allows null. The act of purchasing a baz will cause baz.customer_id to be populated from the customer_id (key) field in the purchase table. The column customer_id is actually the key to the purchase table despite the name. The foobar table is inconsequential as it will not be populated until the baz table is sold out. So for the inserts and updates, foobar will be empty. I could probably not even gen it until I needed it. As I said earlier I'm less concerned about the inserts than I am about the updates. The reason is the 100,000 inserts will happen before the site is live. The updates will happen as part of the purchase process, so updates need to be as fast as possible. I needed to do this because I absolutely positively cannot over-allocate baz. I cannot allocate more than 100,000 period, and any number of users can attempt to purchase one or more baz simultaneously. I am attempting to avoid a race condition and avoid using database locks as I feared this table would turn into a bottleneck. Note, as this question came up more than once from my previous post: Auto Commit was off for the inserts. This will be for a public website and multiple users will be "competing" for baz resources. My thought was for each user wishing to purchase one or more bazes: - Create a list of potentially available baz: SELECT baz_key WHERE customer_id IS NULL LIMIT 100; - If there are no more records in baz with customer_id of NULL, it's a sell-out. - Iterate through the list attempting to reserve a BAZ. Iterate until you have reserved the number of baz requested or until the list is exhausted: UPDATE baz SET customer_id = WHERE baz_key = AND customer_id IS NULL; - For a given update, if no record was updated, someone else set the customer_id before you could - go to the next baz_key in the list and try again. - If the list is exhausted go get the next block of 100 potential available baz keys and go again. Anyway, given this scenario, I *HAVE* to have auto commit on for updates so that everyone is aware of everyone else immediately. I wrote a JAVA simulation of the above that did 1000 updates in 37 seconds. That left me scratching my head because in psql when I did the semi-equivalent: UPDATE baz SET customer_id = '1234' WHERE baz_key IN( SELECT baz_key FROM baz WHERE customer_id IS NULL LIMIT 1000 ); it took 1:27 (one minute 27 seconds) to execute. This led me (erroneously) to the conclusion that Postgres was somehow happier doing single updates than "grouping" them. I realized today that I missed something in my simulation (pulling an all-nighter will do that to you): my JAVA simulation had Auto Commit off and I was doing a commit at the end. Obviously that won't work given what I'm trying to do. Any updates must *IMMEDIATLY* be visible to all other processes, or I could get hit with a race condition. I re-ran with Auto Commit on and the timing fell more in line with what I saw in psql - 1:13. This seems a slow to me. Is there any way to optimize the update? Or, perhaps my design is the issue and I just need to do something else. Perhaps a lock on the table and an insert would be quicker. I'm just worried about locking in a multi-user environment. On the other hand, it looks to me like this table will be a bottleneck no matter what I do. Your thoughts, as always, are much appreciated. __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "If I had a formula for bypassing trouble, I would not pass it round. Trouble creates a capacity to handle it. I don't embrace trouble; that's as bad as treating it as an enemy. But I do say meet it as a friend, for you'll see a lot of it and had better be on speaking terms with it." -- Oliver Wendell Holmes This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of John Pagakis Sent: Thursday, October 23, 2003 5:21 AM To: pgsql-performance@postgresql.org Subject: [PERFORM] Performance Concern Greetings. I have a table that will require 100,000 rows initially. Assume the following (some of the field names have been changed for confidentiality reasons): CREATE TABLE baz ( baz_number CHAR(15) NOT NULL, customer_id CHAR(39), foobar_id INTEGER, is_cancelled BOOL DEFAULT false NOT NULL, create_user VARCHAR(60) NOT NULL, create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, last_update_user VARCHAR(60) NOT NULL, last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, CONSTRAINT PK_baz PRIMARY KEY (baz_number) ); ALTER TABLE baz ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); ALTER TABLE baz ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); Using JDBC, it took approximately one hour to insert 100,000 records. I have an algorithm to generate a unique baz_number - it is a mixture of alpha and numerics. There is a purchase table; one purchase can have many associated baz records, but the baz records will be pre-allocated - baz.customer_id allows null. The act of purchasing a baz will cause baz.customer_id to be populated from the customer_id (key) field in the purchase table. If it took an hour to insert 100,000 records, I can only imagine how much time it will take if one customer were to attempt to purchase all 100,000 baz. Certainly too long for a web page. I've not had to deal with this kind of volume in Postgres before; I have my suspicions on what is wrong here (could it be using a CHAR( 15 ) as a key?) but I'd *LOVE* any thoughts. Would I be better off making the key an identity field and not indexing on baz_number? Thanks in advance for any help. __________________________________________________________________ John Pagakis Email: ih8spam_thebfh@toolsmythe.com "The best way to make your dreams come true is to wake up." -- Paul Valery This signature generated by ... and I Quote!!(tm) Copyright (c) 1999 SpaZmodic Frog Software, Inc. www.spazmodicfrog.com ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Sat Oct 25 08:18: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 50E12D1B517 for ; Sat, 25 Oct 2003 11:18: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 00128-06 for ; Sat, 25 Oct 2003 08:17:54 -0300 (ADT) Received: from mta1.srv.hcvlny.cv.net (mta1.srv.hcvlny.cv.net [167.206.5.67]) by svr1.postgresql.org (Postfix) with ESMTP id 28CE5D1B504 for ; Sat, 25 Oct 2003 08:17:46 -0300 (ADT) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta1.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNB0036I8PTUE@mta1.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Sat, 25 Oct 2003 07:17:54 -0400 (EDT) Date: Sat, 25 Oct 2003 07:20:03 -0400 From: Allen Landsidel Subject: Re: Performance Concern In-reply-to: X-Sender: bsdasym@pop.hotpop.com To: thebfh@toolsmythe.com, john@pagakis.com, pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031025070905.02458060@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/648 X-Sequence-Number: 4396 At 05:56 10/25/2003, John Pagakis wrote: Snipping most of this, I only have one suggestion/comment to make. [snip] >CREATE TABLE baz ( > baz_key int4 NOT NULL, > baz_number CHAR(15) NOT NULL, > customer_id CHAR(39), > foobar_id INTEGER, > is_cancelled BOOL DEFAULT false NOT NULL, > create_user VARCHAR(60) NOT NULL, > create_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > last_update_user VARCHAR(60) NOT NULL, > last_update_datetime TIMESTAMP DEFAULT 'now()' NOT NULL, > CONSTRAINT PK_baz PRIMARY KEY (baz_key) >); > >ALTER TABLE baz > ADD FOREIGN KEY (customer_id) REFERENCES purchase (customer_id); > >ALTER TABLE baz > ADD FOREIGN KEY (foobar_id) REFERENCES foobar (foobar_id); [snip] >I needed to do this because I absolutely positively cannot over-allocate >baz. I cannot allocate more than 100,000 period, and any number of users >can attempt to purchase one or more baz simultaneously. I am attempting to >avoid a race condition and avoid using database locks as I feared this table >would turn into a bottleneck. [snip] I have a similar situation in the database here, using the following example schema: CREATE TABLE foo ( nID serial UNIQUE NOT NULL, bAvailable boolean NOT NULL DEFAULT true, nSomeField int4 NOT NULL, sSomeField text NOT NULL ); CREATE TABLE bar ( nfoo_id int4 UNIQUE NOT NULL ); Assume foo is the table with the 100k pre-populated records that you want to assign to visitors on your site. bar is a table whos only purpose is to eliminate race conditions, working off the following business rules: 1. -- someone attempts to get a 'foo' SELECT nID from foo WHERE bAvailable; 2. -- we first try to assign this 'foo' to ourselves -- the ? is bound to the foo.nID we selected in step 1. INSERT INTO bar (nfoo_ID) VALUES (?) 3. -- Only if step 2 is successful, do we continue, otherwise someone beat us to it. UPDATE foo SET ... WHERE nID=? The key here is step 2. Since there is a UNIQUE constraint defined on the bar.nfoo_id (could even be an FK), only one INSERT will ever succeed. All others will fail. In step 3, you can set the bAvailable flag to false, along with whatever other values you need to set for your 'baz'. This will get much easier once 7.4 is production-ready, as the WHERE IN .. or WHERE NOT IN.. subselects are (according to the HISTORY file) going to be as efficient as joins, instead of the O(n) operation they apparently are right now. Until then however, I've found this simple trick works remarkably well. -Allen From pgsql-performance-owner@postgresql.org Sat Oct 25 12:08: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 C5385D1B51E for ; Sat, 25 Oct 2003 15:08: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 35022-03 for ; Sat, 25 Oct 2003 12:08:10 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 7A60BD1B53B for ; Sat, 25 Oct 2003 12:08:09 -0300 (ADT) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 6BC4B3721F; Sat, 25 Oct 2003 11:08:04 -0400 (EDT) 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 1ADQ1M-0006dV-00; Sat, 25 Oct 2003 11:08:04 -0400 To: Cc: , Subject: Re: Performance Concern References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 25 Oct 2003 11:08:03 -0400 Message-ID: <87wuattkx8.fsf@stark.dyndns.tv> Lines: 64 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: 200310/649 X-Sequence-Number: 4397 "John Pagakis" writes: > UPDATE baz SET customer_id = '1234' WHERE baz_key IN( SELECT baz_key FROM > baz WHERE customer_id IS NULL LIMIT 1000 ); Do an "explain analyze" on this query. I bet it's doing two sequential scans. Unfortunately in 7.3 the WHERE IN type of clause is poorly handled. If you're still in development perhaps you should move to the 7.4 beta as it should handle this much better: test74=> explain UPDATE test SET customer_id = 1 WHERE a IN (SELECT a FROM test WHERE customer_id IS NULL LIMIT 1000 ); QUERY PLAN --------------------------------------------------------------------------------- Nested Loop (cost=1447.26..2069.43 rows=201 width=10) -> HashAggregate (cost=1447.26..1447.26 rows=200 width=4) -> Subquery Scan "IN_subquery" (cost=0.00..1446.01 rows=501 width=4) -> Limit (cost=0.00..1441.00 rows=501 width=4) -> Seq Scan on test (cost=0.00..1441.00 rows=501 width=4) Filter: (customer_id IS NULL) -> Index Scan using ii on test (cost=0.00..3.10 rows=1 width=10) Index Cond: (test.a = "outer".a) (8 rows) However notice you still get at the one sequential scan. One way to help the situation would be to create a partial index WHERE customer_id IS NULL. This would especially help when things are almost completely sold out and available slots are sparse. slo=> explain UPDATE test SET customer_id = 1 WHERE a IN (SELECT a FROM test WHERE customer_id IS NULL LIMIT 1000 ); QUERY PLAN ------------------------------------------------------------------------------------------ Nested Loop (cost=181.01..803.18 rows=201 width=10) -> HashAggregate (cost=181.01..181.01 rows=200 width=4) -> Subquery Scan "IN_subquery" (cost=0.00..179.76 rows=501 width=4) -> Limit (cost=0.00..174.75 rows=501 width=4) -> Index Scan using i on test (cost=0.00..174.75 rows=501 width=4) Filter: (customer_id IS NULL) -> Index Scan using ii on test (cost=0.00..3.10 rows=1 width=10) Index Cond: (test.a = "outer".a) (8 rows) Notice the both sequential scans are gone and replaced by index scans. I kind of worry you might still have a race condition with the above query. Two clients could do the subquery and pick up the same records, then both run and update them. The database would lock the records until the first one commits but I don't think that would stop the second one from updating them a second time. Perhaps moving to serializable transactions would help this, I'm not sure. It's too bad the LIMIT clause doesn't work on UPDATEs. Then you could simply do: UPDATE baz SET customer_id = '1234' where customer_id IS NULL LIMIT 1000 Which shouldn't have to scan the table twice at all and I don't think suffer from any race conditions. -- greg From pgsql-general-owner@postgresql.org Sat Oct 25 14:49:49 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4E84D1B520; Sat, 25 Oct 2003 17:49: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 61448-08; Sat, 25 Oct 2003 14:49:17 -0300 (ADT) Received: from hertz.gene.com (fw-open-virt.gene.com [192.12.78.250]) by svr1.postgresql.org (Postfix) with ESMTP id 38461D1B517; Sat, 25 Oct 2003 14:49:16 -0300 (ADT) Received: from tallac.gene.com (tallac.gene.com [128.137.116.213]) by hertz.gene.com (Switch-3.1.0/Switch-3.1.0) with ESMTP id h9PHn1tB013862; Sat, 25 Oct 2003 10:49:01 -0700 (PDT) Received: by tallac.gene.com (Postfix, from userid 13922) id 5B4C14B9BF; Sat, 25 Oct 2003 10:49:00 -0700 (PDT) Subject: explicit casting required for index use From: Reece Hart To: "pgsql-performance@postgresql.org" , pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="=-oBODLV6E1MTxTYCCWzJA" Message-Id: <1067104140.16297.125.camel@tallac> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sat, 25 Oct 2003 10:49:00 -0700 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1226 X-Sequence-Number: 51299 --=-oBODLV6E1MTxTYCCWzJA Content-Type: text/plain Content-Transfer-Encoding: 7bit Here's the basic issue: PostgreSQL doesn't use indexes unless a query criterion is of exactly the same type as the index type. This occurs even when a cast would enable the use of an index and greatly improve performance. I understand that casting is needed to use an index and will therefore affect performance -- the part I don't understand is why postgresql doesn't automatically cast query arguments to the column type, thereby enabling indexes on that column. I have a table that looks like this (extra cols, indexes, and fk constraints removed): unison@csb=# \d paprospect2 Table "unison.paprospect2" Column | Type | Modifiers -------------+---------+------------------------------------------------------------------- pseq_id | integer | not null run_id | integer | not null pmodel_id | integer | not null svm | real | Indexes: paprospect2_search1 btree (pmodel_id, run_id, svm), I often search for pseq_ids based on all of pmodel_id, run_id, and svm threshold as below, hence the multi-column index. Without an explicit cast of the svm criterion: unison@csb=# explain select pseq_id from paprospect2 where pmodel_id=8210 and run_id=1 and svm>=11; Index Scan using paprospect2_search2 on paprospect2 (cost=0.00..43268.93 rows=2 width=4) Index Cond: ((pmodel_id = 8210) AND (run_id = 1)) Filter: (svm >= 11::double precision) And with an explicit cast to real (the same as the column type and indexed type): unison@csb=# explain select pseq_id from paprospect2 where pmodel_id=8210 and run_id=1 and svm>=11::real; Index Scan using paprospect2_search1 on paprospect2 (cost=0.00..6.34 rows=2 width=4) Index Cond: ((pmodel_id = 8210) AND (run_id = 1) AND (svm >= 11::real)) Note two things above: 1) The explicit cast greatly reduces the predicted (and actual) cost. 2) The uncasted query eventually casts svm to double precision, which seems odd since the column itself is real (that is, it eventually does cast, but to the "wrong" type). For small queries (returning ~10 rows), this is worth 100x in speed (9ms v. 990ms... in absolute terms, no big deal). For larger result sets (~200 rows), I've seen more like 1000x speed increases by using an explicit cast. For the larger queries, this can mean seconds versus many minutes. Having to explicitly cast criterion is very non-intuitive. Moreover, it seems quite straightforward that PostgreSQL might incorporate casts (and perhaps even function calls like upper() for functional indexes) into its query strategy optimization. (I suppose functional indexes would apply only to immutable fx only, but that's fine.) Thanks, Reece -- Reece Hart, Ph.D. rkh@gene.com, http://www.gene.com/ Genentech, Inc. 650/225-6133 (voice), -5389 (fax) Bioinformatics and Protein Engineering 1 DNA Way, MS-93 http://www.in-machina.com/~reece/ South San Francisco, CA 94080-4990 reece@in-machina.com, GPG: 0x25EC91A0 --=-oBODLV6E1MTxTYCCWzJA Content-Type: text/html; charset=utf-8 Here's the basic issue: PostgreSQL doesn't use indexes unless a query criterion is of exactly the same type as the index type. This occurs even when a cast would enable the use of an index and greatly improve performance. I understand that casting is needed to use an index and will therefore affect performance -- the part I don't understand is why postgresql doesn't automatically cast query arguments to the column type, thereby enabling indexes on that column.


I have a table that looks like this (extra cols, indexes, and fk constraints removed):
unison@csb=# \d paprospect2
                                Table "unison.paprospect2"
   Column    |  Type   |                             Modifiers
-------------+---------+-------------------------------------------------------------------
 pseq_id     | integer | not null
 run_id      | integer | not null
 pmodel_id   | integer | not null
 svm         | real    |
Indexes: paprospect2_search1 btree (pmodel_id, run_id, svm),

I often search for pseq_ids based on all of pmodel_id, run_id, and svm threshold as below, hence the multi-column index.

Without an explicit cast of the svm criterion:
unison@csb=# explain select pseq_id from paprospect2 where pmodel_id=8210 and run_id=1 and svm>=11;
 Index Scan using paprospect2_search2 on paprospect2  (cost=0.00..43268.93 rows=2 width=4)
   Index Cond: ((pmodel_id = 8210) AND (run_id = 1))
   Filter: (svm >= 11::double precision)
And with an explicit cast to real (the same as the column type and indexed type):
unison@csb=# explain select pseq_id from paprospect2 where pmodel_id=8210 and run_id=1 and svm>=11::real;
 Index Scan using paprospect2_search1 on paprospect2  (cost=0.00..6.34 rows=2 width=4)
   Index Cond: ((pmodel_id = 8210) AND (run_id = 1) AND (svm >= 11::real))

Note two things above: 1) The explicit cast greatly reduces the predicted (and actual) cost. 2) The uncasted query eventually casts svm to double precision, which seems odd since the column itself is real (that is, it eventually does cast, but to the "wrong" type).

For small queries (returning ~10 rows), this is worth 100x in speed (9ms v. 990ms... in absolute terms, no big deal). For larger result sets (~200 rows), I've seen more like 1000x speed increases by using an explicit cast. For the larger queries, this can mean seconds versus many minutes.

Having to explicitly cast criterion is very non-intuitive. Moreover, it seems quite straightforward that PostgreSQL might incorporate casts (and perhaps even function calls like upper() for functional indexes) into its query strategy optimization. (I suppose functional indexes would apply only to immutable fx only, but that's fine.)

Thanks,
Reece

-- 
Reece Hart, Ph.D.                       rkh@gene.com, http://www.gene.com/
Genentech, Inc.                         650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93                        http://www.in-machina.com/~reece/
South San Francisco, CA  94080-4990     reece@in-machina.com, GPG: 0x25EC91A0
--=-oBODLV6E1MTxTYCCWzJA-- From pgsql-performance-owner@postgresql.org Sat Oct 25 18:16: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 7F14FD1B503 for ; Sat, 25 Oct 2003 21:16: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 80239-10 for ; Sat, 25 Oct 2003 18:15:54 -0300 (ADT) 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 5F2D5D1B52B for ; Sat, 25 Oct 2003 18:15:50 -0300 (ADT) Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h9PLDheN004066; Sun, 26 Oct 2003 00:13:44 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9PLDak0004064; Sun, 26 Oct 2003 00:13:36 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Performance Concern From: Hannu Krosing To: thebfh@toolsmythe.com Cc: john@pagakis.com, pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1067116415.3991.4.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 26 Oct 2003 00:13:36 +0300 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/651 X-Sequence-Number: 4399 John Pagakis kirjutas L, 25.10.2003 kell 12:56: > I wrote a JAVA simulation of the above that did 1000 updates in 37 seconds. > That left me scratching my head because in psql when I did the > semi-equivalent: > > UPDATE baz SET customer_id = '1234' WHERE baz_key IN( SELECT baz_key FROM > baz WHERE customer_id IS NULL LIMIT 1000 ); try it this way, maybe it will start using an index : UPDATE baz SET customer_id = '1234' WHERE baz_key IN ( SELECT baz_key FROM baz innerbaz WHERE customer_id IS NULL and innerbaz.baz_key = baz.baz_key LIMIT 1000 ); you may also try to add a conditional index to baz: CREATE INDEX baz_key_with_null_custid_nxd ON baz WHERE customer_id IS NULL; to make the index access more efficient. ---------------- Hannu From pgsql-general-owner@postgresql.org Sun Oct 26 03:26:58 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D1728D1B548; Sun, 26 Oct 2003 07:26: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 79605-04; Sun, 26 Oct 2003 03:26:28 -0400 (AST) Received: from pimout4-ext.prodigy.net (pimout4-ext.prodigy.net [207.115.63.103]) by svr1.postgresql.org (Postfix) with ESMTP id 7C3E4D1B545; Sun, 26 Oct 2003 03:26:26 -0400 (AST) Received: from sbcglobal.net (adsl-64-169-94-134.dsl.snfc21.pacbell.net [64.169.94.134]) by pimout4-ext.prodigy.net (8.12.9/8.12.3) with ESMTP id h9Q7QQl0145274; Sun, 26 Oct 2003 02:26:27 -0500 Message-ID: <3F9AEA51.2070701@sbcglobal.net> Date: Sun, 26 Oct 2003 00:25:37 +0300 From: Yonatan Goraly User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4.1) Gecko/20030917 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Slow performance with no apparent reason Content-Type: multipart/alternative; boundary="------------070309060100090007060705" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1237 X-Sequence-Number: 51310 This is a multi-part message in MIME format. --------------070309060100090007060705 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I am in the process of adding PostgreSQL support for an application, in addition to Oracle and MS SQL. I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board. I have a query that generally looks like this: SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' AND t2.q=1 This query is strikingly slow (about 100 sec when both t1 and t2 has about 1,200 records, compare with less than 4 sec with MS SQL and Oracle) The strange thing is that if I remove one of the last 2 conditions (doesn't matter which one), I get the same performance like with the other databases. Since in this particular case both conditions ( t2.p='string', t2.q=1) are not required, I can't understand why having both turns the query so slow. A query on table t2 alone is fast with or without the 2 conditions. I tired several alternatives, this one works pretty well: SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND EXISTS ( SELECT * FROM t2 t2a WHERE t2a.p='string' AND t2a.q=1 AND t2a.y=t2.y ) Since the first query is simpler than the second, it seems to me like a bug. Please advise Yonatan --------------070309060100090007060705 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I am in the process of  adding PostgreSQL support for an application, in addition to Oracle and MS SQL.
I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board.

I have a query that generally looks like this:

SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' AND t2.q=1

This query is strikingly slow (about 100 sec when both t1 and t2 has about 1,200 records, compare with less than 4 sec with MS SQL and Oracle)

The strange thing is that if I remove one of the last 2 conditions (doesn't matter which one), I get the same performance like with the other databases.
Since in this particular case both conditions ( t2.p='string', t2.q=1) are not required, I can't understand why having both turns the query so slow.
A query on table t2 alone is fast with or without the 2 conditions.

I tired several alternatives, this one works pretty well:

SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND
     EXISTS (
             SELECT * FROM t2 t2a WHERE t2a.p='string' AND t2a.q=1 AND t2a.y=t2.y )

Since the first query is simpler than the second, it seems to me like a bug.

Please advise

Yonatan
--------------070309060100090007060705-- From pgsql-general-owner@postgresql.org Sun Oct 26 04:27:48 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F035FD1B4E5 for ; Sun, 26 Oct 2003 08:27: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 95995-01 for ; Sun, 26 Oct 2003 04:27:16 -0400 (AST) Received: from pimout4-ext.prodigy.net (pimout4-ext.prodigy.net [207.115.63.103]) by svr1.postgresql.org (Postfix) with ESMTP id 958C5D1B529 for ; Sun, 26 Oct 2003 04:27:12 -0400 (AST) Received: from sbcglobal.net (adsl-64-169-94-134.dsl.snfc21.pacbell.net [64.169.94.134]) by pimout4-ext.prodigy.net (8.12.9/8.12.3) with ESMTP id h9Q8RBl0092778; Sun, 26 Oct 2003 03:27:12 -0500 Message-ID: <3F9AF88E.3040101@sbcglobal.net> Date: Sun, 26 Oct 2003 01:26:22 +0300 From: Yonatan Goraly User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4.1) Gecko/20030917 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: Martijn van Oosterhout Cc: pgsql-general@postgresql.org Subject: Re: Slow performance with no apparent reason References: <3F9AEA51.2070701@sbcglobal.net> <20031026074354.GB15100@svana.org> In-Reply-To: <20031026074354.GB15100@svana.org> Content-Type: multipart/mixed; boundary="------------050205040909090901010203" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1239 X-Sequence-Number: 51312 This is a multi-part message in MIME format. --------------050205040909090901010203 Content-Type: multipart/alternative; boundary="------------090009040505030800080503" --------------090009040505030800080503 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I guess my first message was not accurate, since t1 is a view, that includes t2. Attached are the real queries with their corresponding plans, the first one takes 10.8 sec to execute, the second one takes 0.6 sec. To simplify, I expanded the view, so the attached query refers to tables only. Martijn van Oosterhout wrote: >Please supply EXPLAIN ANALYZE output. > >On Sun, Oct 26, 2003 at 12:25:37AM +0300, Yonatan Goraly wrote: > > >>I am in the process of adding PostgreSQL support for an application, in >>addition to Oracle and MS SQL. >>I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board. >> >>I have a query that generally looks like this: >> >>SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' >>AND t2.q=1 >> >>This query is strikingly slow (about 100 sec when both t1 and t2 has >>about 1,200 records, compare with less than 4 sec with MS SQL and Oracle) >> >>The strange thing is that if I remove one of the last 2 conditions >>(doesn't matter which one), I get the same performance like with the >>other databases. >>Since in this particular case both conditions ( t2.p='string', t2.q=1) >>are not required, I can't understand why having both turns the query so >>slow. >>A query on table t2 alone is fast with or without the 2 conditions. >> >>I tired several alternatives, this one works pretty well: >> >>SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND >> EXISTS ( >> SELECT * FROM t2 t2a WHERE t2a.p='string' AND t2a.q=1 AND >>t2a.y=t2.y ) >> >>Since the first query is simpler than the second, it seems to me like a bug. >> >>Please advise >> >>Yonatan >> >> > > > --------------090009040505030800080503 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I guess my first message was not accurate, since t1 is a view, that includes t2.

Attached are the real queries with their corresponding plans, the first one takes 10.8 sec to execute, the second one takes 0.6 sec.

To simplify, I expanded the view, so the attached query refers to tables only.

Martijn van Oosterhout wrote:
Please supply EXPLAIN ANALYZE output.

On Sun, Oct 26, 2003 at 12:25:37AM +0300, Yonatan Goraly wrote:
  
I am in the process of  adding PostgreSQL support for an application, in 
addition to Oracle and MS SQL.
I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III board.

I have a query that generally looks like this:

SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' 
AND t2.q=1

This query is strikingly slow (about 100 sec when both t1 and t2 has 
about 1,200 records, compare with less than 4 sec with MS SQL and Oracle)

The strange thing is that if I remove one of the last 2 conditions 
(doesn't matter which one), I get the same performance like with the 
other databases.
Since in this particular case both conditions ( t2.p='string', t2.q=1) 
are not required, I can't understand why having both turns the query so 
slow.
A query on table t2 alone is fast with or without the 2 conditions.

I tired several alternatives, this one works pretty well:

SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND
    EXISTS (
            SELECT * FROM t2 t2a WHERE t2a.p='string' AND t2a.q=1 AND 
t2a.y=t2.y )

Since the first query is simpler than the second, it seems to me like a bug.

Please advise

Yonatan
    

  
--------------090009040505030800080503-- --------------050205040909090901010203 Content-Type: text/plain; name="Queries.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Queries.txt" ------------------------------------------------------------------------------------------------------------ slow query(10 sec): select ent.ID,ent.TYPE,ent.STATUS,ent.NAME from (select e.ID, e.TYPE, e.STATUS, e.NAME from ENT_PROJECT e, (select h.*, CASE WHEN f1.ID=-1 THEN '' ELSE f1.NAME || CASE WHEN f2.ID=-1 THEN '' ELSE ' > ' || f2.NAME || CASE WHEN f3.ID=-1 THEN '' ELSE ' > ' || f3.NAME || CASE WHEN f4.ID=-1 THEN '' ELSE ' > ' || f4.NAME || CASE WHEN f5.ID=-1 THEN '' ELSE ' > ' || f5.NAME || CASE WHEN f6.ID=-1 THEN '' ELSE ' > ' || f6.NAME END END END END END END as PATH from COMN_ATTR_HIERARCH h join ENT_FOLDER f1 on h.FOLDER_ID_1=f1.ID join ENT_FOLDER f2 on h.FOLDER_ID_2=f2.ID join ENT_FOLDER f3 on h.FOLDER_ID_3=f3.ID join ENT_FOLDER f4 on h.FOLDER_ID_4=f4.ID join ENT_FOLDER f5 on h.FOLDER_ID_5=f5.ID join ENT_FOLDER f6 on h.FOLDER_ID_6=f6.ID ) path where e.STATUS!=cast(-1 as numeric) and e.ID = path.NODE_ID) ent , COMN_ATTR_HIERARCH hier where hier.NODE_ID=ent.ID and hier.HIERARCHY_ID='IMPLEMENTATION' and hier.DOMAIN=1 ------------------------------------------------------------------------------------------------------------ QUERY PLAN Nested Loop (cost=1808.05..1955.27 rows=14 width=660) Join Filter: ("outer".id = "inner".node_id) -> Nested Loop (cost=0.00..10.82 rows=1 width=244) -> Index Scan using idx_hierarch_hierarch_id on comn_attr_hierarch hier (cost=0.00..5.98 rows=1 width=32) Index Cond: ((hierarchy_id = 'IMPLEMENTATION'::bpchar) AND ("domain" = 1::numeric)) -> Index Scan using pk_ent_project on ent_project e (cost=0.00..4.83 rows=1 width=212) Index Cond: ("outer".node_id = e.id) Filter: (status <> -1::numeric) -> Materialize (cost=1910.33..1910.33 rows=2730 width=416) -> Merge Join (cost=1808.05..1910.33 rows=2730 width=416) Merge Cond: ("outer".id = "inner".folder_id_6) -> Index Scan using pk_ent_folder on ent_folder f6 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1808.05..1814.88 rows=2730 width=384) Sort Key: h.folder_id_6 -> Merge Join (cost=1275.45..1377.73 rows=2730 width=384) Merge Cond: ("outer".id = "inner".folder_id_5) -> Index Scan using pk_ent_folder on ent_folder f5 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1275.45..1282.28 rows=2730 width=352) Sort Key: h.folder_id_5 -> Merge Join (cost=1017.37..1119.64 rows=2730 width=352) Merge Cond: ("outer".id = "inner".folder_id_4) -> Index Scan using pk_ent_folder on ent_folder f4 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1017.37..1024.19 rows=2730 width=320) Sort Key: h.folder_id_4 -> Merge Join (cost=759.28..861.56 rows=2730 width=320) Merge Cond: ("outer".id = "inner".folder_id_3) -> Index Scan using pk_ent_folder on ent_folder f3 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=759.28..766.11 rows=2730 width=288) Sort Key: h.folder_id_3 -> Merge Join (cost=501.20..603.47 rows=2730 width=288) Merge Cond: ("outer".id = "inner".folder_id_2) -> Index Scan using pk_ent_folder on ent_folder f2 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=501.20..508.02 rows=2730 width=256) Sort Key: h.folder_id_2 -> Merge Join (cost=243.11..345.39 rows=2730 width=256) Merge Cond: ("outer".id = "inner".folder_id_1) -> Index Scan using pk_ent_folder on ent_folder f1 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=243.11..249.94 rows=2730 width=224) Sort Key: h.folder_id_1 -> Seq Scan on comn_attr_hierarch h (cost=0.00..87.30 rows=2730 width=224) ------------------------------------------------------------------------------------------------------------ Fast query (.6 sec): select ent.ID,ent.TYPE,ent.STATUS,ent.NAME from (select e.ID, e.TYPE, e.STATUS, e.NAME from ENT_PROJECT e, (select h.*, CASE WHEN f1.ID=-1 THEN '' ELSE f1.NAME || CASE WHEN f2.ID=-1 THEN '' ELSE ' > ' || f2.NAME || CASE WHEN f3.ID=-1 THEN '' ELSE ' > ' || f3.NAME || CASE WHEN f4.ID=-1 THEN '' ELSE ' > ' || f4.NAME || CASE WHEN f5.ID=-1 THEN '' ELSE ' > ' || f5.NAME || CASE WHEN f6.ID=-1 THEN '' ELSE ' > ' || f6.NAME END END END END END END as PATH from COMN_ATTR_HIERARCH h join ENT_FOLDER f1 on h.FOLDER_ID_1=f1.ID join ENT_FOLDER f2 on h.FOLDER_ID_2=f2.ID join ENT_FOLDER f3 on h.FOLDER_ID_3=f3.ID join ENT_FOLDER f4 on h.FOLDER_ID_4=f4.ID join ENT_FOLDER f5 on h.FOLDER_ID_5=f5.ID join ENT_FOLDER f6 on h.FOLDER_ID_6=f6.ID ) path where e.STATUS!=cast(-1 as numeric) and e.ID = path.NODE_ID) ent , COMN_ATTR_HIERARCH hier where hier.NODE_ID=ent.ID and exists( select * from COMN_ATTR_HIERARCH h2 where h2.HIERARCHY_ID='IMPLEMENTATION' and h2.DOMAIN=1 and h2.NODE_ID=hier.NODE_ID and h2.HIERARCHY_ID=hier.HIERARCHY_ID and h2.DOMAIN=hier.DOMAIN) ------------------------------------------------------------------------------------------------------------ QUERY PLAN Merge Join (cost=16145.60..16289.84 rows=18539 width=660) Merge Cond: ("outer".id = "inner".node_id) -> Merge Join (cost=13782.29..13863.08 rows=1358 width=244) Merge Cond: ("outer".id = "inner".node_id) -> Index Scan using pk_ent_project on ent_project e (cost=0.00..54.50 rows=995 width=212) Filter: (status <> -1::numeric) -> Sort (cost=13782.29..13785.70 rows=1365 width=32) Sort Key: hier.node_id -> Seq Scan on comn_attr_hierarch hier (cost=0.00..13711.21 rows=1365 width=32) Filter: (subplan) SubPlan -> Index Scan using pk_comn_attr_hierarch on comn_attr_hierarch h2 (cost=0.00..4.99 rows=1 width=316) Index Cond: (("domain" = 1::numeric) AND ("domain" = $2) AND (node_id = $0)) Filter: ((hierarchy_id = 'IMPLEMENTATION'::bpchar) AND (hierarchy_id = $1)) -> Sort (cost=2363.32..2370.14 rows=2730 width=416) Sort Key: h.node_id -> Merge Join (cost=1808.05..1910.33 rows=2730 width=416) Merge Cond: ("outer".id = "inner".folder_id_6) -> Index Scan using pk_ent_folder on ent_folder f6 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1808.05..1814.88 rows=2730 width=384) Sort Key: h.folder_id_6 -> Merge Join (cost=1275.45..1377.73 rows=2730 width=384) Merge Cond: ("outer".id = "inner".folder_id_5) -> Index Scan using pk_ent_folder on ent_folder f5 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1275.45..1282.28 rows=2730 width=352) Sort Key: h.folder_id_5 -> Merge Join (cost=1017.37..1119.64 rows=2730 width=352) Merge Cond: ("outer".id = "inner".folder_id_4) -> Index Scan using pk_ent_folder on ent_folder f4 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=1017.37..1024.19 rows=2730 width=320) Sort Key: h.folder_id_4 -> Merge Join (cost=759.28..861.56 rows=2730 width=320) Merge Cond: ("outer".id = "inner".folder_id_3) -> Index Scan using pk_ent_folder on ent_folder f3 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=759.28..766.11 rows=2730 width=288) Sort Key: h.folder_id_3 -> Merge Join (cost=501.20..603.47 rows=2730 width=288) Merge Cond: ("outer".id = "inner".folder_id_2) -> Index Scan using pk_ent_folder on ent_folder f2 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=501.20..508.02 rows=2730 width=256) Sort Key: h.folder_id_2 -> Merge Join (cost=243.11..345.39 rows=2730 width=256) Merge Cond: ("outer".id = "inner".folder_id_1) -> Index Scan using pk_ent_folder on ent_folder f1 (cost=0.00..52.00 rows=1000 width=32) -> Sort (cost=243.11..249.94 rows=2730 width=224) Sort Key: h.folder_id_1 -> Seq Scan on comn_attr_hierarch h (cost=0.00..87.30 rows=2730 width=224) ------------------------------------------------------------------------------------------------------------ --------------050205040909090901010203-- From pgsql-performance-owner@postgresql.org Sun Oct 26 01:36: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 A9CCED1B525 for ; Sun, 26 Oct 2003 04:36: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 52834-05 for ; Sun, 26 Oct 2003 01:36:23 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 2DE67D1B52B for ; Sun, 26 Oct 2003 01:36:20 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9Q4a9f09899; Sun, 26 Oct 2003 00:36:09 -0400 (EDT) From: Bruce Momjian Message-Id: <200310260436.h9Q4a9f09899@candle.pha.pa.us> Subject: Re: analyzing postgresql performance for dbt-2 In-Reply-To: <20031021191033.A5484@osdlab.pdx.osdl.net> To: Mark Wong Date: Sun, 26 Oct 2003 00:36:09 -0400 (EDT) Cc: pgsql-performance@postgresql.org, osdldbt-general@lists.sourceforge.net 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: 200310/652 X-Sequence-Number: 4400 Mark Wong wrote: > > > Here are a pair of results where I just raise the load on the > > > database, where increasing the load increases the area of the database > > > touched in addition to increasing the transaction rate. The overall > > > metric increases somewhat, but the response time for most of the > > > interactions also increases significantly: > > > > > > http://developer.osdl.org/markw/dbt2-pgsql/158/ [baseline] > > > - load of 100 warehouses > > > - metric 1249.65 > > > > > > http://developer.osdl.org/markw/dbt2-pgsql/149/ > > > - load of 140 warehouses > > > - metric 1323.90 > > > > I looked at these charts and they looked normal to me. It looked like > > your the load increased until your computer was saturated. Is there > > something I am missing? > > I've run some i/o tests so I'm pretty sure I haven't saturated that. And it > looks like I have almost 10% more processor time left. I do agree that it > appears something might be saturated, I just don't know where to look... Could the 10% be context switching time, or is the I/O saturated? -- 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-general-owner@postgresql.org Sun Oct 26 03:44:37 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 154AED1B4E5 for ; Sun, 26 Oct 2003 07:44: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 87821-03 for ; Sun, 26 Oct 2003 03:44:06 -0400 (AST) Received: from svana.org (svana.org [203.20.62.76]) by svr1.postgresql.org (Postfix) with ESMTP id D312AD1B4F9 for ; Sun, 26 Oct 2003 03:44:03 -0400 (AST) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 1ADfZ4-00053l-00; Sun, 26 Oct 2003 18:43:54 +1100 Date: Sun, 26 Oct 2003 18:43:54 +1100 From: Martijn van Oosterhout To: Yonatan Goraly Cc: pgsql-general@postgresql.org Subject: Re: Slow performance with no apparent reason Message-ID: <20031026074354.GB15100@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Yonatan Goraly , pgsql-general@postgresql.org References: <3F9AEA51.2070701@sbcglobal.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SkvwRMAIpAhPCcCJ" Content-Disposition: inline In-Reply-To: <3F9AEA51.2070701@sbcglobal.net> User-Agent: Mutt/1.3.28i X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1238 X-Sequence-Number: 51311 --SkvwRMAIpAhPCcCJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Please supply EXPLAIN ANALYZE output. On Sun, Oct 26, 2003 at 12:25:37AM +0300, Yonatan Goraly wrote: > I am in the process of adding PostgreSQL support for an application, in= =20 > addition to Oracle and MS SQL. > I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III boa= rd. >=20 > I have a query that generally looks like this: >=20 > SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=3Dt2.y AND t2.p=3D'string'= =20 > AND t2.q=3D1 >=20 > This query is strikingly slow (about 100 sec when both t1 and t2 has=20 > about 1,200 records, compare with less than 4 sec with MS SQL and Oracle) >=20 > The strange thing is that if I remove one of the last 2 conditions=20 > (doesn't matter which one), I get the same performance like with the=20 > other databases. > Since in this particular case both conditions ( t2.p=3D'string', t2.q=3D1= )=20 > are not required, I can't understand why having both turns the query so= =20 > slow. > A query on table t2 alone is fast with or without the 2 conditions. >=20 > I tired several alternatives, this one works pretty well: >=20 > SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=3Dt2.y AND > EXISTS ( > SELECT * FROM t2 t2a WHERE t2a.p=3D'string' AND t2a.q=3D1 AND= =20 > t2a.y=3Dt2.y ) >=20 > Since the first query is simpler than the second, it seems to me like a b= ug. >=20 > Please advise >=20 > Yonatan --=20 Martijn van Oosterhout http://svana.org/kleptog/ > "All that is needed for the forces of evil to triumph is for enough good > men to do nothing." - Edmond Burke > "The penalty good people pay for not being interested in politics is to be > governed by people worse than themselves." - Plato --SkvwRMAIpAhPCcCJ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE/m3s6Y5Twig3Ge+YRAqv5AJ4lxUX6Hz1hr+YM0txMOvPGZhBXbwCfUbHZ aUsIuCmq+jOnAL2+ykhVBrA= =5CPY -----END PGP SIGNATURE----- --SkvwRMAIpAhPCcCJ-- From pgsql-general-owner@postgresql.org Sun Oct 26 05:30:50 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A01A0D1B543 for ; Sun, 26 Oct 2003 09:30: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 03656-02 for ; Sun, 26 Oct 2003 05:30:19 -0400 (AST) Received: from svana.org (svana.org [203.20.62.76]) by svr1.postgresql.org (Postfix) with ESMTP id DF0C2D1B51B for ; Sun, 26 Oct 2003 05:30:15 -0400 (AST) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 1ADhDY-0005Iu-00; Sun, 26 Oct 2003 20:29:48 +1100 Date: Sun, 26 Oct 2003 20:29:48 +1100 From: Martijn van Oosterhout To: Yonatan Goraly Cc: pgsql-general@postgresql.org Subject: Re: Slow performance with no apparent reason Message-ID: <20031026092948.GC15100@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Yonatan Goraly , pgsql-general@postgresql.org References: <3F9AEA51.2070701@sbcglobal.net> <20031026074354.GB15100@svana.org> <3F9AF88E.3040101@sbcglobal.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KDt/GgjP6HVcx58l" Content-Disposition: inline In-Reply-To: <3F9AF88E.3040101@sbcglobal.net> User-Agent: Mutt/1.3.28i X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1240 X-Sequence-Number: 51313 --KDt/GgjP6HVcx58l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ok, those figures look like you've mever run ANALYZE on that database at all, given you keep getting the default values. EXPLAIN ANALYZE would have given the actual number of matching rows. Given that, the plans are probably extremely suboptimal. Also, do you have (unique) indexes on the columns that need it. So the EXPLAIN ANALYZE output after running ANALYZE over your database would be the next step. Hope this helps, On Sun, Oct 26, 2003 at 01:26:22AM +0300, Yonatan Goraly wrote: > I guess my first message was not accurate, since t1 is a view, that=20 > includes t2. >=20 > Attached are the real queries with their corresponding plans, the first= =20 > one takes 10.8 sec to execute, the second one takes 0.6 sec. >=20 > To simplify, I expanded the view, so the attached query refers to tables= =20 > only. >=20 > Martijn van Oosterhout wrote: >=20 > >Please supply EXPLAIN ANALYZE output. > > > >On Sun, Oct 26, 2003 at 12:25:37AM +0300, Yonatan Goraly wrote: > >=20 > > > >>I am in the process of adding PostgreSQL support for an application, i= n=20 > >>addition to Oracle and MS SQL. > >>I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III= =20 > >>board. > >> > >>I have a query that generally looks like this: > >> > >>SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=3Dt2.y AND t2.p=3D'strin= g'=20 > >>AND t2.q=3D1 > >> > >>This query is strikingly slow (about 100 sec when both t1 and t2 has=20 > >>about 1,200 records, compare with less than 4 sec with MS SQL and Oracl= e) > >> > >>The strange thing is that if I remove one of the last 2 conditions=20 > >>(doesn't matter which one), I get the same performance like with the=20 > >>other databases. > >>Since in this particular case both conditions ( t2.p=3D'string', t2.q= =3D1)=20 > >>are not required, I can't understand why having both turns the query so= =20 > >>slow. > >>A query on table t2 alone is fast with or without the 2 conditions. > >> > >>I tired several alternatives, this one works pretty well: > >> > >>SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=3Dt2.y AND > >> EXISTS ( > >> SELECT * FROM t2 t2a WHERE t2a.p=3D'string' AND t2a.q=3D1 AN= D=20 > >>t2a.y=3Dt2.y ) > >> > >>Since the first query is simpler than the second, it seems to me like a= =20 > >>bug. > >> > >>Please advise > >> > >>Yonatan > >>=20=20=20 > >> > > > >=20 > > > -------------------------------------------------------------------------= ----------------------------------- > slow query(10 sec): >=20 > select ent.ID,ent.TYPE,ent.STATUS,ent.NAME > from (select > e.ID, e.TYPE, e.STATUS, e.NAME > from > ENT_PROJECT e, > (select h.*, > CASE WHEN f1.ID=3D-1 THEN '' ELSE f1.NAME || > CASE WHEN f2.ID=3D-1 THEN '' ELSE ' > ' || f2.NAME || > CASE WHEN f3.ID=3D-1 THEN '' ELSE ' > ' || f3.NAME || > CASE WHEN f4.ID=3D-1 THEN '' ELSE ' > ' || f4.NAME || > CASE WHEN f5.ID=3D-1 THEN '' ELSE ' > ' || f5.NAME || > CASE WHEN f6.ID=3D-1 THEN '' ELSE ' > ' || f6.NAME END= END END END END END as PATH > from COMN_ATTR_HIERARCH h > join ENT_FOLDER f1 on h.FOLDER_ID_1=3Df1.ID > join ENT_FOLDER f2 on h.FOLDER_ID_2=3Df2.ID > join ENT_FOLDER f3 on h.FOLDER_ID_3=3Df3.ID > join ENT_FOLDER f4 on h.FOLDER_ID_4=3Df4.ID > join ENT_FOLDER f5 on h.FOLDER_ID_5=3Df5.ID > join ENT_FOLDER f6 on h.FOLDER_ID_6=3Df6.ID > ) path > where e.STATUS!=3Dcast(-1 as numeric) > and e.ID =3D path.NODE_ID) ent , COMN_ATTR_HIERARCH hier > where hier.NODE_ID=3Dent.ID and hier.HIERARCHY_ID=3D'IMPLEMENTATION' = and hier.DOMAIN=3D1 >=20 >=20 > -------------------------------------------------------------------------= ----------------------------------- > QUERY PLAN > Nested Loop (cost=3D1808.05..1955.27 rows=3D14 width=3D660) > Join Filter: ("outer".id =3D "inner".node_id) > -> Nested Loop (cost=3D0.00..10.82 rows=3D1 width=3D244) > -> Index Scan using idx_hierarch_hierarch_id on comn_attr_hierar= ch hier (cost=3D0.00..5.98 rows=3D1 width=3D32) > Index Cond: ((hierarchy_id =3D 'IMPLEMENTATION'::bpchar) AN= D ("domain" =3D 1::numeric)) > -> Index Scan using pk_ent_project on ent_project e (cost=3D0.0= 0..4.83 rows=3D1 width=3D212) > Index Cond: ("outer".node_id =3D e.id) > Filter: (status <> -1::numeric) > -> Materialize (cost=3D1910.33..1910.33 rows=3D2730 width=3D416) > -> Merge Join (cost=3D1808.05..1910.33 rows=3D2730 width=3D416) > Merge Cond: ("outer".id =3D "inner".folder_id_6) > -> Index Scan using pk_ent_folder on ent_folder f6 (cost= =3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1808.05..1814.88 rows=3D2730 width=3D384) > Sort Key: h.folder_id_6 > -> Merge Join (cost=3D1275.45..1377.73 rows=3D2730 = width=3D384) > Merge Cond: ("outer".id =3D "inner".folder_id_5) > -> Index Scan using pk_ent_folder on ent_folde= r f5 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1275.45..1282.28 rows=3D2730 = width=3D352) > Sort Key: h.folder_id_5 > -> Merge Join (cost=3D1017.37..1119.64 = rows=3D2730 width=3D352) > Merge Cond: ("outer".id =3D "inner"= .folder_id_4) > -> Index Scan using pk_ent_folder = on ent_folder f4 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1017.37..1024.19 = rows=3D2730 width=3D320) > Sort Key: h.folder_id_4 > -> Merge Join (cost=3D759.2= 8..861.56 rows=3D2730 width=3D320) > Merge Cond: ("outer".id= =3D "inner".folder_id_3) > -> Index Scan using pk= _ent_folder on ent_folder f3 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D759.2= 8..766.11 rows=3D2730 width=3D288) > Sort Key: h.folde= r_id_3 > -> Merge Join (= cost=3D501.20..603.47 rows=3D2730 width=3D288) > Merge Cond:= ("outer".id =3D "inner".folder_id_2) > -> Index S= can using pk_ent_folder on ent_folder f2 (cost=3D0.00..52.00 rows=3D1000 w= idth=3D32) > -> Sort (= cost=3D501.20..508.02 rows=3D2730 width=3D256) > Sort = Key: h.folder_id_2 > -> M= erge Join (cost=3D243.11..345.39 rows=3D2730 width=3D256) > = Merge Cond: ("outer".id =3D "inner".folder_id_1) > = -> Index Scan using pk_ent_folder on ent_folder f1 (cost=3D0.00..52.00 r= ows=3D1000 width=3D32) > = -> Sort (cost=3D243.11..249.94 rows=3D2730 width=3D224) > = Sort Key: h.folder_id_1 > = -> Seq Scan on comn_attr_hierarch h (cost=3D0.00..87.30 rows=3D273= 0 width=3D224) >=20 >=20 > -------------------------------------------------------------------------= ----------------------------------- > Fast query (.6 sec): >=20 > select ent.ID,ent.TYPE,ent.STATUS,ent.NAME > from (select > e.ID, e.TYPE, e.STATUS, e.NAME > from > ENT_PROJECT e, > (select h.*, > CASE WHEN f1.ID=3D-1 THEN '' ELSE f1.NAME || > CASE WHEN f2.ID=3D-1 THEN '' ELSE ' > ' || f2.NAME || > CASE WHEN f3.ID=3D-1 THEN '' ELSE ' > ' || f3.NAME || > CASE WHEN f4.ID=3D-1 THEN '' ELSE ' > ' || f4.NAME || > CASE WHEN f5.ID=3D-1 THEN '' ELSE ' > ' || f5.NAME || > CASE WHEN f6.ID=3D-1 THEN '' ELSE ' > ' || f6.NAME END= END END END END END as PATH > from COMN_ATTR_HIERARCH h > join ENT_FOLDER f1 on h.FOLDER_ID_1=3Df1.ID > join ENT_FOLDER f2 on h.FOLDER_ID_2=3Df2.ID > join ENT_FOLDER f3 on h.FOLDER_ID_3=3Df3.ID > join ENT_FOLDER f4 on h.FOLDER_ID_4=3Df4.ID > join ENT_FOLDER f5 on h.FOLDER_ID_5=3Df5.ID > join ENT_FOLDER f6 on h.FOLDER_ID_6=3Df6.ID > ) path > where e.STATUS!=3Dcast(-1 as numeric) > and e.ID =3D path.NODE_ID) ent , COMN_ATTR_HIERARCH hier > where hier.NODE_ID=3Dent.ID and exists( > select * from COMN_ATTR_HIERARCH h2 where h2.HIERARCHY_ID=3D'IMPLEMENT= ATION' and h2.DOMAIN=3D1 and h2.NODE_ID=3Dhier.NODE_ID > and h2.HIERARCHY_ID=3Dhier.HIERARCHY_ID and h2.DOMAIN=3Dhier.DOMAIN) >=20 >=20 > -------------------------------------------------------------------------= ----------------------------------- > QUERY PLAN > Merge Join (cost=3D16145.60..16289.84 rows=3D18539 width=3D660) > Merge Cond: ("outer".id =3D "inner".node_id) > -> Merge Join (cost=3D13782.29..13863.08 rows=3D1358 width=3D244) > Merge Cond: ("outer".id =3D "inner".node_id) > -> Index Scan using pk_ent_project on ent_project e (cost=3D0.0= 0..54.50 rows=3D995 width=3D212) > Filter: (status <> -1::numeric) > -> Sort (cost=3D13782.29..13785.70 rows=3D1365 width=3D32) > Sort Key: hier.node_id > -> Seq Scan on comn_attr_hierarch hier (cost=3D0.00..1371= 1.21 rows=3D1365 width=3D32) > Filter: (subplan) > SubPlan > -> Index Scan using pk_comn_attr_hierarch on comn_= attr_hierarch h2 (cost=3D0.00..4.99 rows=3D1 width=3D316) > Index Cond: (("domain" =3D 1::numeric) AND ("= domain" =3D $2) AND (node_id =3D $0)) > Filter: ((hierarchy_id =3D 'IMPLEMENTATION'::= bpchar) AND (hierarchy_id =3D $1)) > -> Sort (cost=3D2363.32..2370.14 rows=3D2730 width=3D416) > Sort Key: h.node_id > -> Merge Join (cost=3D1808.05..1910.33 rows=3D2730 width=3D416) > Merge Cond: ("outer".id =3D "inner".folder_id_6) > -> Index Scan using pk_ent_folder on ent_folder f6 (cost= =3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1808.05..1814.88 rows=3D2730 width=3D384) > Sort Key: h.folder_id_6 > -> Merge Join (cost=3D1275.45..1377.73 rows=3D2730 = width=3D384) > Merge Cond: ("outer".id =3D "inner".folder_id_5) > -> Index Scan using pk_ent_folder on ent_folde= r f5 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1275.45..1282.28 rows=3D2730 = width=3D352) > Sort Key: h.folder_id_5 > -> Merge Join (cost=3D1017.37..1119.64 = rows=3D2730 width=3D352) > Merge Cond: ("outer".id =3D "inner"= .folder_id_4) > -> Index Scan using pk_ent_folder = on ent_folder f4 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D1017.37..1024.19 = rows=3D2730 width=3D320) > Sort Key: h.folder_id_4 > -> Merge Join (cost=3D759.2= 8..861.56 rows=3D2730 width=3D320) > Merge Cond: ("outer".id= =3D "inner".folder_id_3) > -> Index Scan using pk= _ent_folder on ent_folder f3 (cost=3D0.00..52.00 rows=3D1000 width=3D32) > -> Sort (cost=3D759.2= 8..766.11 rows=3D2730 width=3D288) > Sort Key: h.folde= r_id_3 > -> Merge Join (= cost=3D501.20..603.47 rows=3D2730 width=3D288) > Merge Cond:= ("outer".id =3D "inner".folder_id_2) > -> Index S= can using pk_ent_folder on ent_folder f2 (cost=3D0.00..52.00 rows=3D1000 w= idth=3D32) > -> Sort (= cost=3D501.20..508.02 rows=3D2730 width=3D256) > Sort = Key: h.folder_id_2 > -> M= erge Join (cost=3D243.11..345.39 rows=3D2730 width=3D256) > = Merge Cond: ("outer".id =3D "inner".folder_id_1) > = -> Index Scan using pk_ent_folder on ent_folder f1 (cost=3D0.00..52.00 r= ows=3D1000 width=3D32) > = -> Sort (cost=3D243.11..249.94 rows=3D2730 width=3D224) > = Sort Key: h.folder_id_1 > = -> Seq Scan on comn_attr_hierarch h (cost=3D0.00..87.30 rows=3D273= 0 width=3D224) >=20 > -------------------------------------------------------------------------= ----------------------------------- >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match --=20 Martijn van Oosterhout http://svana.org/kleptog/ > "All that is needed for the forces of evil to triumph is for enough good > men to do nothing." - Edmond Burke > "The penalty good people pay for not being interested in politics is to be > governed by people worse than themselves." - Plato --KDt/GgjP6HVcx58l Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE/m5QMY5Twig3Ge+YRAlGvAJsFovy27VJ47nkS9kITZnY+BH+OmQCggdqe 3LGYq5Dy3W8yvIB+z5vc084= =gqtY -----END PGP SIGNATURE----- --KDt/GgjP6HVcx58l-- From pgsql-performance-owner@postgresql.org Sun Oct 26 19:29: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 09DC5D1B4F9 for ; Sun, 26 Oct 2003 23:29: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 24550-02 for ; Sun, 26 Oct 2003 19:29:22 -0400 (AST) Received: from pimout4-ext.prodigy.net (pimout4-ext.prodigy.net [207.115.63.103]) by svr1.postgresql.org (Postfix) with ESMTP id 49A6FD1B4EF for ; Sun, 26 Oct 2003 19:29:19 -0400 (AST) Received: from sbcglobal.net (adsl-64-169-94-134.dsl.snfc21.pacbell.net [64.169.94.134]) by pimout4-ext.prodigy.net (8.12.9/8.12.3) with ESMTP id h9QNTDl0106828; Sun, 26 Oct 2003 18:29:21 -0500 Message-ID: <3F9BCBF5.2090506@sbcglobal.net> Date: Sun, 26 Oct 2003 15:28:21 +0200 From: Yonatan Goraly User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4.1) Gecko/20030917 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: Hannu Krosing Cc: pgsql-performance@postgresql.org Subject: Re: Slow performance with no apparent reason References: <3F9AEA51.2070701@sbcglobal.net> <1067179095.2604.3.camel@fuji.krosing.net> In-Reply-To: <1067179095.2604.3.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: 200310/657 X-Sequence-Number: 4405 I run ANALYZE and the problem resolved Thanks >Yonatan Goraly kirjutas P, 26.10.2003 kell 00:25: > > >>I am in the process of adding PostgreSQL support for an application, >>in addition to Oracle and MS SQL. >>I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III >>board. >> >>I have a query that generally looks like this: >> >>SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' >>AND t2.q=1 >> >>This query is strikingly slow (about 100 sec when both t1 and t2 has >>about 1,200 records, compare with less than 4 sec with MS SQL and >>Oracle) >> >> > >always send results of EXPLAIN ANALYZE if you ask for help on [PERFORM] > >knowing which indexes you have would also help. > >and you should have run ANALYZE too. > >----------------- >Hannu > > > > From pgsql-general-owner@postgresql.org Sun Oct 26 15:00:37 2003 X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 37B31D1B548; Sun, 26 Oct 2003 14:40: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 36900-09; Sun, 26 Oct 2003 10:40:24 -0400 (AST) Received: from fuji.krosing.net (silmet.estpak.ee [194.126.97.78]) by svr1.postgresql.org (Postfix) with ESMTP id 64135D1B554; Sun, 26 Oct 2003 10:40: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 h9QEcG5r002703; Sun, 26 Oct 2003 16:38:17 +0200 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h9QEcGEp002701; Sun, 26 Oct 2003 16:38:16 +0200 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: [PERFORM] Slow performance with no apparent reason From: Hannu Krosing To: Yonatan Goraly Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org In-Reply-To: <3F9AEA51.2070701@sbcglobal.net> References: <3F9AEA51.2070701@sbcglobal.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1067179095.2604.3.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Sun, 26 Oct 2003 16:38:16 +0200 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1247 X-Sequence-Number: 51320 Yonatan Goraly kirjutas P, 26.10.2003 kell 00:25: > I am in the process of adding PostgreSQL support for an application, > in addition to Oracle and MS SQL. > I am using PostgreSQL version 7.3.2, Red Hat 9.0 on Intel Pentium III > board. > > I have a query that generally looks like this: > > SELECT t1.col1, t2.col1 FROM t1, t2 WHERE t1.x=t2.y AND t2.p='string' > AND t2.q=1 > > This query is strikingly slow (about 100 sec when both t1 and t2 has > about 1,200 records, compare with less than 4 sec with MS SQL and > Oracle) always send results of EXPLAIN ANALYZE if you ask for help on [PERFORM] knowing which indexes you have would also help. and you should have run ANALYZE too. ----------------- Hannu From pgsql-performance-owner@postgresql.org Sun Oct 26 15:45: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 82303D1B4E8 for ; Sun, 26 Oct 2003 19:45: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 88293-06 for ; Sun, 26 Oct 2003 15:45:06 -0400 (AST) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 1B29ED1B50F for ; Sun, 26 Oct 2003 15:45:04 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id 419EC5D20 for ; Sun, 26 Oct 2003 11:44:50 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9QJio4w066578 for pgsql-performance@postgresql.org; Sun, 26 Oct 2003 11:44:50 -0800 (PST) (envelope-from dror) Date: Sun, 26 Oct 2003 11:44:50 -0800 From: Dror Matalon To: Postgresql Performance Subject: Various performance questions Message-ID: <20031026194449.GD2979@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/656 X-Sequence-Number: 4404 Hi, We're in the process of setting up a new database server. The application is an online rss aggregator which you can see at www.fastbuzz.com (still running with the old hardware). The new machine is a dual Xeon with 2 Gigs of ram The OS is freebsd 4.9. shared_buffers = 10000 sort_mem = 32768 effective_cache_size = 25520 -- freebsd forumla: vfs.hibufspace / 8192 1. While it seems to work correctly, I'm unclear on why this number is correct. 25520*8 = 204160 or 200 Megs. On a machine with 2 Gigs it seems like the number should be more like 1 - 1.5 Gigs. 2. The main performance challenges are with the items table which has around five million rows and grows at the rate of more than 100,000 rows a day. If I do a select count(*) from the items table it take 55 - 60 seconds to execute. I find it interesting that it takes that long whether it's doing it the first time and fetching the pages from disk or on subsequent request where it fetches the pages from memory. I know that it's not touching the disks because I'm running an iostat in a different window. Here's the explain analyze: explain analyze select count(*) from items; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=245377.53..245377.53 rows=1 width=0) (actual time=55246.035..55246.040 rows=1 loops=1) -> Seq Scan on items (cost=0.00..233100.62 rows=4910762 width=0) (actual time=0.054..30220.641 rows=4910762 loops=1) Total runtime: 55246.129 ms (3 rows) and the number of pages: select relpages from pg_class where relname = 'items'; relpages ---------- 183993 So does it make sense that it would take close to a minute to count the 5 million rows even if all pages are in memory? 3. Relpages is 183993 so file size should be 183993*8192 = 1507270656, roughly 1.5 gig. The actual disk size is 1073741824 or roughly 1 gig. Why the difference? 4. If I put a certain filter/condition on the query it tells me that it's doing a sequential scan, and yet it takes less time than a full sequential scan: explain analyze select count(*) from items where channel < 5000; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=249141.54..249141.54 rows=1 width=0) (actual time=26224.603..26224.608 rows=1 loops=1) -> Seq Scan on items (cost=0.00..245377.52 rows=1505605 width=0) (actual time=7.599..17686.869 rows=1632057 loops=1) Filter: (channel < 5000) Total runtime: 26224.703 ms How can it do a sequential scan and apply a filter to it in less time than the full sequential scan? Is it actually using an index without really telling me? Here's the structure of the items table Column | Type | Modifiers ---------------+--------------------------+----------- articlenumber | integer | not null channel | integer | not null title | character varying | link | character varying | description | character varying | comments | character varying(500) | dtstamp | timestamp with time zone | signature | character varying(32) | pubdate | timestamp with time zone | Indexes: "item_channel_link" btree (channel, link) "item_created" btree (dtstamp) "item_signature" btree (signature) "items_channel_article" btree (channel, articlenumber) "items_channel_tstamp" btree (channel, dtstamp) 5. Any other comments/suggestions on the above setup. Thanks, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Sun Oct 26 23:50: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 0E3DFD1B50E for ; Mon, 27 Oct 2003 03:50: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 64093-04 for ; Sun, 26 Oct 2003 23:49:44 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 6BA0AD1B50C for ; Sun, 26 Oct 2003 23:49:40 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id A19DD369C6; Sun, 26 Oct 2003 22:49:29 -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 1ADyNl-0003AL-00; Sun, 26 Oct 2003 22:49:29 -0500 To: Dror Matalon Cc: Postgresql Performance Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> In-Reply-To: <20031026194449.GD2979@rlx11.zapatec.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 26 Oct 2003 22:49:29 -0500 Message-ID: <87u15vxrue.fsf@stark.dyndns.tv> Lines: 31 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: 200310/658 X-Sequence-Number: 4406 Dror Matalon writes: > explain analyze select count(*) from items where channel < 5000; > QUERY PLAN > -------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=249141.54..249141.54 rows=1 width=0) (actual time=26224.603..26224.608 rows=1 loops=1) > -> Seq Scan on items (cost=0.00..245377.52 rows=1505605 width=0) (actual time=7.599..17686.869 rows=1632057 loops=1) > Filter: (channel < 5000) > Total runtime: 26224.703 ms > > > How can it do a sequential scan and apply a filter to it in less time > than the full sequential scan? Is it actually using an index without > really telling me? It's not using the index and not telling you. It's possible the count(*) operator itself is taking some time. Postgres doesn't have to call it on the rows that don't match the where clause. How long does "explain analyze select 1 from items" with and without the where clause take? What version of postgres is this?. In 7.4 (and maybe 7.3?) count() uses an int8 to store its count so it's not limited to 4 billion records. Unfortunately int8 is somewhat inefficient as it has to be dynamically allocated repeatedly. It's possible it's making a noticeable difference, especially with all the pages in cache, though I'm a bit surprised. There's some thought about optimizing this in 7.5. -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 00:28: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 E4DEBD1B4F4 for ; Mon, 27 Oct 2003 04:28: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 72219-03 for ; Mon, 27 Oct 2003 00:27:38 -0400 (AST) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id 06F9DD1B50A for ; Mon, 27 Oct 2003 00:27:36 -0400 (AST) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9R4RPh0006784 for ; Mon, 27 Oct 2003 12:27:29 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9R4ROJT013419 for ; Mon, 27 Oct 2003 12:27:24 +0800 (SGT) Subject: Duplicate in pg_user table To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Mon, 27 Oct 2003 12:27:29 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/27/2003 12:27:30 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/659 X-Sequence-Number: 4407 Hi Currently we are running Postgresql v7.3.2 on Redhat Linux OS v9.0. We have Windows2000 client machines inserting records into the Postgresql tables via the Postgres ODBC v7.3.0100. After a few weeks of usage, when we do a \d at the sql prompt, there was a duplicate object name in the same schema, ie it can be a duplicate row of index or table. When we do a \d table_name, it will show a duplication of column names inside the table. We discovered that the schema in the pg_user table was duplicated also; thus causing the pg_dump to fail. Thank you, REgards. From pgsql-performance-owner@postgresql.org Mon Oct 27 00:55: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 70D48D1B4ED for ; Mon, 27 Oct 2003 04:55: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 65448-07 for ; Mon, 27 Oct 2003 00:54:47 -0400 (AST) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 10A25D1B4E1 for ; Mon, 27 Oct 2003 00:54:47 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id C65F55D20 for ; Sun, 26 Oct 2003 20:54:31 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9R4sVNQ067273 for pgsql-performance@postgresql.org; Sun, 26 Oct 2003 20:54:31 -0800 (PST) (envelope-from dror) Date: Sun, 26 Oct 2003 20:54:31 -0800 From: Dror Matalon To: Postgresql Performance Subject: Re: Various performance questions Message-ID: <20031027045431.GE2979@rlx11.zapatec.com> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87u15vxrue.fsf@stark.dyndns.tv> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/660 X-Sequence-Number: 4408 On Sun, Oct 26, 2003 at 10:49:29PM -0500, Greg Stark wrote: > Dror Matalon writes: > > > explain analyze select count(*) from items where channel < 5000; > > QUERY PLAN > > -------------------------------------------------------------------------------------------------------------------------- > > Aggregate (cost=249141.54..249141.54 rows=1 width=0) (actual time=26224.603..26224.608 rows=1 loops=1) > > -> Seq Scan on items (cost=0.00..245377.52 rows=1505605 width=0) (actual time=7.599..17686.869 rows=1632057 loops=1) > > Filter: (channel < 5000) > > Total runtime: 26224.703 ms > > > > > > How can it do a sequential scan and apply a filter to it in less time > > than the full sequential scan? Is it actually using an index without > > really telling me? > > It's not using the index and not telling you. > > It's possible the count(*) operator itself is taking some time. Postgres I find it hard to believe that the actual counting would take a significant amount of time. > doesn't have to call it on the rows that don't match the where clause. How > long does "explain analyze select 1 from items" with and without the where > clause take? Same as count(*). Around 55 secs with no where clause, around 25 secs with. > > What version of postgres is this?. In 7.4 (and maybe 7.3?) count() uses an This is 7.4. > int8 to store its count so it's not limited to 4 billion records. > Unfortunately int8 is somewhat inefficient as it has to be dynamically > allocated repeatedly. It's possible it's making a noticeable difference, > especially with all the pages in cache, though I'm a bit surprised. There's > some thought about optimizing this in 7.5. > > -- > greg > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Mon Oct 27 02:15: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 7D7D5D1B4EF for ; Mon, 27 Oct 2003 06:15: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 91171-01 for ; Mon, 27 Oct 2003 02:15:00 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id A0471D1B4ED for ; Mon, 27 Oct 2003 02:14:59 -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 h9R6ExNu043948 for ; Mon, 27 Oct 2003 06:14:59 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9R6CQLo043824 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 06:12:26 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Various performance questions Date: Mon, 27 Oct 2003 01:04:49 -0500 Organization: cbbrowne Computing Inc Lines: 44 Message-ID: References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.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:dAUux8RjFZFVLGCqScpOJmrLRAA= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/661 X-Sequence-Number: 4409 dror@zapatec.com (Dror Matalon) wrote: > On Sun, Oct 26, 2003 at 10:49:29PM -0500, Greg Stark wrote: >> Dror Matalon writes: >> >> > explain analyze select count(*) from items where channel < 5000; >> > QUERY PLAN >> > -------------------------------------------------------------------------------------------------------------------------- >> > Aggregate (cost=249141.54..249141.54 rows=1 width=0) (actual time=26224.603..26224.608 rows=1 loops=1) >> > -> Seq Scan on items (cost=0.00..245377.52 rows=1505605 width=0) (actual time=7.599..17686.869 rows=1632057 loops=1) >> > Filter: (channel < 5000) >> > Total runtime: 26224.703 ms >> > >> > >> > How can it do a sequential scan and apply a filter to it in less time >> > than the full sequential scan? Is it actually using an index without >> > really telling me? >> >> It's not using the index and not telling you. >> >> It's possible the count(*) operator itself is taking some time. Postgres > > I find it hard to believe that the actual counting would take a > significant amount of time. Most of the time involves: a) Reading each page of the table, and b) Figuring out which records on those pages are still "live." What work were you thinking was involved in doing the counting? >> doesn't have to call it on the rows that don't match the where clause. How >> long does "explain analyze select 1 from items" with and without the where >> clause take? > > Same as count(*). Around 55 secs with no where clause, around 25 secs > with. Good; at least that's consistent... -- (format nil "~S@~S" "cbbrowne" "acm.org") http://www3.sympatico.ca/cbbrowne/postgresql.html Signs of a Klingon Programmer #2: "You question the worthiness of my code? I should kill you where you stand!" From pgsql-performance-owner@postgresql.org Mon Oct 27 02:33: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 0D842D1B4ED for ; Mon, 27 Oct 2003 06:33: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 76351-10 for ; Mon, 27 Oct 2003 02:32:57 -0400 (AST) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id 52E83D1B4E5 for ; Mon, 27 Oct 2003 02:32:56 -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.43 $ on Novell NetWare via secured & encrypted transport (TLS); Sun, 26 Oct 2003 23:32:47 -0700 Message-ID: <3F9CBC0A.1070706@myrealbox.com> Date: Mon, 27 Oct 2003 12:02:42 +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: Vivek Khera Cc: Josh Berkus , pgsql-performance@postgresql.org Subject: Re: slow select References: <906E2C446A276048A1BE283F17BCB12CDB4230@encounter.fairind.fairfield.com> <200310221442.56816.josh@agliodbs.com> <200310240822.57737.josh@agliodbs.com> <16281.18548.53239.394135@yertle.int.kciLink.com> In-Reply-To: <16281.18548.53239.394135@yertle.int.kciLink.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: 200310/662 X-Sequence-Number: 4410 Vivek Khera wrote: >>>>>>"JB" == Josh Berkus writes: > JB> Actually, what OS's can't use all idle ram for kernel cache? I > JB> should note that in my performance docs .... > > FreeBSD. Limited by the value of "sysctl vfs.hibufspace" from what I > understand. This value is set at boot based on available RAM and some > other tuning parameters. Actually I wanted to ask this question for long time. Can we have guidelines about how to set effective cache size for various OSs? Linux is pretty simple. Everything free is buffer cache. FreeBSD, not so straightforward but there is a sysctl.. How about HP-UX, Solaris and AIX? Other BSDs? and most importantly windows? That could add much value to the tuning guide. Isn't it? Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 27 03:17: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 35DDFD1B4F9 for ; Mon, 27 Oct 2003 07:17: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 92690-05 for ; Mon, 27 Oct 2003 03:17:04 -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 5978FD1B4E1 for ; Mon, 27 Oct 2003 03:17:03 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id D6594A941 for ; Sun, 26 Oct 2003 23:17:04 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9R7H3Ii067522 for pgsql-performance@postgresql.org; Sun, 26 Oct 2003 23:17:03 -0800 (PST) (envelope-from dror) Date: Sun, 26 Oct 2003 23:17:03 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Various performance questions Message-ID: <20031027071703.GF2979@rlx11.zapatec.com> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> 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: 200310/663 X-Sequence-Number: 4411 On Mon, Oct 27, 2003 at 01:04:49AM -0500, Christopher Browne wrote: > dror@zapatec.com (Dror Matalon) wrote: > > On Sun, Oct 26, 2003 at 10:49:29PM -0500, Greg Stark wrote: > >> Dror Matalon writes: > >> > >> > explain analyze select count(*) from items where channel < 5000; > >> > QUERY PLAN > >> > -------------------------------------------------------------------------------------------------------------------------- > >> > Aggregate (cost=249141.54..249141.54 rows=1 width=0) (actual time=26224.603..26224.608 rows=1 loops=1) > >> > -> Seq Scan on items (cost=0.00..245377.52 rows=1505605 width=0) (actual time=7.599..17686.869 rows=1632057 loops=1) > >> > Filter: (channel < 5000) > >> > Total runtime: 26224.703 ms > >> > > >> > > >> > How can it do a sequential scan and apply a filter to it in less time > >> > than the full sequential scan? Is it actually using an index without > >> > really telling me? > >> > >> It's not using the index and not telling you. > >> > >> It's possible the count(*) operator itself is taking some time. Postgres > > > > I find it hard to believe that the actual counting would take a > > significant amount of time. > > Most of the time involves: > > a) Reading each page of the table, and > b) Figuring out which records on those pages are still "live." The table has been VACUUM ANALYZED so that there are no "dead" records. It's still not clear why select count() would be slower than select with a "where" clause. > > What work were you thinking was involved in doing the counting? I was answering an earlier response that suggested that maybe the actual counting took time so it would take quite a bit longer when there are more rows to count. > > >> doesn't have to call it on the rows that don't match the where clause. How > >> long does "explain analyze select 1 from items" with and without the where > >> clause take? > > > > Same as count(*). Around 55 secs with no where clause, around 25 secs > > with. > > Good; at least that's consistent... > -- > (format nil "~S@~S" "cbbrowne" "acm.org") > http://www3.sympatico.ca/cbbrowne/postgresql.html > Signs of a Klingon Programmer #2: "You question the worthiness of my > code? I should kill you where you stand!" > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Mon Oct 27 03:23: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 E2DF5D1B544 for ; Mon, 27 Oct 2003 07:23: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 92007-08 for ; Mon, 27 Oct 2003 03:22:39 -0400 (AST) Received: from smtp.pspl.co.in (www.pspl.co.in [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 59476D1B50A for ; Mon, 27 Oct 2003 03:22:33 -0400 (AST) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9R7MZN3015066 for ; Mon, 27 Oct 2003 12:52:35 +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 h9R7MYfQ015039; Mon, 27 Oct 2003 12:52:35 +0530 Message-ID: <3F9CC7B3.2090501@persistent.co.in> Date: Mon, 27 Oct 2003 12:52:27 +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: Dror Matalon Cc: pgsql-performance@postgresql.org Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.com> In-Reply-To: <20031027071703.GF2979@rlx11.zapatec.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: 200310/664 X-Sequence-Number: 4412 Dror Matalon wrote: > On Mon, Oct 27, 2003 at 01:04:49AM -0500, Christopher Browne wrote: >>Most of the time involves: >> >> a) Reading each page of the table, and >> b) Figuring out which records on those pages are still "live." > > > The table has been VACUUM ANALYZED so that there are no "dead" records. > It's still not clear why select count() would be slower than select with > a "where" clause. Do a vacuum verbose full and then everything should be within small range of each other. Also in the where clause, does explicitly typecasting helps? Like 'where channel<5000::int2;' HTH Shridhar From pgsql-performance-owner@postgresql.org Mon Oct 27 03:44: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 6638DD1B507 for ; Mon, 27 Oct 2003 07:44: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 01857-01 for ; Mon, 27 Oct 2003 03:44:00 -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 50A30D1B510 for ; Mon, 27 Oct 2003 03:43:59 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id C6636A941 for ; Sun, 26 Oct 2003 23:43:57 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9R7hvwf067558 for pgsql-performance@postgresql.org; Sun, 26 Oct 2003 23:43:57 -0800 (PST) (envelope-from dror) Date: Sun, 26 Oct 2003 23:43:57 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Various performance questions Message-ID: <20031027074357.GG2979@rlx11.zapatec.com> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.com> <3F9CC7B3.2090501@persistent.co.in> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F9CC7B3.2090501@persistent.co.in> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/665 X-Sequence-Number: 4413 On Mon, Oct 27, 2003 at 12:52:27PM +0530, Shridhar Daithankar wrote: > Dror Matalon wrote: > > >On Mon, Oct 27, 2003 at 01:04:49AM -0500, Christopher Browne wrote: > >>Most of the time involves: > >> > >>a) Reading each page of the table, and > >>b) Figuring out which records on those pages are still "live." > > > > > >The table has been VACUUM ANALYZED so that there are no "dead" records. > >It's still not clear why select count() would be slower than select with > >a "where" clause. > > Do a vacuum verbose full and then everything should be within small range > of each other. > I did vaccum full verbose and the results are the same as before, 55 seconds for count(*) and 26 seconds for count(*) where channel < 5000. > Also in the where clause, does explicitly typecasting helps? > > Like 'where channel<5000::int2;' It makes no difference. > > HTH > > Shridhar > -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Mon Oct 27 05:19: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 7536DD1B510 for ; Mon, 27 Oct 2003 09:19: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 14415-06 for ; Mon, 27 Oct 2003 05:18:58 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 5EAFDD1B522 for ; Mon, 27 Oct 2003 05:18:56 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 646BD1F99; Mon, 27 Oct 2003 04:18:57 -0500 (EST) Subject: Re: explicit casting required for index use From: Neil Conway To: Reece Hart Cc: "pgsql-performance@postgresql.org" In-Reply-To: <1067104140.16297.125.camel@tallac> References: <1067104140.16297.125.camel@tallac> Content-Type: text/plain Message-Id: <1067246333.457.12.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 04:18:53 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/666 X-Sequence-Number: 4414 On Sat, 2003-10-25 at 13:49, Reece Hart wrote: > Having to explicitly cast criterion is very non-intuitive. Moreover, > it seems quite straightforward that PostgreSQL might incorporate casts This is a well-known issue with the query optimizer -- search the mailing list archives for lots more information. The executive summary is that this is NOT a trivial issue to fix, and it hasn't been fixed in 7.4, but there is some speculation on how to fix it at some point in the future. -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 06:11: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 9D9F3D1B4F4 for ; Mon, 27 Oct 2003 10:11: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 17597-10 for ; Mon, 27 Oct 2003 06:10:43 -0400 (AST) Received: from email04.aon.at (WARSL402PIP2.highway.telekom.at [195.3.96.74]) by svr1.postgresql.org (Postfix) with SMTP id 00AE6D1B510 for ; Mon, 27 Oct 2003 06:10:40 -0400 (AST) Received: (qmail 44844 invoked from network); 27 Oct 2003 10:10:40 -0000 Received: from m150p029.dipool.highway.telekom.at (HELO cantor) ([62.46.8.189]) (envelope-sender ) by qmail7rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 27 Oct 2003 10:10:40 -0000 From: Manfred Koizar To: Hannu Krosing Cc: thebfh@toolsmythe.com, john@pagakis.com, pgsql-performance@postgresql.org Subject: Re: Performance Concern Date: Mon, 27 Oct 2003 11:08:49 +0100 Message-ID: <1fqppvc6j3jbj2ifsh2qaagdrtsl52gab8@email.aon.at> References: <1067116415.3991.4.camel@fuji.krosing.net> In-Reply-To: <1067116415.3991.4.camel@fuji.krosing.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: 200310/667 X-Sequence-Number: 4415 On Sun, 26 Oct 2003 00:13:36 +0300, Hannu Krosing wrote: >UPDATE baz > SET customer_id = '1234' > WHERE baz_key IN ( > SELECT baz_key > FROM baz innerbaz > WHERE customer_id IS NULL > and innerbaz.baz_key = baz.baz_key > LIMIT 1000 ); AFAICS this is not what the OP intended. It is equivalent to UPDATE baz SET customer_id = '1234' WHERE customer_id IS NULL; because the subselect is now correlated to the outer query and is evaluated for each row of the outer query which makes the LIMIT clause ineffective. Servus Manfred From pgsql-performance-owner@postgresql.org Mon Oct 27 09:15: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 AB8ACD1B4FE for ; Mon, 27 Oct 2003 13:15: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 45622-04 for ; Mon, 27 Oct 2003 09:15:04 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id F3CA7D1B4F1 for ; Mon, 27 Oct 2003 09:15: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 h9RDExNu008269 for ; Mon, 27 Oct 2003 13:14:59 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9RCqMaw004139 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 12:52:22 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Various performance questions Date: Mon, 27 Oct 2003 07:52:06 -0500 Organization: cbbrowne Computing Inc Lines: 21 Message-ID: References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.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:ky8ZiDGnWuUk66ck3tMrBcnPyqQ= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/668 X-Sequence-Number: 4416 In the last exciting episode, dror@zapatec.com (Dror Matalon) wrote: > I was answering an earlier response that suggested that maybe the actual > counting took time so it would take quite a bit longer when there are > more rows to count. Well, if a "where clause" allows the system to use an index to search for the subset of elements, that would reduce the number of pages that have to be examined, thereby diminishing the amount of work. Why don't you report what EXPLAIN ANALYZE returns as output for the query with WHERE clause? That would allow us to get more of an idea of what is going on... -- (format nil "~S@~S" "cbbrowne" "acm.org") http://www3.sympatico.ca/cbbrowne/spiritual.html When replying, it is often possible to cleverly edit the original message in such a way as to subtly alter its meaning or tone to your advantage while appearing that you are taking pains to preserve the author's intent. As a bonus, it will seem that your superior intellect is cutting through all the excess verbiage to the very heart of the matter. -- from the Symbolics Guidelines for Sending Mail From pgsql-performance-owner@postgresql.org Mon Oct 27 11:09: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 A0041D1B548 for ; Mon, 27 Oct 2003 15:09: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 62028-09 for ; Mon, 27 Oct 2003 11:09:14 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 9B7D3D1B529 for ; Mon, 27 Oct 2003 11:09:10 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 96DF636C51; Mon, 27 Oct 2003 10:09:09 -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 1AE8zV-0004n7-00; Mon, 27 Oct 2003 10:09:09 -0500 To: Christopher Browne Cc: pgsql-performance@postgresql.org Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.com> In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 10:09:09 -0500 Message-ID: <87oew2yay2.fsf@stark.dyndns.tv> Lines: 39 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: 200310/669 X-Sequence-Number: 4417 Christopher Browne writes: > In the last exciting episode, dror@zapatec.com (Dror Matalon) wrote: > > I was answering an earlier response that suggested that maybe the actual > > counting took time so it would take quite a bit longer when there are > > more rows to count. That was my theory. I guess it's wrong. There is other work involved in processing a record, but i'm surprised it's as long as the work to actually pull the record from kernel and check if it's visible. > Well, if a "where clause" allows the system to use an index to search > for the subset of elements, that would reduce the number of pages that > have to be examined, thereby diminishing the amount of work. it's not. therein lies the mystery. > Why don't you report what EXPLAIN ANALYZE returns as output for the > query with WHERE clause? That would allow us to get more of an idea > of what is going on... He did, right at the start of the thread. For a 1 million record table without he's seeing select 1 from tab select count(*) from tab being comparable with only a slight delay for the count(*) whereas select 1 from tab where c < 1000 select count(*) from tab where c < 1000 are much faster even though they still use a sequential scan. I'm puzzled why the where clause speeds things up as much as it does. -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 11:15: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 62E5ED1B580 for ; Mon, 27 Oct 2003 15:15: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 65005-07 for ; Mon, 27 Oct 2003 11:15:28 -0400 (AST) Received: from kiwi.iasi.rdsnet.ro (kiwi.iasi.rdsnet.ro [213.157.176.3]) by svr1.postgresql.org (Postfix) with ESMTP id 8D121D1B55D for ; Mon, 27 Oct 2003 11:15:23 -0400 (AST) Received: from blackblue.iasi.rdsnet.ro (blackblue.iasi.rdsnet.ro [213.157.176.7]) by kiwi.iasi.rdsnet.ro (8.12.9/8.12.9) with ESMTP id h9RFFCE6030624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Oct 2003 17:15:12 +0200 Received: from blackblue.iasi.rdsnet.ro (localhost.localdomain [127.0.0.1]) by blackblue.iasi.rdsnet.ro (8.12.9/8.12.9) with ESMTP id h9RFFCen009173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 27 Oct 2003 17:15:12 +0200 Received: from localhost (Mituc@localhost) by blackblue.iasi.rdsnet.ro (8.12.9/8.12.9/Submit) with ESMTP id h9RFF5x8009169; Mon, 27 Oct 2003 17:15:12 +0200 X-Authentication-Warning: blackblue.iasi.rdsnet.ro: Mituc owned process doing -bs Date: Mon, 27 Oct 2003 17:15:05 +0200 (EET) From: Tarhon-Onu Victor To: Dror Matalon Cc: Postgresql Performance Subject: Re: Various performance questions In-Reply-To: <20031026194449.GD2979@rlx11.zapatec.com> Message-ID: References: <20031026194449.GD2979@rlx11.zapatec.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/670 X-Sequence-Number: 4418 On Sun, 26 Oct 2003, Dror Matalon wrote: > Here's the structure of the items table [snip] > pubdate | timestamp with time zone | > Indexes: > "item_channel_link" btree (channel, link) > "item_created" btree (dtstamp) > "item_signature" btree (signature) > "items_channel_article" btree (channel, articlenumber) > "items_channel_tstamp" btree (channel, dtstamp) > > > 5. Any other comments/suggestions on the above setup. Try set enable_seqscan = off; set enable_indexscan = on; to force the planner to use one of the indexes. Analyze the queries from your application and see what are the most used columns in WHERE clauses and recreate the indexes. select count(*) from items where channel < 5000; will never use any of the current indexes because none matches your WHERE clause (channel appears now only in multicolumn indexes). -- Any views or opinions presented within this e-mail are solely those of the author and do not necessarily represent those of any company, unless otherwise expressly stated. From pgsql-performance-owner@postgresql.org Mon Oct 27 11:16: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 D29FED1B580 for ; Mon, 27 Oct 2003 15:16: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 63333-09 for ; Mon, 27 Oct 2003 11:16:10 -0400 (AST) Received: from relay01.kbs.net.au (149.32.220.203.comindico.com.au [203.220.32.149]) by svr1.postgresql.org (Postfix) with ESMTP id 17B75D1B4F9 for ; Mon, 27 Oct 2003 11:16:06 -0400 (AST) Received: from [203.221.247.125] (helo=familyhealth.com.au) by relay01.kbs.net.au with esmtp (Exim 3.36 #1) id 1AE96O-00066z-00 for pgsql-performance@postgresql.org; Tue, 28 Oct 2003 02:16:16 +1100 Message-ID: <3F9D36B5.2080802@familyhealth.com.au> Date: Mon, 27 Oct 2003 23:16:05 +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: pgsql-performance@postgresql.org Subject: Linux Filesystem Shootout 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: 200310/671 X-Sequence-Number: 4419 http://fsbench.netnation.com/ Seems to answer a few of the questions about which might be the best filesystem... Chris From pgsql-performance-owner@postgresql.org Mon Oct 27 11:35: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 650A5D1B4FB for ; Mon, 27 Oct 2003 15:35: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 73030-02 for ; Mon, 27 Oct 2003 11:35:01 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 7FDEDD1B548 for ; Mon, 27 Oct 2003 11:34:57 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 9D3E51E41; Mon, 27 Oct 2003 10:34:57 -0500 (EST) Subject: Re: Various performance questions From: Neil Conway To: Tarhon-Onu Victor Cc: Dror Matalon , PostgreSQL Performance In-Reply-To: References: <20031026194449.GD2979@rlx11.zapatec.com> Content-Type: text/plain Message-Id: <1067268893.460.31.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 10:34:53 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/672 X-Sequence-Number: 4420 On Mon, 2003-10-27 at 10:15, Tarhon-Onu Victor wrote: > select count(*) from items where channel < > 5000; will never use any of the current indexes because none matches > your WHERE clause (channel appears now only in multicolumn indexes). No -- a multi-column index can be used to answer queries on a prefix of the index's column list. So an index on (channel, xyz) can be used to answer queries on (just) "channel". -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 11:42: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 F2F9ED1B538 for ; Mon, 27 Oct 2003 15:42: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 72388-08 for ; Mon, 27 Oct 2003 11:41:53 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id ECC49D1B50A for ; Mon, 27 Oct 2003 11:41:48 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 5B9D21F94; Mon, 27 Oct 2003 10:41:53 -0500 (EST) Subject: Re: Various performance questions From: Neil Conway To: Greg Stark Cc: Dror Matalon , PostgreSQL Performance In-Reply-To: <87u15vxrue.fsf@stark.dyndns.tv> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> Content-Type: text/plain Message-Id: <1067269309.459.33.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 10:41:49 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/673 X-Sequence-Number: 4421 On Sun, 2003-10-26 at 22:49, Greg Stark wrote: > What version of postgres is this?. In 7.4 (and maybe 7.3?) count() uses an > int8 to store its count so it's not limited to 4 billion records. > Unfortunately int8 is somewhat inefficient as it has to be dynamically > allocated repeatedly. Uh, what? Why would an int8 need to be "dynamically allocated repeatedly"? -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 12:04: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 75028D1B507 for ; Mon, 27 Oct 2003 16:04: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 74665-03 for ; Mon, 27 Oct 2003 12:03:36 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id BAD8FD1B50A for ; Mon, 27 Oct 2003 12:03:36 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 207213E29 for ; Mon, 27 Oct 2003 11:03:36 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 31908-03-2 for ; Mon, 27 Oct 2003 11:03:35 -0500 (EST) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 96FA43E24 for ; Mon, 27 Oct 2003 11:03:35 -0500 (EST) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9RG3ZMN002722 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 11:03:35 -0500 (EST) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: My own performance/tuning q&a Date: Mon, 27 Oct 2003 11:03:35 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 22 Message-ID: References: <16281.22423.26659.54130@yertle.int.kciLink.com> <200310242050.h9OKoYX22829@candle.pha.pa.us> <6.0.0.22.0.20031024194443.024306b8@pop.hotpop.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067270615 84809 216.194.193.105 (27 Oct 2003 16:03:35 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 27 Oct 2003 16:03:35 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:vNCRn2Jxf3HcxgNESncQmBnnGmE= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/674 X-Sequence-Number: 4422 >>>>> "AL" == Allen Landsidel writes: AL> However, I do the same thing with the reindex, so I'll definitely be AL> taking it out there, as that one does lock.. although I would think AL> the worst this would do would be a making the index unavailable and AL> forcing a seq scan.. is that not the case? Nope. *All* access to the table is locked out. AL> ---------------------------(end of broadcast)--------------------------- AL> TIP 5: Have you checked our extensive FAQ? AL> http://www.postgresql.org/docs/faqs/FAQ.html -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 27 12:06: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 AE32DD1B57A for ; Mon, 27 Oct 2003 16:06: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 74231-04 for ; Mon, 27 Oct 2003 12:06:13 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 1DECDD1B538 for ; Mon, 27 Oct 2003 12:06:13 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 972583E29 for ; Mon, 27 Oct 2003 11:06:12 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 31908-03-6 for ; Mon, 27 Oct 2003 11:06:12 -0500 (EST) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id DB0E63E24 for ; Mon, 27 Oct 2003 11:06:11 -0500 (EST) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9RG6BtZ075429 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 11:06:11 -0500 (EST) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: My own performance/tuning q&a Date: Mon, 27 Oct 2003 11:06:11 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 63 Message-ID: References: <16281.22423.26659.54130@yertle.int.kciLink.com> <200310242050.h9OKoYX22829@candle.pha.pa.us> <6.0.0.22.0.20031024194443.024306b8@pop.hotpop.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067270771 84809 216.194.193.105 (27 Oct 2003 16:06:11 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 27 Oct 2003 16:06:11 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:fkTT76x2oCjQPkLm+SLbpPB6M7E= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/675 X-Sequence-Number: 4423 >>>>> "AL" == Allen Landsidel writes: >> you need to bump some header file constant and rebuild the kernel. it >> also increases the granularity of how the buffer cache is used, so I'm >> not sure how it affects overall system. nothing like an experiment... AL> So far I've found a whole lot of questions about this, but nothing AL> about the constant. The sysctl (vfs.hibufspace I believe is the one) AL> is read only, although I should be able to work around that via AL> /boot/loader.conf if I can't find the kernel option. Here's what I have in my personal archive. I have not tried it yet. BKVASIZE is in a system header file, so is not a regular "tunable" for a kernel. That is, you must muck with the source files to change it, which make for maintenance headaches. From: Sean Chittenden Subject: Re: go for a script! / ex: PostgreSQL vs. MySQL Newsgroups: ml.postgres.performance To: Vivek Khera Cc: pgsql-performance@postgresql.org Date: Mon, 13 Oct 2003 12:04:46 -0700 Organization: none > >> echo "effective_cache_size = $((`sysctl -n vfs.hibufspace` / 8192))" > >> > >> I've used it for my dedicated servers. Is this calculation correct? > > SC> Yes, or it's real close at least. vfs.hibufspace is the amount > of SC> kernel space that's used for caching IO operations (minus the > > I'm just curious if anyone has a tip to increase the amount of > memory FreeBSD will use for the cache? Recompile your kernel with BKVASIZE set to 4 times its current value and double your nbuf size. According to Bruce Evans: "Actually there is a way: the vfs_maxbufspace gives the amount of space reserved for buffer kva (= nbuf * BKVASIZE). nbuf is easy to recover from this, and the buffer kva space may be what is wanted anyway." [snip] "I've never found setting nbuf useful, however. I want most parametrized sizes including nbuf to scale with resource sizes, and it's only with RAM sizes of similar sizes to the total virtual address size that its hard to get things to fit. I haven't hit this problem myself since my largest machine has only 1GB. I use an nbuf of something like twice the default one, and a BKVASIZE of 4 times the default. vfs.maxbufspace ends up at 445MB on the machine with 1GB, so it is maxed out now." YMMV. -sc -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 27 12:08: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 C35FCD1B564 for ; Mon, 27 Oct 2003 16:08: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 75074-06 for ; Mon, 27 Oct 2003 12:07:46 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 47BCAD1B55F for ; Mon, 27 Oct 2003 12:07:46 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 662461F92; Mon, 27 Oct 2003 11:07:45 -0500 (EST) Subject: Re: My own performance/tuning q&a From: Neil Conway To: Allen Landsidel Cc: PostgreSQL Performance In-Reply-To: <6.0.0.22.0.20031024194443.024306b8@pop.hotpop.com> References: <16281.22423.26659.54130@yertle.int.kciLink.com> <200310242050.h9OKoYX22829@candle.pha.pa.us> <6.0.0.22.0.20031024194443.024306b8@pop.hotpop.com> Content-Type: text/plain Message-Id: <1067270858.460.39.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 11:07:39 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/676 X-Sequence-Number: 4424 On Fri, 2003-10-24 at 20:11, Allen Landsidel wrote: > However, I do the same thing with the reindex, so I'll definitely be taking > it out there, as that one does lock.. although I would think the worst this > would do would be a making the index unavailable and forcing a seq scan.. > is that not the case? No, it exclusively locks the table. It has been mentioned before that we should probably be able to fall back to a seqscan while the REINDEX is going on, but that's not currently done. -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 12:13: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 ACDBBD1B536 for ; Mon, 27 Oct 2003 16:13: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 74785-06 for ; Mon, 27 Oct 2003 12:12:39 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id F36B4D1B522 for ; Mon, 27 Oct 2003 12:12:38 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 721313E29 for ; Mon, 27 Oct 2003 11:12:38 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 44091-03 for ; Mon, 27 Oct 2003 11:12:38 -0500 (EST) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id E79363E24 for ; Mon, 27 Oct 2003 11:12:37 -0500 (EST) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9RGCbOP088426 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 11:12:37 -0500 (EST) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Various performance questions Date: Mon, 27 Oct 2003 11:12:37 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 16 Message-ID: References: <20031026194449.GD2979@rlx11.zapatec.com> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067271157 84809 216.194.193.105 (27 Oct 2003 16:12:37 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 27 Oct 2003 16:12:37 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:uRbWHe5kHz85lqtmQbroXx5xCd0= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/677 X-Sequence-Number: 4425 >>>>> "DM" == Dror Matalon writes: DM> effective_cache_size = 25520 -- freebsd forumla: vfs.hibufspace / 8192 DM> 1. While it seems to work correctly, I'm unclear on why this number is DM> correct. 25520*8 = 204160 or 200 Megs. On a machine with 2 Gigs it DM> seems like the number should be more like 1 - 1.5 Gigs. Nope, that's correct... -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Mon Oct 27 12:33: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 A6435D1B51E for ; Mon, 27 Oct 2003 16:32: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 83843-01 for ; Mon, 27 Oct 2003 12:31:36 -0400 (AST) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 3143AD1B4FE for ; Mon, 27 Oct 2003 12:31:32 -0400 (AST) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB12933 for ; Mon, 27 Oct 2003 09:31:15 -0700 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16285.17811.994000.543635@gargle.gargle.HOWL> Date: Mon, 27 Oct 2003 09:19:31 -0700 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <878ynaupgu.fsf@stark.dyndns.tv> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/679 X-Sequence-Number: 4427 Greg Stark writes: > Sorry I was unclear. By "usual case" I meant reading, as opposed to updates. > The size of the on-disk representation turns out to be a major determinant in > a lot of database applications, since the dominant resource is i/o bandwidth. > Try doing a fresh import of a large table with pctfree 0 pctuse 100 and > compare how long a select takes on it compared to the original table. BTW, I greatly appreciate your support on this stuff. This list is a fantastic resource. I think we agree. The question is what is the workload. On tables without updates, postgres will be fast enough. However, postgres is slow on tables with updates afaict. I think of OLTP as a system with updates. One can do DSS on an OLTP database with Oracle, at least it seems to work for one of our projects. > FIrstly, that type of query will be faster in 7.4 due to implementing a new > method for doing groups called hash aggregates. We'll be trying it as soon as it is out. > Secondly you could try raising sort_mem. Postgres can't know how much memory > it really has before it swaps, so there's a parameter to tell it. And swapping > would be much worse than doing disk sorts. It is at 8000. This is probably as high as I can go with multiple postmasters. The sort area is shared in Oracle (I think :-) in the UGA. > You can raise sort_mem to tell it how much memory it's allowed to > use before it goes to disk sorts. You can even use ALTER SESSION to > raise it in a few DSS sessions but leave it low the many OLTP > sessions. If it's high in OLTP sessions then you could quickly hit > swap when they all happen to decide to use the maximum amount at the > same time. But then you don't want to be doing big sorts in OLTP > sessions anyways. This is a web app. I can't control what the user wants to do. Sometimes they update data, and other times they simply look at it. I didn't find ALTER SESSION for postgres (isn't that Oracle?), so I set sort_mem in the conf file to 512000, restarted postrgres. Reran the simpler query (no name) 3 times, and it was still 27 secs. > Unfortunately there's no way to tell how much memory it thinks it's > going to use. I used to use a script to monitor the pgsql_tmp > directory in the database to watch for usage. I don't have to. The queries that run slow are hitting disk. Anything that takes a minute has to be writing to disk. > Well, first of all it doesn't really because you said to group by t2.name not > f1. You might expect it to at least optimize something like this: I put f2 in the group by, and it doesn't matter. That's the point. It's the on-disk sort before the aggregate that's killing the query. > but even then I don't think it actually is capable of using foreign keys as a > hint like that. I don't think Oracle does either actually, but I'm not sure. I'll be finding out this week. > To convince it to do the right thing you would have to do either: > > SELECT a, t2.name > FROM (SELECT avg(f1),f2 FROM t1 GROUP BY f2) AS t1 > JOIN t2 USING (f2) > > Or use a subquery: > > SELECT a, (SELECT name FROM t2 WHERE t2.f2 = t1.f2) > FROM t1 > GROUP BY f2 This doesn't solve the problem. It's the GROUP BY that is doing the wrong thing. It's grouping, then aggregating. Rob From pgsql-performance-owner@postgresql.org Mon Oct 27 12:59: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 55746D1B57D for ; Mon, 27 Oct 2003 16:40: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 84127-04 for ; Mon, 27 Oct 2003 12:39:37 -0400 (AST) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id EA819D1B53E for ; Mon, 27 Oct 2003 12:39:26 -0400 (AST) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB12936; Mon, 27 Oct 2003 09:39:26 -0700 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16285.18127.773000.825179@gargle.gargle.HOWL> Date: Mon, 27 Oct 2003 09:24:47 -0700 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <87ekx2uqle.fsf@stark.dyndns.tv> References: <16272.318.870000.93584@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <200310240817.22586.mweilguni@sime.com> <16281.41629.69000.492473@gargle.gargle.HOWL> <87ekx2uqle.fsf@stark.dyndns.tv> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/680 X-Sequence-Number: 4428 Greg Stark writes: > I don't understand why you would expect overwriting to win here. > What types of updates do you do on these tables? These are statistics that we're adjusting. I think that's pretty normal stuff. The DSS component is the avg() of these numbers on particular groups. The groups are related to foreign keys to customers and other things. > Normally I found using update on such a table was too awkward to > contemplate so I just delete all the relation records that I'm > replacing for the key I'm working with and insert new ones. This > always works out to be cleaner code. In fact I usually leave such > tables with no UPDATE grants on them. In accounting apps, we do this, too. It's awkward with all the relationships to update all the records in the right order. But Oracle wins on delete/insert, too, because it reuses the tuples it already has in memory, and it can reuse the same foreign key index pages, too, since the values are usually the same. The difference between Oracle and postgres seems to be optimism. postgres assumes the transaction will fail and/or that a transaction will modify lots of data that is used by other queries going on in parallel. Oracle assumes that the transaction is going to be committed, and it might as well make the changes in place. > In that situation I would have actually expected Postgres to do as well as or > better than Oracle since that makes them both functionally > equivalent. I'll find out soon enough. :-) Rob From pgsql-performance-owner@postgresql.org Mon Oct 27 12:28: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 7E959D1B564 for ; Mon, 27 Oct 2003 16: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 83121-03 for ; Mon, 27 Oct 2003 12:27:52 -0400 (AST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by svr1.postgresql.org (Postfix) with ESMTP id 4003FD1B522 for ; Mon, 27 Oct 2003 12:27:51 -0400 (AST) Received: from pestilence.mobilecohesion.com ([10.12.10.31] helo=pestilence) by mailserv.mobilecohesion.com with esmtp (Exim 4.10) id 1AEADc-0000ZK-00 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 16:27:48 +0000 Content-Type: text/plain; charset="us-ascii" From: Damien Dougan Organization: Mobile Cohesion To: pgsql-performance@postgresql.org Subject: Very Poor Insert Performance Date: Mon, 27 Oct 2003 16:26:52 +0000 User-Agent: KMail/1.4.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310271626.52839.damien.dougan@mobilecohesion.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/678 X-Sequence-Number: 4426 Hi All, We've been experiencing extremely poor batch upload performance on our=20 Postgres 7.3 (and 7.3.4) database, and I've not been able to improve matter= s=20 significantly using any suggestions I've gleamed off the mailing list=20 archives ... so I was wondering if anyone with a bigger brain in this area= =20 could help :) Our batch upload is performing a number of stored procedures to insert data= on=20 the database. Initially, this results in quite good performance, but rapidl= y=20 spirals down to approximately 1 per second after some minutes. I've got a script that generates stored procedure calls to upload test inpu= t=20 data, and the script is capable of inserting BEGIN and END at different=20 intervals, together with VACUUM ANALYZE commands as well. I've tried varying the commit level from every operation, every 5, every 10= ,=20 every 25, every 100 operations (again, each operation is 5 SP calls) withou= t=20 any noticeable improvement. Likewise, I've varied the VACUUM ANALYZE from= =20 every 50 to every 100 operations - again without any measurable improvement. top reports that CPU usage is pretty constant at 99%, and there is=20 approximately 1GB of free physical memory available to the OS (with=20 approximately 1GB of physical memory in use). I've have been running postmaster with switched fsync off. I also tried running with backbuffers of default (64), 128, 256, 512 and ev= en=20 1024. Again, with no measurable change. The typical metrics are (completed operations - each of these require 5 SP= =20 calls): 1 min: 1036 (1036 operations) 2 min: 1426 (390 operations) 3 min: 1756 (330 operations) 4 min: 2026 (270 operations) 5 min: 2266 (240 operations) When left running, its not too long before the code snails to 1 operation p= er=20 second. Has anyone any ideas as to what could be causing the spiraling performance? With approximately 20,000 operations commited in the database, it takes abo= ut=20 1 minute to upload a dump of the database - unfortunately we cannot use the= =20 COPY command to upload brand new data - it really has to go through the=20 Stored Procedures to ensure relationships and data integrity across the=20 schema (it would be very difficult to develop and maintain code to generate= =20 COPY commands for inserting new data). And whilst I appreciate INSERTs are= =20 inherently slower than COPY, I was hoping for something significantly faste= r=20 than the 1 operation/second that things fairly quickly descend to... Thanks for any advice! Damien From pgsql-performance-owner@postgresql.org Mon Oct 27 13:17: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 0870BD1B50A for ; Mon, 27 Oct 2003 17:17: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 90214-06 for ; Mon, 27 Oct 2003 13:17:10 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id CA9E5D1B8A3 for ; Mon, 27 Oct 2003 13:17: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 h9RHH9it000401; Mon, 27 Oct 2003 12:17:09 -0500 (EST) To: Rob Messer Cc: pgsql-performance@postgresql.org Subject: Re: Use of multipart index with "IN" In-reply-to: <20031023181831.40095.qmail@web41215.mail.yahoo.com> References: <20031023181831.40095.qmail@web41215.mail.yahoo.com> Comments: In-reply-to Rob Messer message dated "Thu, 23 Oct 2003 11:18:31 -0700" Date: Mon, 27 Oct 2003 12:17:09 -0500 Message-ID: <400.1067275029@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/681 X-Sequence-Number: 4429 Rob Messer writes: > The problem comes in when we are selecting multiple field_name values > in one query. The normal SQL syntax we have been using is like this: > select field_name, option_tag from ds_rec_fld where recid = 3001 and > field_name in ('Q3A1', 'Q3A9'); You'd have better luck if field_name were the first column of the two-column index. See the archives. Improving this situation is on the to-do list but it seems not trivial to fix. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 27 13:23: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 B3315D1B515 for ; Mon, 27 Oct 2003 17:23: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 90949-08 for ; Mon, 27 Oct 2003 13:23:19 -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 CFA69D1B4EB for ; Mon, 27 Oct 2003 13:23:18 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id C2E02A941 for ; Mon, 27 Oct 2003 09:23:10 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9RHNAJZ068563 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 09:23:10 -0800 (PST) (envelope-from dror) Date: Mon, 27 Oct 2003 09:23:10 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Various performance questions Message-ID: <20031027172310.GI2979@rlx11.zapatec.com> References: <20031026194449.GD2979@rlx11.zapatec.com> 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: 200310/682 X-Sequence-Number: 4430 On Mon, Oct 27, 2003 at 11:12:37AM -0500, Vivek Khera wrote: > >>>>> "DM" == Dror Matalon writes: > > DM> effective_cache_size = 25520 -- freebsd forumla: vfs.hibufspace / 8192 > > DM> 1. While it seems to work correctly, I'm unclear on why this number is > DM> correct. 25520*8 = 204160 or 200 Megs. On a machine with 2 Gigs it > DM> seems like the number should be more like 1 - 1.5 Gigs. > > Nope, that's correct... I know it's correct. I was asking why it's correct. > > > -- > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Vivek Khera, Ph.D. Khera Communications, Inc. > Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 > AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ > > ---------------------------(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 -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Mon Oct 27 13:40: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 DE0AED1B4E5 for ; Mon, 27 Oct 2003 17:40: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 94976-07 for ; Mon, 27 Oct 2003 13:40:20 -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 D54A3D1B4E8 for ; Mon, 27 Oct 2003 13:40:19 -0400 (AST) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by rlx13.zapatec.com (Postfix) with ESMTP id A71D6A941 for ; Mon, 27 Oct 2003 09:40:20 -0800 (PST) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9RHeJne068590 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 09:40:19 -0800 (PST) (envelope-from dror) Date: Mon, 27 Oct 2003 09:40:19 -0800 From: Dror Matalon To: pgsql-performance@postgresql.org Subject: Re: Various performance questions Message-ID: <20031027174019.GJ2979@rlx11.zapatec.com> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> <20031027071703.GF2979@rlx11.zapatec.com> 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: 200310/683 X-Sequence-Number: 4431 On Mon, Oct 27, 2003 at 07:52:06AM -0500, Christopher Browne wrote: > In the last exciting episode, dror@zapatec.com (Dror Matalon) wrote: > > I was answering an earlier response that suggested that maybe the actual > > counting took time so it would take quite a bit longer when there are > > more rows to count. > > Well, if a "where clause" allows the system to use an index to search > for the subset of elements, that would reduce the number of pages that > have to be examined, thereby diminishing the amount of work. > > Why don't you report what EXPLAIN ANALYZE returns as output for the > query with WHERE clause? That would allow us to get more of an idea > of what is going on... Here it is once again, and I've added another data poing "channel < 1000" which takes even less time than channel < 5000. It almost seems like the optimizer knows that it can skip certain rows "rows=4910762" vs "rows=1505605" . But how can it do that without using an index or actually looking at each row? zp1936=> EXPLAIN ANALYZE select count(*) from items; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=245044.53..245044.53 rows=1 width=0) (actual time=55806.893..55806.897 rows=1 loops=1) -> Seq Scan on items (cost=0.00..232767.62 rows=4910762 width=0) (actual time=0.058..30481.482 rows=4910762 loops=1) Total runtime: 55806.992 ms (3 rows) zp1936=> EXPLAIN ANALYZE select count(*) from items where channel < 5000; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=248808.54..248808.54 rows=1 width=0) (actual time=26071.264..26071.269 rows=1 loops=1) -> Seq Scan on items (cost=0.00..245044.52 rows=1505605 width=0) (actual time=0.161..17623.033 rows=1632057 loops=1) Filter: (channel < 5000) Total runtime: 26071.361 ms (4 rows) zp1936=> EXPLAIN ANALYZE select count(*) from items where channel < 1000; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- Aggregate (cost=245429.74..245429.74 rows=1 width=0) (actual time=10225.272..10225.276 rows=1 loops=1) -> Seq Scan on items (cost=0.00..245044.52 rows=154085 width=0) (actual time=7.633..10083.246 rows=25687 loops=1) Filter: (channel < 1000) Total runtime: 10225.373 ms (4 rows) > -- > (format nil "~S@~S" "cbbrowne" "acm.org") > http://www3.sympatico.ca/cbbrowne/spiritual.html > When replying, it is often possible to cleverly edit the original > message in such a way as to subtly alter its meaning or tone to your > advantage while appearing that you are taking pains to preserve the > author's intent. As a bonus, it will seem that your superior > intellect is cutting through all the excess verbiage to the very heart > of the matter. -- from the Symbolics Guidelines for Sending Mail > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com From pgsql-performance-owner@postgresql.org Mon Oct 27 13:54: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 AEC60D1B4E8 for ; Mon, 27 Oct 2003 17:54: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 95644-07 for ; Mon, 27 Oct 2003 13:53:57 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id C6D6DD1B515 for ; Mon, 27 Oct 2003 13:53:56 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 78C5E369EE; Mon, 27 Oct 2003 12:53:56 -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 1AEBYy-0005Hr-00; Mon, 27 Oct 2003 12:53:56 -0500 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> <16285.17811.994000.543635@gargle.gargle.HOWL> In-Reply-To: <16285.17811.994000.543635@gargle.gargle.HOWL> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 12:53:56 -0500 Message-ID: <87d6ciy3bf.fsf@stark.dyndns.tv> Lines: 42 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: 200310/684 X-Sequence-Number: 4432 Rob Nagler writes: > I didn't find ALTER SESSION for postgres (isn't that Oracle?), so I > set sort_mem in the conf file to 512000, restarted postrgres. Reran > the simpler query (no name) 3 times, and it was still 27 secs. Sorry, I don't know how that bubbled up from the depths of my Oracle memory. In postgres it's just "SET" db=> set sort_mem = 512000; SET > > To convince it to do the right thing you would have to do either: > > > > SELECT a, t2.name > > FROM (SELECT avg(f1),f2 FROM t1 GROUP BY f2) AS t1 > > JOIN t2 USING (f2) > > > > Or use a subquery: > > > > SELECT a, (SELECT name FROM t2 WHERE t2.f2 = t1.f2) > > FROM t1 > > GROUP BY f2 > > This doesn't solve the problem. It's the GROUP BY that is doing the > wrong thing. It's grouping, then aggregating. But at least in the form above it will consider using an index on f2, and it will consider using indexes on t1 and t2 to do the join. It's unlikely to go ahead and use the indexes though because normally sorting is faster than using the index when scanning the whole table. You should compare the "explain analyze" results for the original query and these two. And check the results with "set enable_seqscan = off" as well. I suspect you'll find your original query uses sequential scans even when they're disabled because it has no alternative. With the two above it can use indexes but I suspect you'll find they actually take longer than the sequential scan and sort -- especially if you have sort_mem set large enough. -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 13:57: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 F2CEAD1B4F4 for ; Mon, 27 Oct 2003 17:57: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 96468-04 for ; Mon, 27 Oct 2003 13:56:45 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id F191FD1B515 for ; Mon, 27 Oct 2003 13:56:44 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 33A4236929; Mon, 27 Oct 2003 12:56:45 -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 1AEBbh-0005IK-00; Mon, 27 Oct 2003 12:56:45 -0500 To: Neil Conway Cc: Greg Stark , Dror Matalon , PostgreSQL Performance Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> In-Reply-To: <1067269309.459.33.camel@tokyo> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 12:56:44 -0500 Message-ID: <877k2qy36r.fsf@stark.dyndns.tv> Lines: 18 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: 200310/685 X-Sequence-Number: 4433 Neil Conway writes: > On Sun, 2003-10-26 at 22:49, Greg Stark wrote: > > What version of postgres is this?. In 7.4 (and maybe 7.3?) count() uses an > > int8 to store its count so it's not limited to 4 billion records. > > Unfortunately int8 is somewhat inefficient as it has to be dynamically > > allocated repeatedly. > > Uh, what? Why would an int8 need to be "dynamically allocated > repeatedly"? Perhaps I'm wrong, I'm extrapolating from a comment Tom Lane made that profiling showed that the bulk of the cost in count() went to allocating int8s. He commented that this could be optimized by having count() and sum() bypass the regular api. I don't have the original message handy. -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 14:01: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 15B18D1B4EF for ; Mon, 27 Oct 2003 18:01: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 96060-08 for ; Mon, 27 Oct 2003 14:01:13 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 715DCD1B515 for ; Mon, 27 Oct 2003 14:01:12 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 835B8369CE; Mon, 27 Oct 2003 13:01:12 -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 1AEBg0-0005Ij-00; Mon, 27 Oct 2003 13:01:12 -0500 To: Damien Dougan Cc: pgsql-performance@postgresql.org Subject: Re: Very Poor Insert Performance References: <200310271626.52839.damien.dougan@mobilecohesion.com> In-Reply-To: <200310271626.52839.damien.dougan@mobilecohesion.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 13:01:12 -0500 Message-ID: <871xsyy2zb.fsf@stark.dyndns.tv> Lines: 16 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: 200310/686 X-Sequence-Number: 4434 Damien Dougan writes: > Our batch upload is performing a number of stored procedures to insert data on > the database. Initially, this results in quite good performance, but rapidly > spirals down to approximately 1 per second after some minutes. It's fairly unlikely anyone will be able to help without you saying what you're doing. What are these procedures doing? What do the tables look like? What indexes exist? At a guess the foreign key relationships you're enforcing don't have indexes to help them. If they do perhaps postgres isn't using them. -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 14:40: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 29788D1B520 for ; Mon, 27 Oct 2003 18:40: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 06577-01 for ; Mon, 27 Oct 2003 14:40:10 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id C8B7CD1B4E1 for ; Mon, 27 Oct 2003 14:40:09 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 037F31F5D; Mon, 27 Oct 2003 13:40:10 -0500 (EST) Subject: Re: Various performance questions From: Neil Conway To: Greg Stark , Tom Lane Cc: Dror Matalon , PostgreSQL Performance In-Reply-To: <877k2qy36r.fsf@stark.dyndns.tv> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> Content-Type: text/plain Message-Id: <1067280005.463.48.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 13:40:06 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/687 X-Sequence-Number: 4435 On Mon, 2003-10-27 at 12:56, Greg Stark wrote: > Neil Conway writes: > > Uh, what? Why would an int8 need to be "dynamically allocated > > repeatedly"? > > Perhaps I'm wrong, I'm extrapolating from a comment Tom Lane made that > profiling showed that the bulk of the cost in count() went to allocating > int8s. He commented that this could be optimized by having count() and sum() > bypass the regular api. I don't have the original message handy. I'm still confused: int64 should be stack-allocated, AFAICS. Tom, do you recall what the issue here is? -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 14: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 50570D1B566 for ; Mon, 27 Oct 2003 18:53: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 06577-08 for ; Mon, 27 Oct 2003 14:52:52 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 8D37DD1B910 for ; Mon, 27 Oct 2003 14:52:12 -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 h9RIqDit001736; Mon, 27 Oct 2003 13:52:13 -0500 (EST) To: Neil Conway Cc: Greg Stark , Dror Matalon , PostgreSQL Performance Subject: Re: Various performance questions In-reply-to: <1067280005.463.48.camel@tokyo> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> <1067280005.463.48.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Mon, 27 Oct 2003 13:40:06 -0500" Date: Mon, 27 Oct 2003 13:52:12 -0500 Message-ID: <1735.1067280732@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/688 X-Sequence-Number: 4436 Neil Conway writes: > On Mon, 2003-10-27 at 12:56, Greg Stark wrote: >> Neil Conway writes: >>> Uh, what? Why would an int8 need to be "dynamically allocated >>> repeatedly"? >> >> Perhaps I'm wrong, I'm extrapolating from a comment Tom Lane made that >> profiling showed that the bulk of the cost in count() went to allocating >> int8s. He commented that this could be optimized by having count() and sum() >> bypass the regular api. I don't have the original message handy. > I'm still confused: int64 should be stack-allocated, AFAICS. Tom, do you > recall what the issue here is? Greg is correct. int8 is a pass-by-reference datatype and so every aggregate state-transition function cycle requires at least one palloc (to return the function result). I think in the current state of the code it requires two pallocs :-(, because we can't trust the transition function to palloc its result in the right context without palloc'ing leaked junk in that context, so an extra palloc is needed to copy the result Datum into a longer-lived context than we call the function in. There was some speculation a few weeks ago about devising a way to let performance-critical transition functions avoid the excess palloc's by working with a specialized API instead of the standard function call API, but I think it'll have to wait for 7.5. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 27 14:55: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 5FB93D1B564 for ; Mon, 27 Oct 2003 18:55: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 07775-05 for ; Mon, 27 Oct 2003 14:54:54 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id AFC8BD1B545 for ; Mon, 27 Oct 2003 14:54:53 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 0A4811F22; Mon, 27 Oct 2003 13:54:54 -0500 (EST) Subject: Re: Various performance questions From: Neil Conway To: Tom Lane Cc: Greg Stark , Dror Matalon , PostgreSQL Performance In-Reply-To: <1735.1067280732@sss.pgh.pa.us> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> <1067280005.463.48.camel@tokyo> <1735.1067280732@sss.pgh.pa.us> Content-Type: text/plain Message-Id: <1067280889.460.67.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 27 Oct 2003 13:54:50 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/689 X-Sequence-Number: 4437 On Mon, 2003-10-27 at 13:52, Tom Lane wrote: > Greg is correct. int8 is a pass-by-reference datatype and so every > aggregate state-transition function cycle requires at least one palloc > (to return the function result). Interesting. Is there a reason why int8 is pass-by-reference? (ISTM that pass-by-value would be sufficient...) Thanks for the information, Tom & Greg. -Neil From pgsql-performance-owner@postgresql.org Mon Oct 27 15:10: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 87B8DD1B533 for ; Mon, 27 Oct 2003 19:10: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 07838-07 for ; Mon, 27 Oct 2003 15:09:51 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id E4F23D1B559 for ; Mon, 27 Oct 2003 15:09: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 h9RJ9mit001990; Mon, 27 Oct 2003 14:09:48 -0500 (EST) To: Neil Conway Cc: Greg Stark , Dror Matalon , PostgreSQL Performance Subject: Re: Various performance questions In-reply-to: <1067280889.460.67.camel@tokyo> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> <1067280005.463.48.camel@tokyo> <1735.1067280732@sss.pgh.pa.us> <1067280889.460.67.camel@tokyo> Comments: In-reply-to Neil Conway message dated "Mon, 27 Oct 2003 13:54:50 -0500" Date: Mon, 27 Oct 2003 14:09:48 -0500 Message-ID: <1989.1067281788@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/690 X-Sequence-Number: 4438 Neil Conway writes: > Interesting. Is there a reason why int8 is pass-by-reference? Pass-by-value types have to fit into Datum. On a 64-bit machine (ie, one where pointers are 64-bits anyway) it would make sense to convert int8 (and float8 too) into pass-by-value types. If the machine does not already need Datum to be 8 bytes, though, I think that widening Datum to 8 bytes just for the benefit of these two datatypes would be a serious net loss. Not to mention that it would just plain break everything on machines with no native 8-byte-int datatype. One of the motivations for the version-1 function call protocol was to allow the pass-by-value-or-by-ref nature of these datatypes to be hidden from most of the code, with an eye to someday making this a platform-specific choice. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 27 15:10: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 4272DD1B4EB for ; Mon, 27 Oct 2003 19:10: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 08245-04 for ; Mon, 27 Oct 2003 15:10:12 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 69FCED1B56B for ; Mon, 27 Oct 2003 15:10:11 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 9EF77369CE; Mon, 27 Oct 2003 14:10:11 -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 1AECkl-0005Yi-00; Mon, 27 Oct 2003 14:10:11 -0500 To: Tom Lane Cc: Neil Conway , Greg Stark , Dror Matalon , PostgreSQL Performance Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> <1067280005.463.48.camel@tokyo> <1735.1067280732@sss.pgh.pa.us> In-Reply-To: <1735.1067280732@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 14:10:11 -0500 Message-ID: <87n0bmwl7w.fsf@stark.dyndns.tv> Lines: 18 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: 200310/691 X-Sequence-Number: 4439 Tom Lane writes: > Greg is correct. int8 is a pass-by-reference datatype Just to keep the conversation on track. the evidence from this particular post seems to indicate that my theory was wrong and the overhead for count(*) is _not_ a big time sink. It seems to be at most 10% and usually less. A simple "select 1 from tab" takes nearly as long. I'm still puzzled why the times on these are so different when the latter returns fewer records and both are doing sequential scans: select 1 from tab select 1 from tab where a < 1000 -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 15:23: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 F34D2D1B55D for ; Mon, 27 Oct 2003 19: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 15548-01 for ; Mon, 27 Oct 2003 15:23:02 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id CE493D1B533 for ; Mon, 27 Oct 2003 15:23:00 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id A102036932; Mon, 27 Oct 2003 14:23:01 -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 1AECxB-0005b1-00; Mon, 27 Oct 2003 14:23:01 -0500 To: Dror Matalon Cc: Postgresql Performance Subject: Re: Various performance questions References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <20031027045431.GE2979@rlx11.zapatec.com> In-Reply-To: <20031027045431.GE2979@rlx11.zapatec.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 27 Oct 2003 14:23:01 -0500 Message-ID: <87he1uwkmi.fsf@stark.dyndns.tv> Lines: 82 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: 200310/692 X-Sequence-Number: 4440 In fact the number of records seems to be almost irrelevant. A sequential scan takes almost exactly the same amount of time up until a critical region (for me around 100000 records) at which point it starts going up very quickly. It's almost as if it's doing some disk i/o, but I'm watching vmstat and don't see anything. And in any case it would have to read all the same blocks to do the sequential scan regardless of how many records match, no? I don't hear the disk seeking either -- though oddly there is some sound coming from the computer when this computer running. It sounds like a high pitched sound, almost like a floppy drive reading without seeking. Perhaps there is some i/o happening and linux is lying about it? Perhaps I'm not hearing seeking because it's reading everything from one track and not seeking? Very strange. slo=> explain analyze select 1::int4 from test where a < 1 ; QUERY PLAN ------------------------------------------------------------------------------------------------------ Seq Scan on test (cost=0.00..1693.00 rows=11 width=0) (actual time=417.468..417.468 rows=0 loops=1) Filter: (a < 1) Total runtime: 417.503 ms (3 rows) Time: 418.181 ms slo=> explain analyze select 1::int4 from test where a < 100 ; QUERY PLAN ----------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=53 width=0) (actual time=0.987..416.224 rows=50 loops=1) Filter: (a < 100) Total runtime: 416.301 ms (3 rows) Time: 417.008 ms slo=> explain analyze select 1::int4 from test where a < 10000 ; QUERY PLAN --------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=5283 width=0) (actual time=0.812..434.967 rows=5000 loops=1) Filter: (a < 10000) Total runtime: 439.620 ms (3 rows) Time: 440.665 ms slo=> explain analyze select 1::int4 from test where a < 100000 ; QUERY PLAN ----------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=50076 width=0) (actual time=0.889..458.623 rows=50000 loops=1) Filter: (a < 100000) Total runtime: 491.281 ms (3 rows) Time: 491.998 ms slo=> explain analyze select 1::int4 from test where a < 1000000 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------ Seq Scan on test (cost=0.00..1693.00 rows=99991 width=0) (actual time=0.018..997.421 rows=715071 loops=1) Filter: (a < 1000000) Total runtime: 1461.851 ms (3 rows) Time: 1462.898 ms slo=> explain analyze select 1::int4 from test where a < 10000000 ; QUERY PLAN ------------------------------------------------------------------------------------------------------------- Seq Scan on test (cost=0.00..1693.00 rows=99991 width=0) (actual time=0.015..1065.456 rows=800000 loops=1) Filter: (a < 10000000) Total runtime: 1587.481 ms (3 rows) -- greg From pgsql-performance-owner@postgresql.org Mon Oct 27 15:27: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 AB983D1B550 for ; Mon, 27 Oct 2003 19:26: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 15548-02 for ; Mon, 27 Oct 2003 15:26:29 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 1F875D1B4EB for ; Mon, 27 Oct 2003 15:26:07 -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 h9RJQ7it002168; Mon, 27 Oct 2003 14:26:08 -0500 (EST) To: Greg Stark Cc: Neil Conway , Dror Matalon , PostgreSQL Performance Subject: Re: Various performance questions In-reply-to: <87n0bmwl7w.fsf@stark.dyndns.tv> References: <20031026194449.GD2979@rlx11.zapatec.com> <87u15vxrue.fsf@stark.dyndns.tv> <1067269309.459.33.camel@tokyo> <877k2qy36r.fsf@stark.dyndns.tv> <1067280005.463.48.camel@tokyo> <1735.1067280732@sss.pgh.pa.us> <87n0bmwl7w.fsf@stark.dyndns.tv> Comments: In-reply-to Greg Stark message dated "27 Oct 2003 14:10:11 -0500" Date: Mon, 27 Oct 2003 14:26:07 -0500 Message-ID: <2167.1067282767@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/693 X-Sequence-Number: 4441 Greg Stark writes: > I'm still puzzled why the times on these are so different when the latter > returns fewer records and both are doing sequential scans: My best guess is that it's simply the per-tuple overhead of cycling tuples through the two plan nodes. When you have no actual I/O happening, the seqscan runtime is going to be all CPU time, something of the form cost_per_page * number_of_pages_processed + cost_per_tuple_scanned * number_of_tuples_scanned + cost_per_tuple_returned * number_of_tuples_returned I don't have numbers for the relative sizes of those three costs, but I doubt that any of them are negligible compared to the other two. Adding a WHERE clause increases cost_per_tuple_scanned but reduces the number_of_tuples_returned, and so it cuts the contribution from the third term, evidently by more than the WHERE clause adds to the second term. Ny own profiling had suggested that the cost-per-tuple-scanned in the aggregate node dominated the seqscan CPU costs, but that might be platform-specific, or possibly have something to do with the fact that I was profiling an assert-enabled build. It might be worth pointing out that EXPLAIN ANALYZE adds two kernel calls (gettimeofday or some such) into each cycle of the plan nodes; that's probably inflating the cost_per_tuple_returned by a noticeable amount. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 27 16:12: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 26B8CD1B536 for ; Mon, 27 Oct 2003 20:12: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 21976-03 for ; Mon, 27 Oct 2003 16:12:16 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 12131D1B545 for ; Mon, 27 Oct 2003 16:12: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 h9RKC8it002494; Mon, 27 Oct 2003 15:12:08 -0500 (EST) To: Damien Dougan Cc: pgsql-performance@postgresql.org Subject: Re: Very Poor Insert Performance In-reply-to: <200310271626.52839.damien.dougan@mobilecohesion.com> References: <200310271626.52839.damien.dougan@mobilecohesion.com> Comments: In-reply-to Damien Dougan message dated "Mon, 27 Oct 2003 16:26:52 +0000" Date: Mon, 27 Oct 2003 15:12:08 -0500 Message-ID: <2493.1067285528@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/694 X-Sequence-Number: 4442 Damien Dougan writes: > Has anyone any ideas as to what could be causing the spiraling performance? You really haven't provided any information that would allow anything but guesses, but I'll guess anyway: poor plans for foreign key checks? See nearby threads. regards, tom lane From pgsql-performance-owner@postgresql.org Mon Oct 27 19:35: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 7385CD1B559 for ; Mon, 27 Oct 2003 23:35: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 53119-06 for ; Mon, 27 Oct 2003 19:35:22 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 5F208D1B544 for ; Mon, 27 Oct 2003 19:35:19 -0400 (AST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3831915 for pgsql-performance@postgresql.org; Mon, 27 Oct 2003 15:35:46 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: PostgreSQL Performance Subject: Guesses on what this NestLoop is for? Date: Mon, 27 Oct 2003 15:32:41 -0800 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310271532.41974.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/695 X-Sequence-Number: 4443 Folks, I'm getting this plan on 7.2.4: ---------------------------------------------------------- explain select events.event_id, events.event_name, type_name, COALESCE(cases.case_name || '(' || cases.docket || ')',=20 trial_groups.tgroup_name) as event_case, jw_date_format(events.event_date, events.event_tz, events.duration) as=20 show_date FROM event_types, events LEFT OUTER JOIN cases ON (events.link_type =3D 'case' AND events.case_id = =3D=20 cases.case_id) LEFT OUTER JOIN trial_groups ON ( events.link_type =3D 'tg' AND events.case_id =3D trial_groups.tgroup_id ) LEFT OUTER JOIN event_history eh ON events.event_id =3D eh.event_id WHERE events.status =3D 1 or events.status =3D 11 and events.event_date > '2003-10-27' and events.etype_id =3D event_types.etype_id and ( ( events.mod_user =3D 562 AND eh.event_id IS NULL ) OR ( eh.mod_user =3D 562 and not exists (select 1 from event_history eh2 where eh2.event_id =3D eh.event_id and eh2.mod_date < eh.mod_date) ) ); Nested Loop (cost=3D100004949.08..2676373923.96 rows=3D3666858 width=3D197) -> Hash Join (cost=3D4949.08..8519.60 rows=3D43568 width=3D165) -> Hash Join (cost=3D4407.81..6615.02 rows=3D43568 width=3D149) -> Hash Join (cost=3D4403.21..6485.29 rows=3D43568 width=3D= 125) -> Seq Scan on events (cost=3D0.00..1515.70 rows=3D43= 568=20 width=3D79) -> Hash (cost=3D3108.07..3108.07 rows=3D115355 width= =3D46) -> Seq Scan on cases (cost=3D0.00..3108.07=20 rows=3D115355 width=3D46) -> Hash (cost=3D4.43..4.43 rows=3D143 width=3D24) -> Seq Scan on trial_groups (cost=3D0.00..4.43 rows= =3D143=20 width=3D24) -> Hash (cost=3D524.72..524.72 rows=3D13240 width=3D16) -> Seq Scan on event_history eh (cost=3D0.00..524.72 rows= =3D13240=20 width=3D16) -> Seq Scan on event_types (cost=3D0.00..4.32 rows=3D106 width=3D32) SubPlan -> Seq Scan on event_history eh2 (cost=3D0.00..557.82 rows=3D1 width= =3D0) ----------------------------------------------------------------- What I can't figure out is what is that inredibly expensive nested loop for= ?=20=20=20 If I could figure that out, maybe I could query around it. Unfortunately, I can't EXPLAIN ANALYZE because the present query swamps the= =20 machine, and it's a production server. Also it never completes. And yes, the system is vacuum full analyzed. Event_history is under-index= ed,=20 but the other tables are heavily indexed. Ideas? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 30 16:32: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 6E816D1B544 for ; Tue, 28 Oct 2003 06:11: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 20711-05 for ; Tue, 28 Oct 2003 02:11:25 -0400 (AST) Received: from mail.networkprograms.com (unknown [203.190.139.254]) by svr1.postgresql.org (Postfix) with ESMTP id 983BFD1B50D for ; Tue, 28 Oct 2003 02:11:22 -0400 (AST) Received: from KAMALR ([192.9.203.78]) by mail.networkprograms.com (8.12.9/8.12.9) with SMTP id h9S6AeqG031041 for ; Tue, 28 Oct 2003 11:40:40 +0530 Message-ID: <008201c39d1a$e2064c80$4ecb09c0@KAMALR> Reply-To: "Kamalraj Singh Madhan" From: "Kamalraj Singh Madhan" To: Subject: Optimizing Performance Date: Tue, 28 Oct 2003 11:45:28 +0530 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Scanned-By: MIMEDefang 2.35 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: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline X-Archive-Number: 200310/775 X-Sequence-Number: 4523 Hi, I'am having major performance issues with post gre 7.3.1 db. Kindly s= uggest all the possible means by which i can optimize the performance of th= is database. If not all, some ideas (even if they are common) are also welc= ome. There is no optimisation done to the default configuration of the inst= alled database. Kindly suggest.=20=20 regards Kamalraj From pgsql-performance-owner@postgresql.org Tue Oct 28 02:22: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 5D6FED1B52F for ; Tue, 28 Oct 2003 06:22: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 20613-10 for ; Tue, 28 Oct 2003 02:21:40 -0400 (AST) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id 663E6D1B50D for ; Tue, 28 Oct 2003 02:21:39 -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.43 $ on Novell NetWare via secured & encrypted transport (TLS); Mon, 27 Oct 2003 23:21:33 -0700 Message-ID: <3F9E0AE9.7070302@myrealbox.com> Date: Tue, 28 Oct 2003 11:51:29 +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: Kamalraj Singh Madhan Cc: pgsql-performance@postgresql.org Subject: Re: Optimizing Performance References: <00c601c39d1b$ca129880$4ecb09c0@KAMALR> In-Reply-To: <00c601c39d1b$ca129880$4ecb09c0@KAMALR> 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: 200310/697 X-Sequence-Number: 4445 Kamalraj Singh Madhan wrote: > Hi, > I'am having major performance issues with post gre 7.3.1 db. Kindly suggest all the possible means by which i can optimize the performance of this database. If not all, some ideas (even if they are common) are also welcome. There is no optimisation done to the default configuration of the installed database. Kindly suggest. Check http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html Shridhar From pgsql-performance-owner@postgresql.org Tue Oct 28 02:18: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 08676D1B50D for ; Tue, 28 Oct 2003 06:18: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 27365-04 for ; Tue, 28 Oct 2003 02:17:57 -0400 (AST) Received: from mail.networkprograms.com (unknown [203.190.139.254]) by svr1.postgresql.org (Postfix) with ESMTP id 4B1B5D1B514 for ; Tue, 28 Oct 2003 02:17:54 -0400 (AST) Received: from KAMALR ([192.9.203.78]) by mail.networkprograms.com (8.12.9/8.12.9) with SMTP id h9S6H9qG031723 for ; Tue, 28 Oct 2003 11:47:09 +0530 Message-ID: <00c601c39d1b$ca129880$4ecb09c0@KAMALR> Reply-To: "Kamalraj Singh Madhan" From: "Kamalraj Singh Madhan" To: Subject: Optimizing Performance Date: Tue, 28 Oct 2003 11:51:57 +0530 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Scanned-By: MIMEDefang 2.35 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: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline X-Archive-Number: 200310/696 X-Sequence-Number: 4444 Hi, I'am having major performance issues with post gre 7.3.1 db. Kindly s= uggest all the possible means by which i can optimize the performance of th= is database. If not all, some ideas (even if they are common) are also welc= ome. There is no optimisation done to the default configuration of the inst= alled database. Kindly suggest.=20=20 regards Kamalraj From pgsql-performance-owner@postgresql.org Tue Oct 28 07:03: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 73074D1B4F9 for ; Tue, 28 Oct 2003 11:03: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 63878-07 for ; Tue, 28 Oct 2003 07:02:53 -0400 (AST) Received: from email01.aon.at (WARSL402PIP8.highway.telekom.at [195.3.96.97]) by svr1.postgresql.org (Postfix) with SMTP id AE774D1B4FE for ; Tue, 28 Oct 2003 07:02:49 -0400 (AST) Received: (qmail 25918 invoked from network); 28 Oct 2003 11:01:23 -0000 Received: from m154p012.dipool.highway.telekom.at (HELO cantor) ([62.46.9.44]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 28 Oct 2003 11:01:23 -0000 From: Manfred Koizar To: josh@agliodbs.com Cc: PostgreSQL Performance Subject: Re: Guesses on what this NestLoop is for? Date: Tue, 28 Oct 2003 11:59:36 +0100 Message-ID: <3nhspvkbsarcieub1neodds7pr9h6hbtna@email.aon.at> References: <200310271532.41974.josh@agliodbs.com> In-Reply-To: <200310271532.41974.josh@agliodbs.com> 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: 200310/698 X-Sequence-Number: 4446 On Mon, 27 Oct 2003 15:32:41 -0800, Josh Berkus wrote: >FROM event_types, events > LEFT OUTER JOIN ... >WHERE events.status = 1 or events.status = 11 > and events.event_date > '2003-10-27' > and events.etype_id = event_types.etype_id > and ( ... > ); > > >What I can't figure out is what is that inredibly expensive nested loop for? Sorry, I have no answer to your question, but may I ask whether you really want to get presumably 106 output rows for each event with status 1? Or did you mean WHERE (events.status = 1 OR events.status = 11) AND ... >Ideas? I'd also try to push that NOT EXISTS condition into the FROM clause: ...LEFT JOIN (SELECT DISTINCT ON (event_id) event_id, mod_date, mod_user FROM event_history ORDER BY event_id, mod_date ) AS eh ON (events.event_id = eh.event_id) ... WHERE ... AND CASE WHEN eh.event_id IS NULL THEN events.mod_user ELSE eh.mod_user END = 562 If mod_user is NOT NULL in event_history, then CASE ... END can be simplified to COALESCE(eh.mod_user, events.mod_user). Servus Manfred From pgsql-performance-owner@postgresql.org Tue Oct 28 10:05: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 2E9FDD1B4F4 for ; Tue, 28 Oct 2003 14:05: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 94296-02 for ; Tue, 28 Oct 2003 10:05:20 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id B7C95D1B529 for ; Tue, 28 Oct 2003 10:05:15 -0400 (AST) Received: (qmail 26026 invoked from network); 28 Oct 2003 14:07:07 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 28 Oct 2003 14:07:07 -0000 Date: Tue, 28 Oct 2003 09:05:15 -0500 From: Jeff To: pgsql-performance@postgresql.org Subject: More info in explain analyze Message-Id: <20031028090515.278c8342.threshar@torgo.978.org> 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: 200310/699 X-Sequence-Number: 4447 This has probably been asked before, but I'll re-ask to spark debate on it again. Is there any good reason to not have explain analyze also include information if temporary files will be required on sorts, hashes, etc. during the processing of a query. [Idea being setting your sort_mem won't be purely anecdotal]... maybe include how much space it needed in temp files? something along the lines of: Sort (Cost=1..10) (Actual=1..1000) (Temp Files=5MB) Seeing that and looking at your current sort_mem and seeing it is 4MB you'll have the info you need to get a nice boost by avoiding that spill at a low cost. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 28 10:17: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 B04C9D1B568 for ; Tue, 28 Oct 2003 14:17: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 00849-03 for ; Tue, 28 Oct 2003 10:16:49 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 55E59D1B54B for ; Tue, 28 Oct 2003 10:16:45 -0400 (AST) Received: (qmail 26233 invoked from network); 28 Oct 2003 14:18:37 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 28 Oct 2003 14:18:37 -0000 Date: Tue, 28 Oct 2003 09:16:45 -0500 From: Jeff To: pgsql-performance@postgresql.org Subject: Adding foreign key performance Message-Id: <20031028091645.3d610841.threshar@torgo.978.org> 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: 200310/700 X-Sequence-Number: 4448 I recalled seeing a thread on -HACKERS about some major improvements to the speed of adding an FK to an existing table in 7.4. Naturally I was curious and decided to give it a whirl. My findings are not too good. In fact, they are bad. Could it be this patch never made it in? Anyway, here's the info. Machine: Linux 2.4.18 [stock rh8], p3 500, 512mb, 4x18GB scsi raid 0 Two tables: members and watchedmembers with 1045720 and 829994 rows respectivly. freshly vacuum analyze'd for each PG: 7.4b4, 10k shared buff, 256mb effective cache: 485706ms 7.3.4 [same settings]: 412304.76 ms Now the odd thing during that operation was that the machine was about oh, 50-70% _idle_ during the whole time. Then I started thinking more about it and realized hearing if you bump sort_mem up ridiculously high during a foreign key add it helps. So I did. Bumped it up to 256MB. [again, vacuum analyze'd each beforehand] 7.3.4: 328912ms [cpu pegged] 7.4b4: 298383ms [cpu pegged] Quite an improvement I'd say. Perhaps we should make note of this somewhere? Performance guide? Docs? And this leads to the place we'd get a huge benefit: Restoring backups.. If there were some way to bump up sort_mem while doing the restore.. things would be much more pleasant. [Although, even better would be to disable FK stuff while restoring a backup and assume the backup is "sane"] How we'd go about doing that is the subject of much debate. Perhaps add the functionality to pg_restore? ie, pg_restore -s 256MB mybackup.db? It would just end up issuing a set sort_mem=256000.. What do you guys think? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 28 11:22: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 F0796D1B514 for ; Tue, 28 Oct 2003 15:22: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 12467-01 for ; Tue, 28 Oct 2003 11:21:54 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 422BDD1B56B for ; Tue, 28 Oct 2003 11:21:50 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B9C6C352DD; Tue, 28 Oct 2003 07:21:51 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id B8B1B3529D; Tue, 28 Oct 2003 07:21:51 -0800 (PST) Date: Tue, 28 Oct 2003 07:21:51 -0800 (PST) From: Stephan Szabo To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance In-Reply-To: <20031028091645.3d610841.threshar@torgo.978.org> Message-ID: <20031028072112.X60098@megazone.bigpanda.com> References: <20031028091645.3d610841.threshar@torgo.978.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/701 X-Sequence-Number: 4449 On Tue, 28 Oct 2003, Jeff wrote: > I recalled seeing a thread on -HACKERS about some major improvements to > the speed of adding an FK to an existing table in 7.4. Naturally I was > curious and decided to give it a whirl. My findings are not too good. In > fact, they are bad. > > Could it be this patch never made it in? I think it went in between b4 and b5, can you try with b5? From pgsql-performance-owner@postgresql.org Tue Oct 28 11: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 5133ED1B4E1 for ; Tue, 28 Oct 2003 15:51: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 14659-03 for ; Tue, 28 Oct 2003 11:51:32 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 2E7CFD1B529 for ; Tue, 28 Oct 2003 11:51:28 -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 h9SFpWit022515; Tue, 28 Oct 2003 10:51:32 -0500 (EST) To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance In-reply-to: <20031028091645.3d610841.threshar@torgo.978.org> References: <20031028091645.3d610841.threshar@torgo.978.org> Comments: In-reply-to Jeff message dated "Tue, 28 Oct 2003 09:16:45 -0500" Date: Tue, 28 Oct 2003 10:51:32 -0500 Message-ID: <22514.1067356292@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/702 X-Sequence-Number: 4450 Jeff writes: > I recalled seeing a thread on -HACKERS about some major improvements to the speed of adding an FK to an existing table in 7.4. Naturally I was curious and decided to give it a whirl. My findings are not too good. In fact, they are bad. > 7.4b4, 10k shared buff, 256mb effective cache: 485706ms You are testing the wrong version. beta5 has the ADD FOREIGN KEY improvement. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Oct 28 12:15: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 A4508D1B561 for ; Tue, 28 Oct 2003 16:15: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 15365-07 for ; Tue, 28 Oct 2003 12:15:21 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id D5D4ED1B568 for ; Tue, 28 Oct 2003 12:15: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 h9SGFINu088408 for ; Tue, 28 Oct 2003 16:15:18 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9SGA2I8087542 for pgsql-performance@postgresql.org; Tue, 28 Oct 2003 16:10:02 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Optimizing Performance Date: Tue, 28 Oct 2003 10:59:37 -0500 Organization: Hub.Org Networking Services Lines: 22 Message-ID: <60he1t8iae.fsf@dev6.int.libertyrms.info> References: <00c601c39d1b$ca129880$4ecb09c0@KAMALR> 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:tNOXkL8zkkTqXnkF/ugiARVSKII= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/703 X-Sequence-Number: 4451 kamalr@networkprograms.com ("Kamalraj Singh Madhan") writes: > Hi, I'am having major performance issues with post gre 7.3.1 > db. Kindly suggest all the possible means by which i can optimize > the performance of this database. If not all, some ideas (even if > they are common) are also welcome. There is no optimisation done to > the default configuration of the installed database. Kindly suggest. The best single document I am aware of on tuning the database may be found here: That may help with some of your problems, but there can be no guarantees. What ultimately must happen is for you to discover what are the bottlenecks on your system and addressing them. That involves a process of exploration, as opposed to one of doing some unambiguous "best practices." -- select 'cbbrowne' || '@' || 'libertyrms.info'; Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Tue Oct 28 12:34: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 D70D0D1B561 for ; Tue, 28 Oct 2003 16:34: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 23828-01 for ; Tue, 28 Oct 2003 12:34:12 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id AB90ED1B56B for ; Tue, 28 Oct 2003 12:34:10 -0400 (AST) Received: (qmail 28458 invoked from network); 28 Oct 2003 16:35:53 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 28 Oct 2003 16:35:53 -0000 Date: Tue, 28 Oct 2003 11:33:59 -0500 From: Jeff To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance Message-Id: <20031028113359.3932438f.threshar@torgo.978.org> In-Reply-To: <20031028091645.3d610841.threshar@torgo.978.org> References: <20031028091645.3d610841.threshar@torgo.978.org> 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: 200310/704 X-Sequence-Number: 4452 On Tue, 28 Oct 2003 09:16:45 -0500 Jeff wrote: > 7.3.4: 328912ms [cpu pegged] > 7.4b4: 298383ms [cpu pegged] > Just loaded up delicious 7.4b5 and wow... sort_mem 8192: 137038ms [lots of tmp file activity] sort_mem 256000: 83109ms That's some good work there Lou, You'll make sargent for that someday. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 28 13:37: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 D4866D1B503 for ; Tue, 28 Oct 2003 17:37: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 32830-06 for ; Tue, 28 Oct 2003 13:36:38 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 7C4B6D1B559 for ; Tue, 28 Oct 2003 13:36:37 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3834932; Tue, 28 Oct 2003 09:36:54 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Manfred Koizar Subject: Re: Guesses on what this NestLoop is for? Date: Tue, 28 Oct 2003 09:36:02 -0800 User-Agent: KMail/1.4.3 Cc: PostgreSQL Performance References: <200310271532.41974.josh@agliodbs.com> <3nhspvkbsarcieub1neodds7pr9h6hbtna@email.aon.at> In-Reply-To: <3nhspvkbsarcieub1neodds7pr9h6hbtna@email.aon.at> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310280936.02167.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/705 X-Sequence-Number: 4453 Manfred, > Sorry, I have no answer to your question, but may I ask whether you > really want to get presumably 106 output rows for each event with > status 1? > > Or did you mean > WHERE (events.status = 1 OR events.status = 11) AND ... Thanks! I spent so much time tinkering around with the exists clauses, I completely missed that. Hopefully I'll get this client to upgrade to 7.4 so that the explains will be more readable .... -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Oct 28 14:11: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 01CD2D1B53F for ; Tue, 28 Oct 2003 18:11: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 41218-01 for ; Tue, 28 Oct 2003 14:10:37 -0400 (AST) Received: from granger.centurytel.net (granger.centurytel.net [209.142.136.117]) by svr1.postgresql.org (Postfix) with ESMTP id A83C5D1B50A for ; Tue, 28 Oct 2003 14:10:36 -0400 (AST) Received: from 192.168.1.3 (pppoe0511.grp.centurytel.net [64.91.27.4]) by granger.centurytel.net (8.12.10/8.12.10) with ESMTP id h9SIAJHj013488; Tue, 28 Oct 2003 12:10:19 -0600 (CST) From: "John K. Herreshoff" To: Stephan Szabo , Jeff Subject: Re: Adding foreign key performance Date: Tue, 28 Oct 2003 13:06:10 -0500 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: <20031028091645.3d610841.threshar@torgo.978.org> <20031028072112.X60098@megazone.bigpanda.com> In-Reply-To: <20031028072112.X60098@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310281306.10779.jkherr@centurytel.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/707 X-Sequence-Number: 4455 FWIW: I'm fiddling with that right now, and the FK think was quick... a few seconds... the tables in question have 1400 records, 343000 records and 7200 records... I'm running Beta5... John. On Tuesday 28 October 2003 10:21, Stephan Szabo wrote: > On Tue, 28 Oct 2003, Jeff wrote: > > I recalled seeing a thread on -HACKERS about some major improvements to > > the speed of adding an FK to an existing table in 7.4. Naturally I was > > curious and decided to give it a whirl. My findings are not too good. In > > fact, they are bad. > > > > Could it be this patch never made it in? > > I think it went in between b4 and b5, can you try with b5? > > > ---------------------------(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 Oct 28 14:09: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 A574CD1B52D for ; Tue, 28 Oct 2003 18:09: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 34855-07 for ; Tue, 28 Oct 2003 14:09:16 -0400 (AST) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 5BD6DD1B538 for ; Tue, 28 Oct 2003 14:09:15 -0400 (AST) Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h9SI8ao01456; Tue, 28 Oct 2003 10:08:37 -0800 Message-Id: <200310281808.h9SI8ao01456@mail.osdl.org> Date: Tue, 28 Oct 2003 10:08:33 -0800 (PST) From: markw@osdl.org Subject: Re: analyzing postgresql performance for dbt-2 To: pgman@candle.pha.pa.us Cc: pgsql-performance@postgresql.org, osdldbt-general@lists.sourceforge.net In-Reply-To: <200310260436.h9Q4a9f09899@candle.pha.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: 200310/706 X-Sequence-Number: 4454 On 26 Oct, Bruce Momjian wrote: > Mark Wong wrote: >> > > Here are a pair of results where I just raise the load on the >> > > database, where increasing the load increases the area of the database >> > > touched in addition to increasing the transaction rate. The overall >> > > metric increases somewhat, but the response time for most of the >> > > interactions also increases significantly: >> > > >> > > http://developer.osdl.org/markw/dbt2-pgsql/158/ [baseline] >> > > - load of 100 warehouses >> > > - metric 1249.65 >> > > >> > > http://developer.osdl.org/markw/dbt2-pgsql/149/ >> > > - load of 140 warehouses >> > > - metric 1323.90 >> > >> > I looked at these charts and they looked normal to me. It looked like >> > your the load increased until your computer was saturated. Is there >> > something I am missing? >> >> I've run some i/o tests so I'm pretty sure I haven't saturated that. And it >> looks like I have almost 10% more processor time left. I do agree that it >> appears something might be saturated, I just don't know where to look... > > Could the 10% be context switching time, or is the I/O saturated? There are about 14,000 to 17,000 context switches/s according to the vmstat output. This is on a 1.5Ghz hyperthreaded Xeon processor. I don't know what I'm supposed to be able to expect in terms of context switching. I really doubt the i/o is saturated because I've run disktest (part of the Linux Test Project suite) and saw much higher throughput for various sequential/random read/write tests. I'm starting to collect oprofile data (and will hopefully have some results soon) to get an idea where the database is spending its time, just in case that may have something to do with it. Mark From pgsql-performance-owner@postgresql.org Tue Oct 28 14:33: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 97539D1B53E for ; Tue, 28 Oct 2003 18:33: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 44223-02 for ; Tue, 28 Oct 2003 14:32:51 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id E092BD1B50A for ; Tue, 28 Oct 2003 14:32:50 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 31CBC352D1; Tue, 28 Oct 2003 10:32:36 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2FF6E3525B; Tue, 28 Oct 2003 10:32:36 -0800 (PST) Date: Tue, 28 Oct 2003 10:32:36 -0800 (PST) From: Stephan Szabo To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance In-Reply-To: <20031028113359.3932438f.threshar@torgo.978.org> Message-ID: <20031028101820.T64490@megazone.bigpanda.com> References: <20031028091645.3d610841.threshar@torgo.978.org> <20031028113359.3932438f.threshar@torgo.978.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/708 X-Sequence-Number: 4456 On Tue, 28 Oct 2003, Jeff wrote: > On Tue, 28 Oct 2003 09:16:45 -0500 > Jeff wrote: > > > > 7.3.4: 328912ms [cpu pegged] > > 7.4b4: 298383ms [cpu pegged] > > > > Just loaded up delicious 7.4b5 and wow... > > sort_mem 8192: 137038ms [lots of tmp file activity] > sort_mem 256000: 83109ms Hmm, 298383 -> 83109 (since those are the 256k numbers). Not as much as I'd have hoped, but I'll take a factor of 3. From pgsql-performance-owner@postgresql.org Tue Oct 28 14:35: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 CE6A6D1B56B for ; Tue, 28 Oct 2003 18:34: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 43004-07 for ; Tue, 28 Oct 2003 14:34:28 -0400 (AST) Received: from candle.pha.pa.us (unknown [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id D2307D1B54C for ; Tue, 28 Oct 2003 14:34:25 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9SIYFB25030; Tue, 28 Oct 2003 13:34:15 -0500 (EST) From: Bruce Momjian Message-Id: <200310281834.h9SIYFB25030@candle.pha.pa.us> Subject: Re: Adding foreign key performance In-Reply-To: <200310281306.10779.jkherr@centurytel.net> To: "John K. Herreshoff" Date: Tue, 28 Oct 2003 13:34:15 -0500 (EST) Cc: Stephan Szabo , Jeff , 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: 200310/709 X-Sequence-Number: 4457 John K. Herreshoff wrote: > FWIW: I'm fiddling with that right now, and the FK think was quick... a few > seconds... the tables in question have 1400 records, 343000 records and 7200 > records... I'm running Beta5... Did those tables have analyze statistics? Can you try it without statistics (I think you have to drop the tables to erase the statistics). -- 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 Oct 28 14:35: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 3BDF1D1B52D for ; Tue, 28 Oct 2003 18:35: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 44475-01 for ; Tue, 28 Oct 2003 14:34:37 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id B2004D1B568 for ; Tue, 28 Oct 2003 14:34:35 -0400 (AST) Received: (qmail 29868 invoked from network); 28 Oct 2003 18:36:26 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 28 Oct 2003 18:36:26 -0000 Date: Tue, 28 Oct 2003 13:34:31 -0500 From: Jeff To: Stephan Szabo Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance Message-Id: <20031028133431.0bf17ce4.threshar@torgo.978.org> In-Reply-To: <20031028101820.T64490@megazone.bigpanda.com> References: <20031028091645.3d610841.threshar@torgo.978.org> <20031028113359.3932438f.threshar@torgo.978.org> <20031028101820.T64490@megazone.bigpanda.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: 200310/710 X-Sequence-Number: 4458 On Tue, 28 Oct 2003 10:32:36 -0800 (PST) Stephan Szabo wrote: > Hmm, 298383 -> 83109 (since those are the 256k numbers). Not as > much as I'd have hoped, but I'll take a factor of 3. Yes. those are the numbers for 256MB of sort_mem. It seemed to saturate the IO so once I get more disks in here it should hopefully speed up. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 28 14:43: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 C6B14D1B54C for ; Tue, 28 Oct 2003 18:43: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 45075-02 for ; Tue, 28 Oct 2003 14:43:01 -0400 (AST) Received: from granger.centurytel.net (granger.centurytel.net [209.142.136.117]) by svr1.postgresql.org (Postfix) with ESMTP id 959F9D1B570 for ; Tue, 28 Oct 2003 14:43:00 -0400 (AST) Received: from 192.168.1.3 (pppoe0511.grp.centurytel.net [64.91.27.4]) by granger.centurytel.net (8.12.10/8.12.10) with ESMTP id h9SIgqHj021606; Tue, 28 Oct 2003 12:42:52 -0600 (CST) From: "John K. Herreshoff" To: Bruce Momjian Subject: Re: Adding foreign key performance Date: Tue, 28 Oct 2003 13:38:43 -0500 User-Agent: KMail/1.5 Cc: Stephan Szabo , Jeff , pgsql-performance@postgresql.org References: <200310281834.h9SIYFB25030@candle.pha.pa.us> In-Reply-To: <200310281834.h9SIYFB25030@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310281338.43414.jkherr@centurytel.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/711 X-Sequence-Number: 4459 I'm not sure about the analyze stats... Where would I find that (in postgresql.conf I suppose) I'll go see what I have set up, and get back to you in 30 minutes or less... John. On Tuesday 28 October 2003 13:34, Bruce Momjian wrote: > John K. Herreshoff wrote: > > FWIW: I'm fiddling with that right now, and the FK think was quick... a > > few seconds... the tables in question have 1400 records, 343000 records > > and 7200 records... I'm running Beta5... > > Did those tables have analyze statistics? Can you try it without > statistics (I think you have to drop the tables to erase the > statistics). From pgsql-performance-owner@postgresql.org Tue Oct 28 15:07: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 4EFE0D1B563 for ; Tue, 28 Oct 2003 19:07: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 52599-01 for ; Tue, 28 Oct 2003 15:06:50 -0400 (AST) Received: from candle.pha.pa.us (unknown [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 53880D1B53E for ; Tue, 28 Oct 2003 15:06:48 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9SIs3726853; Tue, 28 Oct 2003 13:54:03 -0500 (EST) From: Bruce Momjian Message-Id: <200310281854.h9SIs3726853@candle.pha.pa.us> Subject: Re: Adding foreign key performance In-Reply-To: <200310281338.43414.jkherr@centurytel.net> To: "John K. Herreshoff" Date: Tue, 28 Oct 2003 13:54:03 -0500 (EST) Cc: Stephan Szabo , Jeff , 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: 200310/713 X-Sequence-Number: 4461 John K. Herreshoff wrote: > I'm not sure about the analyze stats... Where would I find that (in > postgresql.conf I suppose) I'll go see what I have set up, and get back to > you in 30 minutes or less... They are in pg_statistic. If you have ever anaylzed the table, there are stats. I am interested in the non-analyze case because that's how the data will load into a fresh db via pg_dump. -- 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 Oct 28 14:58: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 5CA63D1B54C for ; Tue, 28 Oct 2003 18:58: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 44475-07 for ; Tue, 28 Oct 2003 14:57:43 -0400 (AST) Received: from omikron.sk (cepr.nustep.sk [81.0.222.49]) by svr1.postgresql.org (Postfix) with SMTP id 82478D1B545 for ; Tue, 28 Oct 2003 14:57:40 -0400 (AST) Received: (qmail 19324 invoked from network); 28 Oct 2003 18:57:24 -0000 Received: from nustep.casablanca.sk (HELO stratos) (81.0.208.19) by 0 with SMTP; 28 Oct 2003 18:57:24 -0000 Message-ID: <017201c39d85$533eed70$0200a8c0@stratos> From: "Cestmir Hybl" To: Subject: Ignoring index on (A is null), (A is not null) conditions Date: Tue, 28 Oct 2003 19:57:24 +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= X-Spam-Level: X-Archive-Number: 200310/712 X-Sequence-Number: 4460 Hi, suppose, for simplicity, there is a table with index like this: create table TABLE1 ( A integer ); create index TABLE1_A on TABLE1 (A); My question is: why psql (7.3.3) does not use index when filtering by A IS NULL, A IS NOT NULL expressions? In fact, I need to filter by expression ((A is null) or (A > const)). Is there a way to filter by this expression using index? Functional index cannot be used (except strange solution with CASE-ing and converting NULL values into some integer constant) ---------------------------------------------------------------------------- -- Index Scan using table1_a on table1 (cost=0.00..437.14 rows=29164 width=4) Index Cond: (a > 1000) ---------------------------------------------------------------------------- -- Seq Scan on table1 (cost=0.00..448.22 rows=1 width=4) Filter: (a IS NULL) -------------------------------------------------------- Seq Scan on table1 (cost=0.00..448.22 rows=30222 width=4) Filter: (a IS NOT NULL) ------------------------------------------------------------ Seq Scan on table1 (cost=0.00..523.77 rows=29164 width=4) Filter: ((a IS NULL) OR (a > 1000)) ------------------------------------------------------------ CH From pgsql-performance-owner@postgresql.org Tue Oct 28 15: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 20F06D1B54C for ; Tue, 28 Oct 2003 19:10: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 45075-10 for ; Tue, 28 Oct 2003 15:09:46 -0400 (AST) Received: from granger.centurytel.net (granger.centurytel.net [209.142.136.117]) by svr1.postgresql.org (Postfix) with ESMTP id 02BBCD1B52F for ; Tue, 28 Oct 2003 15:09:45 -0400 (AST) Received: from 192.168.1.3 (pppoe0511.grp.centurytel.net [64.91.27.4]) by granger.centurytel.net (8.12.10/8.12.10) with ESMTP id h9SJ97Hj011004; Tue, 28 Oct 2003 13:09:12 -0600 (CST) From: "John K. Herreshoff" To: Bruce Momjian Subject: Re: Adding foreign key performance Date: Tue, 28 Oct 2003 14:04:57 -0500 User-Agent: KMail/1.5 Cc: Stephan Szabo , Jeff , pgsql-performance@postgresql.org References: <200310281834.h9SIYFB25030@candle.pha.pa.us> In-Reply-To: <200310281834.h9SIYFB25030@candle.pha.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310281404.57984.jkherr@centurytel.net> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/714 X-Sequence-Number: 4462 That did not take long... about 13 minutes to reload the tables from an *.mdb file, and a second or two for each of the 'alter table foo add foreign key...' lines. I tried to drop a 'referencing' table, and the database would not let me, said that something depended on it ;o) Is there some way to name the foreign key so that it can be dropped later, or is there a way to drop the foreign key using information already in the database? John. On Tuesday 28 October 2003 13:34, Bruce Momjian wrote: > John K. Herreshoff wrote: > > FWIW: I'm fiddling with that right now, and the FK think was quick... a > > few seconds... the tables in question have 1400 records, 343000 records > > and 7200 records... I'm running Beta5... > > Did those tables have analyze statistics? Can you try it without > statistics (I think you have to drop the tables to erase the > statistics). From pgsql-performance-owner@postgresql.org Tue Oct 28 15:22: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 6AE97D1B573 for ; Tue, 28 Oct 2003 19:22: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 45248-10 for ; Tue, 28 Oct 2003 15:22:09 -0400 (AST) Received: from candle.pha.pa.us (unknown [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 77906D1B545 for ; Tue, 28 Oct 2003 15:22:07 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9SJDvN28840; Tue, 28 Oct 2003 14:13:57 -0500 (EST) From: Bruce Momjian Message-Id: <200310281913.h9SJDvN28840@candle.pha.pa.us> Subject: Re: Adding foreign key performance In-Reply-To: <200310281404.57984.jkherr@centurytel.net> To: "John K. Herreshoff" Date: Tue, 28 Oct 2003 14:13:57 -0500 (EST) Cc: Stephan Szabo , Jeff , 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: 200310/717 X-Sequence-Number: 4465 John K. Herreshoff wrote: > That did not take long... about 13 minutes to reload the tables from an *.mdb > file, and a second or two for each of the 'alter table foo add foreign > key...' lines. I tried to drop a 'referencing' table, and the database would > not let me, said that something depended on it ;o) > > Is there some way to name the foreign key so that it can be dropped later, or > is there a way to drop the foreign key using information already in the > database? You have to use ALTER TABLE DROP CONSTRAINT perhaps. -- 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 Oct 28 15:18: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 47E83D1B53E for ; Tue, 28 Oct 2003 19: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 52694-02 for ; Tue, 28 Oct 2003 15:18:03 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 72856D1B50A for ; Tue, 28 Oct 2003 15:18:02 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 68DD43E53 for ; Tue, 28 Oct 2003 14:18:03 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 18910-01-2 for ; Tue, 28 Oct 2003 14:18:03 -0500 (EST) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id E2B753E3D for ; Tue, 28 Oct 2003 14:18:02 -0500 (EST) Received: (from news@localhost) by lorax.kciLink.com (8.12.9p2/8.12.9/Submit) id h9SJI21l020938 for pgsql-performance@postgresql.org; Tue, 28 Oct 2003 14:18:02 -0500 (EST) (envelope-from news) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Very Poor Insert Performance Date: Tue, 28 Oct 2003 14:18:02 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 15 Message-ID: References: <200310271626.52839.damien.dougan@mobilecohesion.com> <871xsyy2zb.fsf@stark.dyndns.tv> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067368682 19562 216.194.193.105 (28 Oct 2003 19:18:02 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Tue, 28 Oct 2003 19:18:02 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:FhJVPMxhmciLW59CWpBolTgGu04= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/715 X-Sequence-Number: 4463 >>>>> "GS" == Greg Stark writes: GS> At a guess the foreign key relationships you're enforcing don't GS> have indexes to help them. If they do perhaps postgres isn't using GS> them. Or, if you do have indexes, they've bloated to be way too big and are overwhelming your shared buffers. Reindex them and see it it helps. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Tue Oct 28 15:22: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 977ABD1B56A for ; Tue, 28 Oct 2003 19:22: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 45775-08 for ; Tue, 28 Oct 2003 15:22:06 -0400 (AST) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id E6836D1B53E for ; Tue, 28 Oct 2003 15:22:04 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id A0D1A3E8D for ; Tue, 28 Oct 2003 14:22:05 -0500 (EST) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 17423-04-2 for ; Tue, 28 Oct 2003 14:22:05 -0500 (EST) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 1423E3E67 for ; Tue, 28 Oct 2003 14:22:05 -0500 (EST) Received: (from news@localhost) by lorax.kciLink.com (8.12.9p2/8.12.9/Submit) id h9SJM5u9031436 for pgsql-performance@postgresql.org; Tue, 28 Oct 2003 14:22:05 -0500 (EST) (envelope-from news) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Adding foreign key performance Date: Tue, 28 Oct 2003 14:22:04 -0500 Organization: Khera Communications, Inc., Rockville, MD Lines: 30 Message-ID: References: <20031028091645.3d610841.threshar@torgo.978.org> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1067368925 19562 216.194.193.105 (28 Oct 2003 19:22:05 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Tue, 28 Oct 2003 19:22:05 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:LjEPHPFQj13MAOCly5EmPnt3/vM= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/716 X-Sequence-Number: 4464 >>>>> "J" == Jeff writes: J> And this leads to the place we'd get a huge benefit: Restoring J> backups.. If there were some way to bump up sort_mem while doing J> the restore.. things would be much more pleasant. [Although, even There was a rather substantial thread on this about the time when 7.4b1 was released. J> better would be to disable FK stuff while restoring a backup and J> assume the backup is "sane"] How we'd go about doing that is the J> subject of much debate. If you're restoring from a pg_dump -Fc (compressed dump) it already happens for you. The indexes and foreign keys are not added until the very end, from what I recall. J> Perhaps add the functionality to pg_restore? ie, pg_restore -s J> 256MB mybackup.db? It would just end up issuing a set J> sort_mem=256000.. This was essentially my proposal, though I had better speed enhancement by increasing the number of checkpoint buffers. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ From pgsql-performance-owner@postgresql.org Tue Oct 28 15:26: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 CC395D1B54C for ; Tue, 28 Oct 2003 19:25: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 52676-05 for ; Tue, 28 Oct 2003 15:25:29 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 7D8A7D1B55D for ; Tue, 28 Oct 2003 15:25:27 -0400 (AST) Received: (qmail 30435 invoked from network); 28 Oct 2003 19:27:19 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 28 Oct 2003 19:27:19 -0000 Date: Tue, 28 Oct 2003 14:25:24 -0500 From: Jeff To: Vivek Khera Cc: pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance Message-Id: <20031028142524.30e9e6fc.threshar@torgo.978.org> In-Reply-To: References: <20031028091645.3d610841.threshar@torgo.978.org> 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: 200310/718 X-Sequence-Number: 4466 On Tue, 28 Oct 2003 14:22:04 -0500 Vivek Khera wrote: > If you're restoring from a pg_dump -Fc (compressed dump) it already > happens for you. The indexes and foreign keys are not added until the > very end, from what I recall. > This happens with regular dumps - at the end is a pile of alter table's that create the indices, FK's and triggers. Is the -Fc method different? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Tue Oct 28 21:44: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 886C7D1B515 for ; Wed, 29 Oct 2003 01:44: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 12363-10 for ; Tue, 28 Oct 2003 21:43:34 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id C8A02D1B4EB for ; Tue, 28 Oct 2003 21:43:29 -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 h9T1hIoD062201; Wed, 29 Oct 2003 09:43:19 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3F9F1C30.4010306@familyhealth.com.au> Date: Wed, 29 Oct 2003 09:47:28 +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: Stephan Szabo Cc: Jeff , pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance References: <20031028091645.3d610841.threshar@torgo.978.org> <20031028113359.3932438f.threshar@torgo.978.org> <20031028101820.T64490@megazone.bigpanda.com> In-Reply-To: <20031028101820.T64490@megazone.bigpanda.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: 200310/719 X-Sequence-Number: 4467 >>Just loaded up delicious 7.4b5 and wow... >> >>sort_mem 8192: 137038ms [lots of tmp file activity] >>sort_mem 256000: 83109ms > > > Hmm, 298383 -> 83109 (since those are the 256k numbers). Not as > much as I'd have hoped, but I'll take a factor of 3. Hi Jeff, Could you let us know the load times when you have done: 1. A full ANALYZE 2. A delete all from pg_statistic So we can see if ANALYZE stats make much difference? Chris From pgsql-performance-owner@postgresql.org Wed Oct 29 06:24: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 B2D09D1B53E for ; Wed, 29 Oct 2003 10:24: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 89751-04 for ; Wed, 29 Oct 2003 06:24:06 -0400 (AST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by svr1.postgresql.org (Postfix) with ESMTP id 0B44ED1B53A for ; Wed, 29 Oct 2003 06:23:44 -0400 (AST) Received: from pestilence.mobilecohesion.com ([10.12.10.31] helo=pestilence) by mailserv.mobilecohesion.com with esmtp (Exim 4.10) id 1AEnU2-00034r-00; Wed, 29 Oct 2003 10:23:22 +0000 Content-Type: text/plain; charset="iso-8859-15" From: Damien Dougan Organization: Mobile Cohesion To: pgsql-performance@postgresql.org Subject: Re: Very Poor Insert Performance Date: Wed, 29 Oct 2003 10:22:24 +0000 User-Agent: KMail/1.4.1 Cc: Tom Lane References: <200310271626.52839.damien.dougan@mobilecohesion.com> <2493.1067285528@sss.pgh.pa.us> In-Reply-To: <2493.1067285528@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310291022.24035.damien.dougan@mobilecohesion.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/720 X-Sequence-Number: 4468 On Monday 27 October 2003 8:12 pm, Tom Lane wrote: > Damien Dougan writes: > > Has anyone any ideas as to what could be causing the spiraling > > performance? > > You really haven't provided any information that would allow anything > but guesses, but I'll guess anyway: poor plans for foreign key checks? > See nearby threads. > > regards, tom lane Apologies for not including more info - I had been hoping that spiralling p= erformance was a known tell-tale sign of something :) Here is some additional information - sorry if its overload, but I figured = I should give an intro to the schema before showing the EXPLAIN results! Firstly, a quick schema overview for the relevant tables: contact has many contactparts address has many addressparts contact has many address Now, the above table relationships are connected via relationship tables (r= ather than foreign indexes directly to each other), so we have: contact rel_contact_has_contactpart address rel_address_has_addresspart (The reasons behind this are for meta-data purposes - our database is inten= ded to be very abstract from the code...) Table "public.contact" Column | Type | Modif= iers ------------------+-----------------------------+--------------------------= ------------------------- id | integer | default nextval('contact_= id_seq'::text) version | integer | default 1 contactid | character varying | enddate | timestamp without time zone | preferredaddress | character varying | startdate | timestamp without time zone | Indexes: "contact_id_idx" unique, btree (id) "contact_key" unique, btree (contactid) So we have an index on the meta-data related "id" and the externally visibl= e "contactid" values. The "id" is used with the rel_contact_has_XXX tables = (see below). Table "public.contactpart" Column | Type | Modifiers -------------+-------------------+-----------------------------------------= ------- id | integer | default nextval('contactpart_id_seq'::te= xt) version | integer | default 1 detailname | character varying | not null detailvalue | character varying | Indexes: "contactpart_id_idx" unique, btree (id) So we have an index on the meta-data related "id". =20=20=20=20 Table "public.address" Column | Type | Modifiers ---------+-----------------------------+-----------------------------------= --------- id | integer | default nextval('mc_address_id_seq= '::text) version | integer | default 1 enddate | timestamp without time zone | format | character varying | type | character varying | not null value | character varying | Indexes: "address_id_idx" unique, btree (id) "address_value_key" btree (value) So we have an index on the meta-data related "id". Table "public.addresspart" Column | Type | Modifiers -------------+-------------------+-----------------------------------------= ------- id | integer | default nextval('addresspart_id_seq'::te= xt) version | integer | default 1 detailname | character varying | not null detailvalue | character varying | Indexes: "addresspart_id_idx" unique, btree (id) So we have an index on the meta-data related "id". This is used with the re= l_address_has_addresspart table (see below). =20=20=20=20 Table "public.rel_contact_has_contactpart" Column | Type | Modifiers ----------------------+---------+----------- contact_id | integer | contactpart_id | integer | Indexes: "rel_contact_has_contactpart_idx2" unique, btree (contactpart_id) "rel_contact_has_contactpart_idx1" btree (contact_id) So we have a unique index on the contactpart and a non-unique index on the = contact (to reflect the 1:M relationship contact has contactparts) Table "public.rel_address_has_addresspart" Column | Type | Modifiers -------------------+---------+----------- address_id | integer | addresspart_id | integer | Indexes: "rel_address_has_addresspart_idx2" unique, btree (addresspart_id) "rel_address_has_addresspart_idx1" btree (address_id) So we have a unique index on the addresspart and a non-unique index on the = address (to reflect the 1:M relationship address has addressparts) =20=20=20=20 Table "public.rel_contact_has_address" Column | Type | Modifiers ----------------------+---------+----------- contact_id | integer | address_id | integer | Indexes: "rel_contact_has_address_idx2" unique, btree (address_id) "rel_contact_has_address_idx1" btree (contactdetails_id) So we have a unique index on the address and a non-unique index on the cont= act (to reflect the 1:M relationship contact has addresses) However, to add a layer of abstraction to the business logic, the underlyin= g tables are never directly exposed through anything other than public view= s. The public views combine the and into a single table. So we have 2 public views: PvContact which ties together the contact and co= ntactparts, and PvAddress which ties together the address and addresspart. View "public.pvcontact" Column | Type | Modifiers ------------------+-----------------------------+----------- version | integer | contactid | character varying | startdate | timestamp without time zone | enddate | timestamp without time zone | preferredaddress | character varying | firstname | character varying | lastname | character varying | (Note - firstname and lastname are dervied from the detailnames of contactp= art table) View "public.pvaddress" Column | Type | Modifiers -----------+-----------------------------+----------- version | integer | contactid | character varying | type | character varying | format | character varying | enddate | timestamp without time zone | npi | character varying | ton | character varying | number | character varying | prefix | character varying | addrvalue | character varying | link | character varying | house | character varying | street | character varying | town | character varying | city | character varying | county | character varying | postcode | character varying | state | character varying | zipcode | character varying | extension | character varying | (Note - number, prefix, link, house, street, town, city, postcode etc are = derived from the detailnames of addresspart table) For example, suppose we have 2 contactparts for a particular contact (with = unique id =3D y): FirstName and LastName, then the contactpart table would = have 2 rows like: id =3D x version =3D 1 partname =3D 'FirstName' partvalue =3D 'John' id =3D x+1 version =3D 1 partname =3D 'LastName' partvalue =3D 'Doe' Then the public view, PvContact, would look like: Version =3D 1 ContactId =3D y StartDate =3D ... EndDate =3D ... PreferredAddress =3D ... FirstName =3D John LastName =3D Doe All Create, Read, Update, Delete operations on the DB are performed by Stor= edProcedures (again, to help abstract the code from the DB). The SPs are ca= pable of dealing with externally (public view) advertised schemas, and ensu= ring data integrity across the underlying tables. Now, our problem seems to be the delays introduced by reading from the publ= ic views. I've taken some measurements of raw INSERTS that mirror what the = SPs are doing (but the data is invalid and its not correctly linked across = tables (which is what the StoredProcs are responsible for) - but the INSERT= S are happening in the same order and frequency for a valid data upload). W= e can upload 2000 sets of users+contacts+addresses in about 17 seconds. But= when it is done via the Stored Procedures (which do some inserts, some rea= ds, some more inserts etc to ensure tables are properly linked via the rela= tionships), this drops to 2 minutes for 2000. And the performance spirals d= own to less than 1 user+contact+address per second after a short while. First of all then, the definition of the PublicView PvAddress View definition: SELECT address.id AS addressid, address."version", contact.id AS contactid= , contact.contactid AS contactuuid, address."type", address.format, address= .enddate, address.value, rel_npi.npiid, rel_npi.npi, rel_ton.tonid, rel_ton= .ton, rel_number.numberid, rel_number.number, rel_prefix.prefixid, rel_pref= ix.prefix, rel_addrvalue.addrvalueid, rel_addrvalue.addrvalue, rel_link.lin= kid, rel_link.link, rel_house.houseid, rel_house.house, rel_street.streetid= , rel_street.street, rel_town.townid, rel_town.town, rel_city.cityid, rel_c= ity.city, rel_county.countyid, rel_county.county, rel_postcode.postcodeid, = rel_postcode.postcode, rel_state.stateid, rel_state.state, rel_zipcode.zipc= odeid, rel_zipcode.zipcode, rel_extension.extensionid, rel_extension.extens= ion FROM svcurrentcontactdetails contact, rel_contact_has_address rel_contac= t, svcurrentaddress address LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS np= iid, det.detailvalue AS npi FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Npi'::text) rel_npi ON address.id =3D rel_npi.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS to= nid, det.detailvalue AS ton FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Ton'::text) rel_ton ON address.id =3D rel_ton.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS nu= mberid, det.detailvalue AS number FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Number'::text) rel_number ON address.id =3D rel_number.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS pr= efixid, det.detailvalue AS prefix FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Prefix'::text) rel_prefix ON address.id =3D rel_prefix.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS ad= drvalueid, det.detailvalue AS addrvalue FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'AddrValue'::text) rel_addrvalue ON address.id =3D rel_addrvalue.addre= ssid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS li= nkid, det.detailvalue AS link FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Link'::text) rel_link ON address.id =3D rel_link.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS ho= useid, det.detailvalue AS house FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'House'::text) rel_house ON address.id =3D rel_house.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS st= reetid, det.detailvalue AS street FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Street'::text) rel_street ON address.id =3D rel_street.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS to= wnid, det.detailvalue AS town FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Town'::text) rel_town ON address.id =3D rel_town.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS ci= tyid, det.detailvalue AS city FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'City'::text) rel_city ON address.id =3D rel_city.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS co= untyid, det.detailvalue AS county FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'County'::text) rel_county ON address.id =3D rel_county.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS po= stcodeid, det.detailvalue AS postcode FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Postcode'::text) rel_postcode ON address.id =3D rel_postcode.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS st= ateid, det.detailvalue AS state FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'State'::text) rel_state ON address.id =3D rel_state.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS zi= pcodeid, det.detailvalue AS zipcode FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Zipcode'::text) rel_zipcode ON address.id =3D rel_zipcode.addressid LEFT JOIN ( SELECT rel.address_id AS addressid, rel.addresspart_id AS ex= tensionid, det.detailvalue AS extension FROM rel_address_has_addresspart rel, addresspart det WHERE rel.addresspart_id =3D det.id AND det.detailname::text= =3D 'Extension'::text) rel_extension ON address.id =3D rel_extension.addre= ssid WHERE contact.id =3D rel_contact.contact_id AND address.id =3D rel_contac= t.address_id; =20=20 (The JOINs are where our problems are below ...) hydradb=3D# explain select * from pvaddress where contactuuid =3D 'test' an= d type =3D 'sms' and format is null ; = QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------------------------------------------------------------------- ----------------------------------------------- Merge Join (cost=3D42499.93..44975.38 rows=3D1 width=3D358) Merge Cond: ("outer".id =3D "inner".address_id) -> Merge Left Join (cost=3D42491.11..44957.05 rows=3D3795 width=3D323) Merge Cond: ("outer".id =3D "inner".address_id) -> Merge Left Join (cost=3D41822.20..44278.07 rows=3D3795 width= =3D305) Merge Cond: ("outer".id =3D "inner".address_id) -> Merge Left Join (cost=3D41153.29..43599.08 rows=3D3795 = width=3D287) Merge Cond: ("outer".id =3D "inner".address_id) -> Merge Left Join (cost=3D40484.39..42920.10 rows= =3D3795 width=3D269) Merge Cond: ("outer".id =3D "inner".address_id) -> Merge Left Join (cost=3D39815.48..42241.12 = rows=3D3795 width=3D251) Merge Cond: ("outer".id =3D "inner".addres= s_id) -> Merge Left Join (cost=3D39146.58..415= 62.13 rows=3D3795 width=3D233) Merge Cond: ("outer".id =3D "inner".= address_id) -> Merge Left Join (cost=3D38477.6= 7..40883.15 rows=3D3795 width=3D215) Merge Cond: ("outer".id =3D "i= nner".address_id) -> Merge Left Join (cost=3D3= 7808.76..40204.16 rows=3D3795 width=3D197) Merge Cond: ("outer".id = =3D "inner".address_id) -> Merge Left Join (co= st=3D37139.86..39525.18 rows=3D3795 width=3D179) Merge Cond: ("oute= r".id =3D "inner".address_id) -> Merge Left Joi= n (cost=3D36470.95..38846.20 rows=3D3795 width=3D161) Merge Cond: = ("outer".id =3D "inner".address_id) -> Merge Le= ft Join (cost=3D35802.04..38167.21 rows=3D3795 width=3D143) Merge = Cond: ("outer".id =3D "inner".address_id) -> Me= rge Left Join (cost=3D28634.40..30852.70 rows=3D3795 width=3D125) = Merge Cond: ("outer".id =3D "inner".address_id) = -> Merge Left Join (cost=3D21495.85..23569.10 rows=3D3795 width=3D107) = Merge Cond: ("outer".id =3D "inner".address_id) = -> Merge Left Join (cost=3D14328.21..16254.59 rows=3D3795 width=3D8= 9) = Merge Cond: ("outer".id =3D "inner".address_id) = -> Merge Left Join (cost=3D7102.23..8878.06 rows=3D3795 width= =3D71) = Merge Cond: ("outer".id =3D "inner".address_id) = -> Index Scan using address_id_idx on address (cost=3D0= .00..1633.07 rows=3D3795 width=3D53) = Filter: (((enddate IS NULL) OR (('now'::text)::time= stamp(6) with time zone < (enddate)::timestamp with time zone)) AND (("typ e")::text =3D 'sms'::text) AND (format IS NULL)) = -> Sort (cost=3D7102.23..7159.65 rows=3D22970 width=3D2= 2) = Sort Key: rel.address_id = -> Merge Join (cost=3D0.00..5438.34 rows=3D22970 = width=3D22) = Merge Cond: ("outer".id =3D "inner".addressli= ne_id) = -> Index Scan using addressline_id_idx on ad= dressline det (cost=3D0.00..2773.61 rows=3D22969 width=3D18) = Filter: ((detailname)::text =3D 'Npi'::= text) = -> Index Scan using rel_address_has_addressl= ine_idx2 on rel_address_has_addressline rel (cost=3D0.00..2082.13 rows=3D1= 181 93 width=3D8) = -> Sort (cost=3D7225.98..7286.76 rows=3D24310 width=3D22) = Sort Key: rel.address_id = -> Merge Join (cost=3D0.00..5455.09 rows=3D24310 width= =3D22) = Merge Cond: ("outer".id =3D "inner".addressline_id) = -> Index Scan using addressline_id_idx on addressl= ine det (cost=3D0.00..2773.61 rows=3D24309 width=3D18) = Filter: ((detailname)::text =3D 'Ton'::text) = -> Index Scan using rel_address_has_addressline_id= x2 on rel_address_has_addressline rel (cost=3D0.00..2082.13 rows=3D118193 = wid th=3D8) = -> Sort (cost=3D7167.64..7226.84 rows=3D23679 width=3D22) = Sort Key: rel.address_id = -> Merge Join (cost=3D0.00..5447.20 rows=3D23679 width=3D22) = Merge Cond: ("outer".id =3D "inner".addressline_id) = -> Index Scan using addressline_id_idx on addressline de= t (cost=3D0.00..2773.61 rows=3D23678 width=3D18) = Filter: ((detailname)::text =3D 'Number'::text) = -> Index Scan using rel_address_has_addressline_idx2 on = rel_address_has_addressline rel (cost=3D0.00..2082.13 rows=3D118193 width= =3D8) = -> Sort (cost=3D7138.56..7196.97 rows=3D23364 width=3D22) = Sort Key: rel.address_id = -> Merge Join (cost=3D0.00..5443.27 rows=3D23364 width=3D22) = Merge Cond: ("outer".id =3D "inner".addressline_id) = -> Index Scan using addressline_id_idx on addressline det (co= st=3D0.00..2773.61 rows=3D23363 width=3D18) = Filter: ((detailname)::text =3D 'Prefix'::text) = -> Index Scan using rel_address_has_addressline_idx2 on rel_ad= dress_has_addressline rel (cost=3D0.00..2082.13 rows=3D118193 width=3D8) -> So= rt (cost=3D7167.64..7226.84 rows=3D23679 width=3D22) = Sort Key: rel.address_id = -> Merge Join (cost=3D0.00..5447.20 rows=3D23679 width=3D22) = Merge Cond: ("outer".id =3D "inner".addressline_id) = -> Index Scan using addressline_id_idx on addressline det (cost=3D0= .00..2773.61 rows=3D23678 width=3D18) = Filter: ((detailname)::text =3D 'AddrValue'::text) = -> Index Scan using rel_address_has_addressline_idx2 on rel_address_= has_addressline rel (cost=3D0.00..2082.13 rows=3D118193 width=3D8) -> Sort (c= ost=3D668.91..669.16 rows=3D100 width=3D22) Sort K= ey: rel.address_id -> Ne= sted Loop (cost=3D0.00..665.58 rows=3D100 width=3D22) = -> Index Scan using addressline_detail_idx on addressline det (cost=3D0.0= 0..366.01 rows=3D99 width=3D18) = Index Cond: ((detailname)::text =3D 'Link'::text) = -> Index Scan using rel_address_has_addressline_idx2 on rel_address_has_ad= dressline rel (cost=3D0.00..3.01 rows=3D1 width=3D8) = Index Cond: (rel.addressline_id =3D "outer".id) -> Sort (cost=3D= 668.91..669.16 rows=3D100 width=3D22) Sort Key: re= l.address_id -> Nested L= oop (cost=3D0.00..665.58 rows=3D100 width=3D22) -> In= dex Scan using addressline_detail_idx on addressline det (cost=3D0.00..366= .01 rows=3D99 width=3D18) = Index Cond: ((detailname)::text =3D 'House'::text) -> In= dex Scan using rel_address_has_addressline_idx2 on rel_address_has_addressl= ine rel (cost=3D0.00..3.01 rows=3D1 width=3D8) = Index Cond: (rel.addressline_id =3D "outer".id) -> Sort (cost=3D668.91= ..669.16 rows=3D100 width=3D22) Sort Key: rel.addr= ess_id -> Nested Loop (= cost=3D0.00..665.58 rows=3D100 width=3D22) -> Index Sc= an using addressline_detail_idx on addressline det (cost=3D0.00..366.01 ro= ws=3D99 width=3D18) Index = Cond: ((detailname)::text =3D 'Street'::text) -> Index Sc= an using rel_address_has_addressline_idx2 on rel_address_has_addressline re= l (cost=3D0.00..3.01 rows=3D1 width=3D8) Index = Cond: (rel.addressline_id =3D "outer".id) -> Sort (cost=3D668.91..669.= 16 rows=3D100 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost= =3D0.00..665.58 rows=3D100 width=3D22) -> Index Scan usi= ng addressline_detail_idx on addressline det (cost=3D0.00..366.01 rows=3D9= 9 width=3D18) Index Cond: = ((detailname)::text =3D 'Town'::text) -> Index Scan usi= ng rel_address_has_addressline_idx2 on rel_address_has_addressline rel (co= st=3D0.00..3.01 rows=3D1 width=3D8) Index Cond: = (rel.addressline_id =3D "outer".id) -> Sort (cost=3D668.91..669.16 row= s=3D100 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00.= .665.58 rows=3D100 width=3D22) -> Index Scan using add= ressline_detail_idx on addressline det (cost=3D0.00..366.01 rows=3D99 widt= h=3D18) Index Cond: ((deta= ilname)::text =3D 'City'::text) -> Index Scan using rel= _address_has_addressline_idx2 on rel_address_has_addressline rel (cost=3D0= .00..3.01 rows=3D1 width=3D8) Index Cond: (rel.a= ddressline_id =3D "outer".id) -> Sort (cost=3D668.91..669.16 rows=3D10= 0 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00..665.5= 8 rows=3D100 width=3D22) -> Index Scan using addressli= ne_detail_idx on addressline det (cost=3D0.00..366.01 rows=3D99 width=3D18) Index Cond: ((detailname= )::text =3D 'County'::text) -> Index Scan using rel_addre= ss_has_addressline_idx2 on rel_address_has_addressline rel (cost=3D0.00..3= .01 rows=3D1 width=3D8) Index Cond: (rel.address= line_id =3D "outer".id) -> Sort (cost=3D668.91..669.16 rows=3D100 widt= h=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00..665.58 rows= =3D100 width=3D22) -> Index Scan using addressline_det= ail_idx on addressline det (cost=3D0.00..366.01 rows=3D99 width=3D18) Index Cond: ((detailname)::tex= t =3D 'Postcode'::text) -> Index Scan using rel_address_has= _addressline_idx2 on rel_address_has_addressline rel (cost=3D0.00..3.01 ro= ws=3D1 width=3D8) Index Cond: (rel.addressline_i= d =3D "outer".id) -> Sort (cost=3D668.91..669.16 rows=3D100 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00..665.58 rows=3D100= width=3D22) -> Index Scan using addressline_detail_id= x on addressline det (cost=3D0.00..366.01 rows=3D99 width=3D18) Index Cond: ((detailname)::text =3D = 'State'::text) -> Index Scan using rel_address_has_addre= ssline_idx2 on rel_address_has_addressline rel (cost=3D0.00..3.01 rows=3D1= width=3D8) Index Cond: (rel.addressline_id =3D = "outer".id) -> Sort (cost=3D668.91..669.16 rows=3D100 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00..665.58 rows=3D100 width= =3D22) -> Index Scan using addressline_detail_idx on a= ddressline det (cost=3D0.00..366.01 rows=3D99 width=3D18) Index Cond: ((detailname)::text =3D 'Zipco= de'::text) -> Index Scan using rel_address_has_addressline= _idx2 on rel_address_has_addressline rel (cost=3D0.00..3.01 rows=3D1 width= =3D8) Index Cond: (rel.addressline_id =3D "outer= ".id) -> Sort (cost=3D668.91..669.16 rows=3D100 width=3D22) Sort Key: rel.address_id -> Nested Loop (cost=3D0.00..665.58 rows=3D100 width=3D22) -> Index Scan using addressline_detail_idx on address= line det (cost=3D0.00..366.01 rows=3D99 width=3D18) Index Cond: ((detailname)::text =3D 'Extension':= :text) -> Index Scan using rel_address_has_addressline_idx2 = on rel_address_has_addressline rel (cost=3D0.00..3.01 rows=3D1 width=3D8) Index Cond: (rel.addressline_id =3D "outer".id) -> Sort (cost=3D8.83..8.83 rows=3D2 width=3D39) Sort Key: rel_contact.address_id -> Nested Loop (cost=3D0.00..8.82 rows=3D2 width=3D39) -> Index Scan using contact_key on contact (cost=3D0.00..5= .77 rows=3D1 width=3D35) Index Cond: ((contactid)::text =3D 'test'::text) Filter: (((startdate IS NULL) OR (('now'::text)::times= tamp(6) with time zone >=3D (startdate)::timestamp with time zone)) AND ((e= nddate IS NULL) OR (('now'::text)::timestamp(6) with time zone < (enddate):: timestamp with time zone))) -> Index Scan using rel_contact_has_address_idx1 on rel_con= tact_has_address rel_contact (cost=3D0.00..3.02 rows=3D2 width=3D8) Index Cond: ("outer".id =3D rel_contact.contact_id) (147 rows) As you can see, the PublicView is resulting in a huge nested loop, with an = index scan of the contact only occurring at the end. I would have expected = something more like: (1) An index scan of the contact table to determine the correct contact (2) An index scan of the address table using the rel_contact_has_address.ad= dress_id to obtain the (relatively small - max 16, and typically 2) address= es (3) A number of joins - at the same level rather than looping - to obtain t= he detailnames for the new column names of the public view As I said in my original email, these delays are after applying all the per= formance related enhancements (fsync off, increased backbuffers, sort memor= y etc) I have picked up from the archives and FAQ. The upload script was al= so modified to commit and vacuum analyze at different intervals without pro= viding any significant improvement. top reports the CPU usage at 99% - so I= believe its all looping of the above intermediate SELECTs that is causing = the spiralling delays as the number of rows increases. Again, any help would be very much appreciated! Damien From pgsql-performance-owner@postgresql.org Wed Oct 29 10:02: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 167DED1B538 for ; Wed, 29 Oct 2003 14:02: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 27051-08 for ; Wed, 29 Oct 2003 10:02:05 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 48476D1B4E5 for ; Wed, 29 Oct 2003 10:02:01 -0400 (AST) Received: (qmail 9959 invoked from network); 29 Oct 2003 14:04:02 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 29 Oct 2003 14:04:02 -0000 Date: Wed, 29 Oct 2003 09:01:54 -0500 From: Jeff To: Christopher Kings-Lynne Cc: sszabo@megazone.bigpanda.com, pgsql-performance@postgresql.org Subject: Re: Adding foreign key performance Message-Id: <20031029090154.53b1e22d.threshar@torgo.978.org> In-Reply-To: <3F9F1C30.4010306@familyhealth.com.au> References: <20031028091645.3d610841.threshar@torgo.978.org> <20031028113359.3932438f.threshar@torgo.978.org> <20031028101820.T64490@megazone.bigpanda.com> <3F9F1C30.4010306@familyhealth.com.au> 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: 200310/721 X-Sequence-Number: 4469 On Wed, 29 Oct 2003 09:47:28 +0800 Christopher Kings-Lynne wrote: > >>Just loaded up delicious 7.4b5 and wow... > >> > >>sort_mem 8192: 137038ms [lots of tmp file activity] > >>sort_mem 256000: 83109ms > > > 1. A full ANALYZE > 2. A delete all from pg_statistic > I had previously analyze'd before I ran those numbers. But I did it again with and without stats. With: Run 1 Time: 80157.21 ms Run 2 Time: 80763.59 ms Killed statistics: Time: 80571.71 ms Time: 80759.18 ms Chances are it is going to seq scan regardless so the stats are rather useless. Perhaps in other scenarios it would help. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Wed Oct 29 10:04: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 09686D1B563 for ; Wed, 29 Oct 2003 14:04: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 27817-05 for ; Wed, 29 Oct 2003 10:04:19 -0400 (AST) Received: from bramble.mmrd.com (unknown [65.217.53.66]) by svr1.postgresql.org (Postfix) with ESMTP id 7A495D1B556 for ; Wed, 29 Oct 2003 10:04:15 -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 h9TD5LcM019632 for ; Wed, 29 Oct 2003 08:05:23 -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 h9TE3vl14918 for ; Wed, 29 Oct 2003 09:03:58 -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 V3JRRANF; Wed, 29 Oct 2003 09:03:55 -0500 Subject: redundent index? From: Robert Treat To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 29 Oct 2003 09:03:56 -0500 Message-Id: <1067436236.2069.28785.camel@camel> Mime-Version: 1.0 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/722 X-Sequence-Number: 4470 I just noticed on one of my tables I have the following two indexes: Indexes: entity_watch_map_pkey primary key btree (entity_id, watch_id), ewm_entity_id btree (entity_id), I can't think of why the second index is there, as ISTM there is no instance where the first index wouldn't be used in place of the second one if i were to delete the second one. its a heavily updated table, so axing the second one would be a bonus for performance, am i missing something? Thanks in advance, Robert Treat -- Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgsql-performance-owner@postgresql.org Wed Oct 29 10:24: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 7014CD1B55D for ; Wed, 29 Oct 2003 14:24: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 33087-06 for ; Wed, 29 Oct 2003 10:23:58 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 0220AD1B545 for ; Wed, 29 Oct 2003 10:23: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 h9TENJit003668; Wed, 29 Oct 2003 09:23:19 -0500 (EST) To: Damien Dougan Cc: pgsql-performance@postgresql.org Subject: Re: Very Poor Insert Performance In-reply-to: <200310291022.24035.damien.dougan@mobilecohesion.com> References: <200310271626.52839.damien.dougan@mobilecohesion.com> <2493.1067285528@sss.pgh.pa.us> <200310291022.24035.damien.dougan@mobilecohesion.com> Comments: In-reply-to Damien Dougan message dated "Wed, 29 Oct 2003 10:22:24 +0000" Date: Wed, 29 Oct 2003 09:23:19 -0500 Message-ID: <3667.1067437399@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/723 X-Sequence-Number: 4471 Damien Dougan writes: > Now, our problem seems to be the delays introduced by reading from the > public views. Your initial message stated plainly that the problem was in INSERTs; it's not surprising that you got unhelpful advice. > View definition: > [ huge view full of LEFT JOINs ] > As you can see, the PublicView is resulting in a huge nested loop, > with an index scan of the contact only occurring at the end. I would > have expected something more like: > (1) An index scan of the contact table to determine the correct contact > (2) An index scan of the address table using the rel_contact_has_address.address_id to obtain the (relatively small - max 16, and typically 2) addresses > (3) A number of joins - at the same level rather than looping - to obtain the detailnames for the new column names of the public view Your LEFT JOINs are constraining the join order --- see http://www.postgresql.org/docs/7.3/static/explicit-joins.html You'll need to reorder the joins into something that does what you want. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 29 10:41: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 35791D1B53A for ; Wed, 29 Oct 2003 14:41: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 36999-01 for ; Wed, 29 Oct 2003 10:41:14 -0400 (AST) Received: from mailserv.mobilecohesion.com (picard.mobilecohesion.com [80.4.157.11]) by svr1.postgresql.org (Postfix) with ESMTP id C854BD1B523 for ; Wed, 29 Oct 2003 10:41:09 -0400 (AST) Received: from pestilence.mobilecohesion.com ([10.12.10.31] helo=pestilence) by mailserv.mobilecohesion.com with esmtp (Exim 4.10) id 1AErVT-0003c2-00; Wed, 29 Oct 2003 14:41:07 +0000 Content-Type: text/plain; charset="iso-8859-15" From: Damien Dougan Organization: Mobile Cohesion To: pgsql-performance@postgresql.org Subject: Re: Very Poor Insert Performance Date: Wed, 29 Oct 2003 14:40:06 +0000 User-Agent: KMail/1.4.1 Cc: Tom Lane References: <200310271626.52839.damien.dougan@mobilecohesion.com> <200310291022.24035.damien.dougan@mobilecohesion.com> <3667.1067437399@sss.pgh.pa.us> In-Reply-To: <3667.1067437399@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310291440.06450.damien.dougan@mobilecohesion.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/724 X-Sequence-Number: 4472 On Wednesday 29 October 2003 2:23 pm, Tom Lane wrote: > Your initial message stated plainly that the problem was in INSERTs; > it's not surprising that you got unhelpful advice. But perhaps my use of the term "insert" to describe upload was a very bad c= all=20 given the domain of the list... I assure you I wasn't setting out to deceive anyone! The only location i us= ed=20 INSERT (ie as a Postgres keyword) was towards the end of my mail when I tri= ed=20 to highlight the fact we couldn't use COPY to upload our data because of th= e=20 difficulty in maintaining the code to generate inter-table relations ahead = of=20 time. The problem was showing itself during database upload - so I assumed (ASS o= ut=20 of U and ME and all that!) that the write delay was very large (hence the= =20 disappointing improvements by switching off fsync etc). It was only after= =20 further investigation that we discovered that simulated INSERTs were going= =20 fine, but the Read delays between INSERTs where holding us up. > Your LEFT JOINs are constraining the join order --- see > http://www.postgresql.org/docs/7.3/static/explicit-joins.html > You'll need to reorder the joins into something that does what you want. Thanks very much for the heads-up, we'll reorder the joins into something m= ore=20 effecient! Damien From pgsql-performance-owner@postgresql.org Wed Oct 29 11:18: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 52750D1B537 for ; Wed, 29 Oct 2003 15:17: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 38400-04 for ; Wed, 29 Oct 2003 11:17:32 -0400 (AST) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id E5FDBD1B508 for ; Wed, 29 Oct 2003 11:17:22 -0400 (AST) Received: (qmail 20569 invoked from network); 29 Oct 2003 15:16:31 -0000 Received: from unknown (HELO ?10.0.2.5?) (216.208.117.7) by 205.178.180.9 with SMTP; 29 Oct 2003 15:16:31 -0000 Subject: Re: redundent index? From: Rod Taylor To: Robert Treat Cc: Postgresql Performance In-Reply-To: <1067436236.2069.28785.camel@camel> References: <1067436236.2069.28785.camel@camel> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-JrIgf+aZ/bwKPCl6LkvD" Message-Id: <1067440627.5789.2.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 29 Oct 2003 10:17:24 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/725 X-Sequence-Number: 4473 --=-JrIgf+aZ/bwKPCl6LkvD Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-10-29 at 09:03, Robert Treat wrote: > I just noticed on one of my tables I have the following two indexes: >=20 > Indexes: entity_watch_map_pkey primary key btree (entity_id, watch_id), > ewm_entity_id btree (entity_id), >=20 >=20 > I can't think of why the second index is there, as ISTM there is no > instance where the first index wouldn't be used in place of the second The cost in evaluating the first index will be a little higher (more data to pull off disk due to second item), so there may be a few borderline cases that could switch to a sequential scan rather than an index scan. --=-JrIgf+aZ/bwKPCl6LkvD Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/n9nz6DETLow6vwwRAtbvAKCF3HGfA2T7lz3og7ntfapVyRAyVgCfeS5t unNgh8ZmMa1gm7W9dPJwDWk= =V03b -----END PGP SIGNATURE----- --=-JrIgf+aZ/bwKPCl6LkvD-- From pgsql-performance-owner@postgresql.org Wed Oct 29 15:21: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 369F9D1B57C for ; Wed, 29 Oct 2003 19:21: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 80545-04 for ; Wed, 29 Oct 2003 15:21:06 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id B2E07D1B555 for ; Wed, 29 Oct 2003 15:21:04 -0400 (AST) Received: (qmail 16616 invoked from network); 29 Oct 2003 19:22:43 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 19:22:43 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 00:52:43 +0530 (IST) Message-ID: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 00:52:43 +0530 (IST) Subject: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) From: To: 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-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=BAYES_20, CLICK_BELOW, MISSING_MIMEOLE, MISSING_OUTLOOK_NAME, NO_REAL_NAME, SEARCH_ENGINE_PROMO X-Spam-Level: X-Archive-Number: 200310/726 X-Sequence-Number: 4474 Dear PostgreSQL gurus, I really not intend to start a flame war here but i am genuinely seeking help to retain PostgreSQL as my database for my RT system. Few months back i had posted regarding lowering of column names in SQL being passed to RDBMS by DBIx::SearchBuilder , looks like it was controlled by a parameter "CASESENSITIVE" changing it to 1 from 0 did help for postgresql to MySQL it probably does not matter. But This time its a different situation The query in Postgresql is taking 6 times more than MySQL The Query being given gets generated by DBIx::SearchBuilder. Although i am not sure but i feel modules like DBIx::SearchBuilder which are supposed to provide RDBMS independent abstraction are unfortunately getting test only with MySQL or Oracle otherwise such huge difference in timing were not possible. IN MYSQL: ======== mysql> SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ;+-------+------------+---------------------------+----------------+-----------+----------+ | id | Name | Description | Domain | Type | Instance | +-------+------------+---------------------------+----------------+-----------+----------+ | 40208 | sales | Sales team in Delhi | UserDefined | | | | 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 | | 11 | User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 | | 13 | User 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 | | 31067 | User 31066 | ACL equiv. for user 31066 | ACLEquivalence | UserEquiv | 31066 | +-------+------------+---------------------------+----------------+-----------+----------+ 5 rows in set (0.94 sec) mysql> WHEREAS for PostgreSQL: rt3=# SELECT version(); PostgreSQL 7.4beta5 on i686-pc-linux-gnu, compiled by GCC 2.96 rt3=# SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ;+-------+------------+---------------------------+----------------+-----------+----------+ | id | name | description | domain | type | instance | +-------+------------+---------------------------+----------------+-----------+----------+ | 40264 | sales | Sales team in Delhi | UserDefined | | | | 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 | | 11 | User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 | | 13 | User 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 | | 31123 | User 31122 | ACL equiv. for user 31122 | ACLEquivalence | UserEquiv | 31122 | +-------+------------+---------------------------+----------------+-----------+----------+ (5 rows) Time: 7281.574 ms rt3=# Explain Analyze of Above Query is being given below: Unique (cost=4744.06..4744.08 rows=1 width=81) (actual time=6179.789..6179.828 rows=5 loops=1) -> Sort (cost=4744.06..4744.07 rows=1 width=81) (actual time=6179.785..6179.792 rows=6 loops=1) Sort Key: main.name, main.id, main.description, main."domain", main."type", main.instance -> Nested Loop (cost=1788.68..4744.05 rows=1 width=81) (actual time=584.004..6179.712 rows=6 loops=1) Join Filter: (((("inner".principaltype)::text = 'Group'::text) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer".instance)::text = '6973'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer".instance)::text = '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer".instance)::text = '6973'::text) OR (("outer".instance)::text = '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND ((("outer"."domain")::text = 'SystemInternal'::text) OR (("outer"."domain")::text = 'UserDefined'::text) OR (("outer"."domain")::text = 'ACLEquivalence'::text) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("inner".principalid = "outer".id) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".principalid = "outer".id) OR (("outer".instance)::text = '6973'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".principalid = "outer".id) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer".instance)::text = '25'::text)) AND (("inner".principalid = "outer".id) OR (("outer".instance)::text = '6973'::text) OR (("outer".instance)::text = '25'::text)) AND (("inner".principalid = "outer".id) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("outer".id = "outer".id) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("inner".principalid = "outer".id) OR ("outer".id = "outer".id)) AND ((("inner".principaltype)::text = 'Group'::text) OR ("outer".id = "outer".id))) -> Merge Join (cost=1788.68..4735.71 rows=1 width=85) (actual time=583.804..1187.448 rows=20153 loops=1) Merge Cond: ("outer".id = "inner".id) Join Filter: ((("inner".id = "outer".id) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR (("inner".instance)::text = '6973'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner".instance)::text = '25'::text)) AND (("inner".id = "outer".id) OR (("inner".instance)::text = '6973'::text) OR (("inner".instance)::text = '25'::text)) AND ((("inner"."domain")::text = 'SystemInternal'::text) OR (("inner"."domain")::text = 'UserDefined'::text) OR (("inner"."domain")::text = 'ACLEquivalence'::text) OR ("inner".id = "outer".id))) -> Index Scan using principals_pkey on principals principals_1 (cost=0.00..2536.49 rows=82221 width=4) (actual time=0.087..169.725 rows=64626 loops=1) -> Sort (cost=1788.68..1797.99 rows=3726 width=81) (actual time=583.624..625.604 rows=20153 loops=1) Sort Key: main.id -> Index Scan using groups_domain, groups_domain, groups_domain, groups_lower_instance, groups_domain on groups main (cost=0.00..1567.66 rows=3726 width=81) (actual time=0.132..449.240 rows=20153 loops=1) Index Cond: ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) Filter: (((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR ((instance)::text = '25'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR ((instance)::text = '25'::text))) -> Index Scan using acl_objectid, acl_objecttype on acl acl_2 (cost=0.00..8.03 rows=3 width=13) (actual time=0.032..0.138 rows=6 loops=20153) Index Cond: ((objectid = 25) OR ((objecttype)::text = 'RT::System'::text)) Filter: ((((rightname)::text = 'OwnTicket'::text) OR ((rightname)::text = 'SuperUser'::text)) AND (((objecttype)::text = 'RT::Queue'::text) OR ((objecttype)::text = 'RT::System'::text))) Total runtime: 6183.155 ms [ 6 secs approx ] (18 rows) Sincerely Looking Forward to a Help Regds Mallah ----------------------------------------- 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 Wed Oct 29 15:44: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 F2E29D1B4E9 for ; Wed, 29 Oct 2003 19:44: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 87150-08 for ; Wed, 29 Oct 2003 15:43:52 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id 8F9C6D1B50E for ; Wed, 29 Oct 2003 15:43:50 -0400 (AST) Received: (qmail 19619 invoked from network); 29 Oct 2003 19:45:44 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 19:45:44 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 01:15:44 +0530 (IST) Message-ID: <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 01:15:44 +0530 (IST) Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) From: To: In-Reply-To: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> 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: 200310/727 X-Sequence-Number: 4475 Actually PostgreSQL is at par with MySQL when the query is being Properly Written(simplified) like below rt3=# SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') ) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType ) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ; id | name | description | domain | type | instance -------+------------+---------------------------+----------------+-----------+---------- 40264 | sales | Sales team in Delhi | UserDefined | | 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 11 | User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 13 | User 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 31123 | User 31122 | ACL equiv. for user 31122 | ACLEquivalence | UserEquiv | 31122 (5 rows) ( Total runtime: 1.699 ms ) Time: 6.455 ms which is 0.00 6455 Secs In mysql: mysql> SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') ) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType ) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ;+-------+------------+---------------------------+----------------+-----------+----------+ | id | Name | Description | Domain | Type | Instance | +-------+------------+---------------------------+----------------+-----------+----------+ | 40208 | sales | Sales team in Delhi | UserDefined | | | | 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 | | 11 | User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 | | 13 | User 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 | | 31067 | User 31066 | ACL equiv. for user 31066 | ACLEquivalence | UserEquiv | 31066 | +-------+------------+---------------------------+----------------+-----------+----------+ 5 rows in set (0.00 sec) mysql> So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. But the question is my does PostgreSQL suffer so badly ?? I think not all developers write very nice SQLs. Its really sad to see that a fine peice of work (RT) is performing sub-optimal becoz of malformed SQLs. [ specially on database of my choice ;-) ] Regds Mallah. > > Dear PostgreSQL gurus, > > I really not intend to start a flame war here but i am genuinely > seeking help to retain PostgreSQL as my database for my RT > system. > > Few months back i had posted regarding lowering of column names in SQL being passed to RDBMS by > DBIx::SearchBuilder , looks like it was controlled by a parameter "CASESENSITIVE" changing it > to 1 from 0 did help for postgresql to MySQL it probably does not matter. > > > But This time its a different situation > The query in Postgresql is taking 6 times more than MySQL > > The Query being given gets generated by DBIx::SearchBuilder. > Although i am not sure but i feel modules like DBIx::SearchBuilder which are supposed to > provide RDBMS independent abstraction are unfortunately getting test only with MySQL or Oracle > otherwise such huge difference in timing were not possible. > > > > IN MYSQL: > ======== > mysql> SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE > ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( > ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = > 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id > = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( > main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = > ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR > (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC > ;+-------+------------+---------------------------+----------------+-----------+----------+ | > id | Name | Description | Domain | Type | Instance | > +-------+------------+---------------------------+----------------+-----------+----------+ | > 40208 | sales | Sales team in Delhi | UserDefined | | | | > 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 | | 11 | > User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 | | 13 | User > 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 | | 31067 | User > 31066 | ACL equiv. for user 31066 | ACLEquivalence | UserEquiv | 31066 | > +-------+------------+---------------------------+----------------+-----------+----------+ 5 > rows in set (0.94 sec) > > mysql> > > WHEREAS for PostgreSQL: > rt3=# SELECT version(); > PostgreSQL 7.4beta5 on i686-pc-linux-gnu, compiled by GCC 2.96 > > > rt3=# SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE > ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( > ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = > 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id > = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( > main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = > ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR > (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC > ;+-------+------------+---------------------------+----------------+-----------+----------+ | > id | name | description | domain | type | instance | > +-------+------------+---------------------------+----------------+-----------+----------+ | > 40264 | sales | Sales team in Delhi | UserDefined | | | | > 2 | User 1 | ACL equiv. for user 1 | ACLEquivalence | UserEquiv | 1 | | 11 | > User 10 | ACL equiv. for user 10 | ACLEquivalence | UserEquiv | 10 | | 13 | User > 12 | ACL equiv. for user 12 | ACLEquivalence | UserEquiv | 12 | | 31123 | User > 31122 | ACL equiv. for user 31122 | ACLEquivalence | UserEquiv | 31122 | > +-------+------------+---------------------------+----------------+-----------+----------+ (5 > rows) > Time: 7281.574 ms > rt3=# > > Explain Analyze of Above Query is being given below: > > Unique (cost=4744.06..4744.08 rows=1 width=81) (actual time=6179.789..6179.828 rows=5 loops=1) > -> Sort (cost=4744.06..4744.07 rows=1 width=81) (actual time=6179.785..6179.792 rows=6 > loops=1) > Sort Key: main.name, main.id, main.description, main."domain", main."type", > main.instance -> Nested Loop (cost=1788.68..4744.05 rows=1 width=81) (actual > time=584.004..6179.712 rows=6 loops=1) Join Filter: > (((("inner".principaltype)::text = 'Group'::text) OR > (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer"."domain")::text > = 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) > OR (("outer".instance)::text = '6973'::text) OR (("outer"."domain")::text = > 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR > (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer".instance)::text > = '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR > (("outer".instance)::text = '6973'::text) OR (("outer".instance)::text = > '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR > (("outer"."type")::text = ("inner".principaltype)::text)) AND > ((("outer"."domain")::text = 'SystemInternal'::text) OR (("outer"."domain")::text > = 'UserDefined'::text) OR (("outer"."domain")::text = 'ACLEquivalence'::text) OR > (("outer"."type")::text = ("inner".principaltype)::text)) AND > (("inner".principalid = "outer".id) OR (("outer"."domain")::text = > 'RT::Ticket-Role'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) > AND (("inner".principalid = "outer".id) OR (("outer".instance)::text = > '6973'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND > (("inner".principalid = "outer".id) OR (("outer"."domain")::text = > 'RT::Ticket-Role'::text) OR (("outer".instance)::text = '25'::text)) AND > (("inner".principalid = "outer".id) OR (("outer".instance)::text = '6973'::text) > OR (("outer".instance)::text = '25'::text)) AND (("inner".principalid = > "outer".id) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND > (("outer".id = "outer".id) OR (("outer"."type")::text = > ("inner".principaltype)::text)) AND (("inner".principalid = "outer".id) OR > ("outer".id = "outer".id)) AND ((("inner".principaltype)::text = 'Group'::text) > OR ("outer".id = "outer".id))) -> Merge Join > (cost=1788.68..4735.71 rows=1 width=85) (actual time=583.804..1187.448 rows=20153 > loops=1) Merge Cond: ("outer".id = "inner".id) > Join Filter: ((("inner".id = "outer".id) OR (("inner"."domain")::text = > 'RT::Ticket-Role'::text) OR (("inner"."domain")::text = > 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR > (("inner".instance)::text = '6973'::text) OR (("inner"."domain")::text = > 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR > (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR > (("inner".instance)::text = '25'::text)) AND (("inner".id = "outer".id) OR > (("inner".instance)::text = '6973'::text) OR (("inner".instance)::text = > '25'::text)) AND ((("inner"."domain")::text = 'SystemInternal'::text) OR > (("inner"."domain")::text = 'UserDefined'::text) OR > (("inner"."domain")::text = 'ACLEquivalence'::text) OR ("inner".id = > "outer".id))) -> Index Scan using principals_pkey on > principals principals_1 (cost=0.00..2536.49 rows=82221 width=4) (actual > time=0.087..169.725 rows=64626 loops=1) -> Sort > (cost=1788.68..1797.99 rows=3726 width=81) (actual time=583.624..625.604 > rows=20153 loops=1) Sort Key: main.id > -> Index Scan using groups_domain, groups_domain, groups_domain, > groups_lower_instance, groups_domain on groups main > (cost=0.00..1567.66 rows=3726 width=81) (actual time=0.132..449.240 > rows=20153 loops=1) Index Cond: > ((("domain")::text = 'SystemInternal'::text) OR > (("domain")::text = 'UserDefined'::text) OR (("domain")::text = > 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR > (("domain")::text = 'RT::Queue-Role'::text)) > Filter: (((("domain")::text = > 'SystemInternal'::text) OR (("domain")::text = > 'UserDefined'::text) OR (("domain")::text = > 'ACLEquivalence'::text) OR (("domain")::text = > 'RT::Ticket-Role'::text) OR (("domain")::text = > 'RT::Queue-Role'::text)) AND ((("domain")::text = > 'SystemInternal'::text) OR (("domain")::text = > 'UserDefined'::text) OR (("domain")::text = > 'ACLEquivalence'::text) OR (("domain")::text = > 'RT::Ticket-Role'::text) OR ((instance)::text = '25'::text)) > AND ((("domain")::text = 'SystemInternal'::text) OR > (("domain")::text = 'UserDefined'::text) OR (("domain")::text = > 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR > ((instance)::text = '25'::text))) -> Index Scan > using acl_objectid, acl_objecttype on acl acl_2 > (cost=0.00..8.03 > rows=3 width=13) (actual time=0.032..0.138 rows=6 loops=20153) > Index Cond: ((objectid = 25) OR ((objecttype)::text = 'RT::System'::text)) > Filter: ((((rightname)::text = 'OwnTicket'::text) OR ((rightname)::text = > 'SuperUser'::text)) AND (((objecttype)::text = 'RT::Queue'::text) OR > ((objecttype)::text = 'RT::System'::text))) Total runtime: 6183.155 ms [ 6 > secs approx ] > (18 rows) > > Sincerely Looking Forward to a Help > Regds > Mallah > > > > > > > > > ----------------------------------------- > 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/ > > > > ---------------------------(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 Thu Oct 30 16:42: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 F1671D1B4F4 for ; Wed, 29 Oct 2003 19:52: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 89174-02 for ; Wed, 29 Oct 2003 15:51:31 -0400 (AST) Received: from pallas.eruditorum.org (pallas.eruditorum.org [63.251.136.85]) by svr1.postgresql.org (Postfix) with ESMTP id CA3DCD1B4E9 for ; Wed, 29 Oct 2003 15:51:29 -0400 (AST) Received: by pallas.eruditorum.org (Postfix, from userid 500) id 6AA4E11325; Wed, 29 Oct 2003 14:51:15 -0500 (EST) Date: Wed, 29 Oct 2003 14:51:15 -0500 From: Jesse To: mallah@trade-india.com Cc: pgsql-performance@postgresql.org Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) Message-ID: <20031029195115.GX7337@pallas.fsck.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> User-Agent: Mutt/1.5.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/778 X-Sequence-Number: 4526 On Thu, Oct 30, 2003 at 01:15:44AM +0530, mallah@trade-india.com wrote: > Actually PostgreSQL is at par with MySQL when the query is being Properly Written(simplified) > > In mysql: > mysql> SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join ACL > ACL_2 on (ACL_2.PrincipalId = Principals_1.id) Interesting, last time I looked, this syntax wasn't valid on mysql. And I'm not familiar with the "using(id)" notation. Can you point me at proper docs on it? > > So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. > But the question is my does PostgreSQL suffer so badly ?? > I think not all developers write very nice SQLs. > > Its really sad to see that a fine peice of work (RT) is performing sub-optimal > becoz of malformed SQLs. [ specially on database of my choice ;-) ] Can you try using SearchBuilder 0.90? That made certain optimizations to the postgres query builder that got backed out in 0.92, due to a possible really bad failure mode. Thankfully, because all of this is machine generated SQL we can just improve the generator, rather than having to retool the entire application. -- jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 "If IBM _wanted_ to make clones, we could make them cheaper and faster than anyone else!" - An IBM Rep. visiting Vassar College's Comp Sci Department. From pgsql-performance-owner@postgresql.org Wed Oct 29 16:04: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 2F573D1B503 for ; Wed, 29 Oct 2003 20: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 87946-09 for ; Wed, 29 Oct 2003 16:04:00 -0400 (AST) Received: from perrin.nxad.com (internal.nxad.com [69.1.70.251]) by svr1.postgresql.org (Postfix) with ESMTP id 1CFAFD1B50D for ; Wed, 29 Oct 2003 16:03:59 -0400 (AST) Received: by perrin.nxad.com (Postfix, from userid 1001) id 7005721066; Wed, 29 Oct 2003 12:03:44 -0800 (PST) Date: Wed, 29 Oct 2003 12:03:44 -0800 From: Sean Chittenden To: mallah@trade-india.com Cc: pgsql-performance@postgresql.org, jesse@fsck.com Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) Message-ID: <20031029200344.GA36028@perrin.nxad.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 3849 3760 1AFE 7B17 11A0 83A6 DD99 E31F BC84 B341 X-Web-Homepage: http://sean.chittenden.org/ User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/728 X-Sequence-Number: 4476 > So its not just PostgreSQL that is suffering from the bad SQL but > MySQL also. But the question is my does PostgreSQL suffer so badly > ?? I think not all developers write very nice SQLs. > > Its really sad to see that a fine peice of work (RT) is performing > sub-optimal becoz of malformed SQLs. [ specially on database of my > choice ;-) ] Post EXPLAIN ANALYZES of the queries you're running, then maybe you'll be able to get some useful help from this list. Until then, it's very hard to speculate as to why PostgreSQL is slower. -sc -- Sean Chittenden From pgsql-performance-owner@postgresql.org Wed Oct 29 16:17: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 87323D1B509 for ; Wed, 29 Oct 2003 20:17: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 90058-03 for ; Wed, 29 Oct 2003 16:16:51 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id BFC82D1B4F1 for ; Wed, 29 Oct 2003 16:16:49 -0400 (AST) Received: (qmail 23486 invoked from network); 29 Oct 2003 20:18:43 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 20:18:43 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 01:48:43 +0530 (IST) Message-ID: <33338.203.145.130.142.1067458723.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 01:48:43 +0530 (IST) Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) From: To: In-Reply-To: <20031029195115.GX7337@pallas.fsck.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> <20031029195115.GX7337@pallas.fsck.com> 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: 200310/729 X-Sequence-Number: 4477 > > > > On Thu, Oct 30, 2003 at 01:15:44AM +0530, mallah@trade-india.com wrote: >> Actually PostgreSQL is at par with MySQL when the query is being Properly Written(simplified) >> >> In mysql: >> mysql> SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join >> ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) > > Interesting, last time I looked, this syntax wasn't valid on mysql. And I'm not familiar with > the "using(id)" notation. Can you point me at proper docs on it? I am using MySQL 4.0.16 the latest stable one. Docs MySQL: http://www.mysql.com/doc/en/JOIN.html Postgresql: well i am not able to point out a dedicated page for this topic in pgsql document but below covers it a bit. http://www.postgresql.org/docs/7.3/static/sql-select.html Join i beleive are SQL standard feature and better docs shud exist. > > >> >> So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. But the question >> is my does PostgreSQL suffer so badly ?? >> I think not all developers write very nice SQLs. >> >> Its really sad to see that a fine peice of work (RT) is performing sub-optimal becoz of >> malformed SQLs. [ specially on database of my choice ;-) ] > > Can you try using SearchBuilder 0.90? That made certain optimizations to the postgres query > builder that got backed out in 0.92, due to a > possible really bad failure mode. Thankfully, because all of this is machine generated SQL we > can just improve the generator, rather than having to retool the entire application. True, Its really a pleasure to see that in DBIx/SearchBuilder/Handle/Pg.pm Database Specific optimisations can be done easily Congratulations on writing SearchBuilder in such an well structured manner. mine is .92 just going to try .90 as u are suggesting and will post back the result. > > > -- > jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com > 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 > > "If IBM _wanted_ to make clones, we could make them cheaper and faster than anyone else!" - An > IBM Rep. visiting Vassar College's Comp Sci Department. ----------------------------------------- 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 Wed Oct 29 16:21: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 7D782D1B4F4 for ; Wed, 29 Oct 2003 20:21: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 89664-06 for ; Wed, 29 Oct 2003 16:21:20 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id 82454D1B573 for ; Wed, 29 Oct 2003 16:21:17 -0400 (AST) Received: (qmail 23742 invoked from network); 29 Oct 2003 20:22:56 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 20:22:56 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 01:52:56 +0530 (IST) Message-ID: <33342.203.145.130.142.1067458976.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 01:52:56 +0530 (IST) Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) From: To: In-Reply-To: <20031029200344.GA36028@perrin.nxad.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> <20031029200344.GA36028@perrin.nxad.com> 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-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_20, CLICK_BELOW, IN_REP_TO, MISSING_MIMEOLE, MISSING_OUTLOOK_NAME, NO_REAL_NAME, REFERENCES, SEARCH_ENGINE_PROMO X-Spam-Level: X-Archive-Number: 200310/730 X-Sequence-Number: 4478 >> So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. But the >> question is my does PostgreSQL suffer so badly ?? I think not all developers write very nice >> SQLs. >> >> Its really sad to see that a fine peice of work (RT) is performing sub-optimal becoz of >> malformed SQLs. [ specially on database of my choice ;-) ] > > Post EXPLAIN ANALYZES of the queries you're running, then maybe you'll be able to get some > useful help from this list. Until then, it's very hard to speculate as to why PostgreSQL is > slower. -sc Here It is: in case they are illegeble please lemme know i will attach it as .txt files. Slower One: explain analyze SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ; Unique (cost=4744.06..4744.08 rows=1 width=81) (actual time=6774.140..6774.204 rows=5 loops=1) -> Sort (cost=4744.06..4744.07 rows=1 width=81) (actual time=6774.136..6774.145 rows=6 loops=1) Sort Key: main.name, main.id, main.description, main."domain", main."type", main.instance -> Nested Loop (cost=1788.68..4744.05 rows=1 width=81) (actual time=597.744..6774.042 rows=6 loops=1) Join Filter: (((("inner".principaltype)::text = 'Group'::text) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer".instance)::text = '6973'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer".instance)::text = '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer".instance)::text = '6973'::text) OR (("outer".instance)::text = '25'::text)) AND ((("inner".principaltype)::text = 'Group'::text) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND ((("outer"."domain")::text = 'SystemInternal'::text) OR (("outer"."domain")::text = 'UserDefined'::text) OR (("outer"."domain")::text = 'ACLEquivalence'::text) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("inner".principalid = "outer".id) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".principalid = "outer".id) OR (("outer".instance)::text = '6973'::text) OR (("outer"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".principalid = "outer".id) OR (("outer"."domain")::text = 'RT::Ticket-Role'::text) OR (("outer".instance)::text = '25'::text)) AND (("inner".principalid = "outer".id) OR (("outer".instance)::text = '6973'::text) OR (("outer".instance)::text = '25'::text)) AND (("inner".principalid = "outer".id) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("outer".id = "outer".id) OR (("outer"."type")::text = ("inner".principaltype)::text)) AND (("inner".principalid = "outer".id) OR ("outer".id = "outer".id)) AND ((("inner".principaltype)::text = 'Group'::text) OR ("outer".id = "outer".id))) -> Merge Join (cost=1788.68..4735.71 rows=1 width=85) (actual time=597.540..1340.526 rows=20153 loops=1) Merge Cond: ("outer".id = "inner".id) Join Filter: ((("inner".id = "outer".id) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR (("inner".instance)::text = '6973'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND (("inner".id = "outer".id) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner".instance)::text = '25'::text)) AND (("inner".id = "outer".id) OR (("inner".instance)::text = '6973'::text) OR (("inner".instance)::text = '25'::text)) AND ((("inner"."domain")::text = 'SystemInternal'::text) OR (("inner"."domain")::text = 'UserDefined'::text) OR (("inner"."domain")::text = 'ACLEquivalence'::text) OR ("inner".id = "outer".id))) -> Index Scan using principals_pkey on principals principals_1 (cost=0.00..2536.49 rows=82221 width=4) (actual time=0.073..248.849 rows=64626 loops=1) -> Sort (cost=1788.68..1797.99 rows=3726 width=81) (actual time=597.360..645.859 rows=20153 loops=1) Sort Key: main.id -> Index Scan using groups_domain, groups_domain, groups_domain, groups_lower_instance, groups_domain on groups main (cost=0.00..1567.66 rows=3726 width=81) (actual time=0.105..456.682 rows=20153 loops=1) Index Cond: ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) Filter: (((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR ((instance)::text = '25'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR ((instance)::text = '25'::text))) -> Index Scan using acl_objectid, acl_objecttype on acl acl_2 (cost=0.00..8.03 rows=3 width=13) (actual time=0.034..0.150 rows=6 loops=20153) Index Cond: ((objectid = 25) OR ((objecttype)::text = 'RT::System'::text)) Filter: ((((rightname)::text = 'OwnTicket'::text) OR ((rightname)::text = 'SuperUser'::text)) AND (((objecttype)::text = 'RT::Queue'::text) OR ((objecttype)::text = 'RT::System'::text))) Total runtime: 6778.888 ms BETTER ONE: explain analyze SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( ACL_2.PrincipalType = 'Group' AND ( main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') ) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType ) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ; Unique (cost=22.18..22.20 rows=1 width=81) (actual time=0.878..0.910 rows=5 loops=1) -> Sort (cost=22.18..22.19 rows=1 width=81) (actual time=0.875..0.881 rows=6 loops=1) Sort Key: main.name, main.id, main.description, main."domain", main."type", main.instance -> Nested Loop (cost=0.00..22.17 rows=1 width=81) (actual time=0.255..0.814 rows=6 loops=1) -> Nested Loop (cost=0.00..17.54 rows=1 width=85) (actual time=0.194..0.647 rows=6 loops=1) Join Filter: (((("outer".principaltype)::text = 'Group'::text) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND ((("outer".principaltype)::text = 'Group'::text) OR (("inner".instance)::text = '6973'::text) OR (("inner"."domain")::text = 'RT::Queue-Role'::text)) AND ((("outer".principaltype)::text = 'Group'::text) OR (("inner"."domain")::text = 'RT::Ticket-Role'::text) OR (("inner".instance)::text = '25'::text)) AND ((("outer".principaltype)::text = 'Group'::text) OR (("inner".instance)::text = '6973'::text) OR (("inner".instance)::text = '25'::text)) AND ((("outer".principaltype)::text = 'Group'::text) OR (("inner"."type")::text = ("outer".principaltype)::text)) AND ((("inner"."domain")::text = 'SystemInternal'::text) OR (("inner"."domain")::text = 'UserDefined'::text) OR (("inner"."domain")::text = 'ACLEquivalence'::text) OR (("inner"."type")::text = ("outer".principaltype)::text))) -> Index Scan using acl_objectid, acl_objecttype on acl acl_2 (cost=0.00..8.03 rows=3 width=13) (actual time=0.064..0.190 rows=6 loops=1) Index Cond: ((objectid = 25) OR ((objecttype)::text = 'RT::System'::text)) Filter: ((((rightname)::text = 'OwnTicket'::text) OR ((rightname)::text = 'SuperUser'::text)) AND (((objecttype)::text = 'RT::Queue'::text) OR ((objecttype)::text = 'RT::System'::text))) -> Index Scan using groups_pkey on groups main (cost=0.00..3.11 rows=1 width=81) (actual time=0.050..0.051 rows=1 loops=6) Index Cond: ("outer".principalid = main.id) Filter: (((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR (("domain")::text = 'RT::Queue-Role'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR (("domain")::text = 'RT::Ticket-Role'::text) OR ((instance)::text = '25'::text)) AND ((("domain")::text = 'SystemInternal'::text) OR (("domain")::text = 'UserDefined'::text) OR (("domain")::text = 'ACLEquivalence'::text) OR ((instance)::text = '6973'::text) OR ((instance)::text = '25'::text))) -> Index Scan using principals_pkey on principals principals_1 (cost=0.00..4.62 rows=1 width=4) (actual time=0.017..0.019 rows=1 loops=6) Index Cond: ("outer".principalid = principals_1.id) Total runtime: 1.151 ms (15 rows) > > -- > Sean Chittenden > > ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and > unsubscribe commands go 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 Wed Oct 29 16:45: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 59785D1B50D for ; Wed, 29 Oct 2003 20:45: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 88306-10 for ; Wed, 29 Oct 2003 16:45:17 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id 3DF9AD1B4F4 for ; Wed, 29 Oct 2003 16:45:15 -0400 (AST) Received: (qmail 27193 invoked from network); 29 Oct 2003 20:47:09 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 20:47:09 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 02:17:09 +0530 (IST) Message-ID: <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 02:17:09 +0530 (IST) Subject: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. From: To: In-Reply-To: <20031029202920.GZ7337@pallas.fsck.com> References: <33298.203.145.130.142.1067457626.squirrel@mail.trade-india.com> <20031029200458.GY7337@pallas.fsck.com> <33356.203.145.130.142.1067459251.squirrel@mail.trade-india.com> <20031029202920.GZ7337@pallas.fsck.com> 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: 200310/731 X-Sequence-Number: 4479 ok this time it constructs a query which puts 7.3.4 on a infinite loop but 7.4b5 is able to come out of it. since it may be of interest to the pgsql people i am Ccing it to the pgsql-performance list i hope its ok. Pgsql 7.3.4 on an endless loop: 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 But 7.4 beta5 seems to be able to handle it: 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; 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------+-------------+-------+--------+----------------+------------+-------+-------------------------+-----------------+---------------+----------+---------------+------------+--------+----------+------+---------------------+---------------------+---------------------+---------------------+---------------+---------------------+---------+---------------------+---------- 13 | 13 | 23 | ticket | 0 | 0 | 31122 | General Discussion | 0 | 0 | 0 | 0 | 0 | new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 31122 | 2001-11-22 04:19:10 | 31122 | 2001-11-22 04:19:07 | 0 6018 | 6018 | 19 | ticket | 0 | 0 | 10 | EYP Prospective Clients | 0 | 0 | 0 | 0 | 0 | new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 2002-09-11 18:29:37 | 1970-01-01 00:00:00 | 31122 | 2002-09-11 18:29:39 | 31122 | 2002-09-11 18:29:37 | 0 6336 | 6336 | 19 | ticket | 0 | 0 | 10 | EYP Prospective Clients | 0 | 0 | 0 | 0 | 0 | new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 2002-09-20 12:31:02 | 1970-01-01 00:00:00 | 31122 | 2002-09-20 12:31:09 | 31122 | 2002-09-20 12:31:02 | 0 6341 | 6341 | 19 | ticket | 0 | 0 | 10 | IP Prospective Clients | 0 | 0 | 0 | 0 | 0 | new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 2002-09-20 14:34:25 | 1970-01-01 00:00:00 | 31122 | 2002-09-20 14:34:26 | 31122 | 2002-09-20 14:34:25 | 0(4 rows) Time: 900.930 ms With The explain analyze below: 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 ( ( ( (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) (actual time=854.302..854.433 rows=4 loops=1) -> Unique (cost=582.27..582.34 rows=1 width=164) (actual time=854.297..854.418 rows=4 loops=1) -> Sort (cost=582.27..582.28 rows=1 width=164) (actual time=854.294..854.303 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=853.025..854.056 rows=8 loops=1) Hash Cond: ("outer".groupid = "inner".id) -> Nested Loop (cost=0.00..105.97 rows=21 width=4) (actual time=0.372..1.073 rows=37 loops=1) -> Index Scan using users4 on users users_4 (cost=0.00..3.99 rows=2 width=4) (actual time=0.182..0.188 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.165..0.703 rows=37 loops=1) Index Cond: (cachedgroupmembers_3.memberid = "outer".id) -> Hash (cost=476.17..476.17 rows=1 width=168) (actual time=852.267..852.267 rows=0 loops=1) -> Nested Loop (cost=0.00..476.17 rows=1 width=168) (actual time=0.684..842.401 rows=3209 loops=1) -> Nested Loop (cost=0.00..471.54 rows=1 width=168) (actual time=0.571..704.492 rows=3209 loops=1) -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=164) (actual time=0.212..87.100 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.158..0.168 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.019..0.022 rows=1 loops=3209) Index Cond: ("outer".id = principals_2.objectid) Filter: ((principaltype)::text = 'Group'::text) Total runtime: 855.472 ms (22 rows) Time: 895.739 ms rt3=# > http://backpan.cpan.org/authors/id/J/JE/JESSE/DBIx-SearchBuilder-0.90.tar.gz > > > On Thu, Oct 30, 2003 at 01:57:31AM +0530, mallah@trade-india.com wrote: >> > >> > >> > >> > On Thu, Oct 30, 2003 at 01:30:26AM +0530, mallah@trade-india.com wrote: >> >> >> >> Dear Jesse, >> >> >> >> I really want to add a Pg specific better query builder >> >> the generic one is messing with postgresql. >> > >> > I've removed the CC to ivan, to my knowledge, he has nothing to do with SB these days >> > anymore. >> > >> > >> >> i think i have to work in : >> >> DBIx/SearchBuilder/Handle/Pg.pm >> >> >> >> i hope u read my recent emails to pgsql-performance list. >> >> Yes. >> >> >> >> >> >> > And I hope you read my reply. There _is_ a postgres specific query builder. And there was a >> > bug in 0.90 that caused a possible endless loop. The bugfix disabled some of the >> > optimization. If you can tell me that 0.90 improves your performance (as it generated more >> > correct queries for pg) then we can work on just fixing the little bug. >> >> where is .90 ? i dont see it in >> >> http://www.fsck.com/pub/rt/devel/ >> >> >> regds >> mallah. >> >> >> > >> > >> > >> >> =================================================================================== # this >> >> code is all hacky and evil. but people desperately want _something_ and I'm # super tired. >> >> refactoring gratefully appreciated. >> >> =================================================================================== >> >> >> >> sub _BuildJoins { >> >> my $self = shift; >> >> my $sb = shift; >> >> my %seen_aliases; >> >> >> >> $seen_aliases{'main'} = 1; >> >> >> >> my $join_clause =$sb->{'table'} . " main " ; >> >> >> >> my @keys = ( keys %{ $sb->{'left_joins'} } ); >> >> >> >> while ( my $join = shift @keys ) { >> >> if ( $seen_aliases{ $sb->{'left_joins'}{$join}{'depends_on'} } ) { >> >> $join_clause = "(" . $join_clause; >> >> $join_clause .= $sb->{'left_joins'}{$join}{'alias_string'} . " ON ("; >> >> $join_clause .= >> >> join ( ') AND( ', values %{ $sb->{'left_joins'}{$join}{'criteria'} } ); >> >> $join_clause .= ")) "; >> >> >> >> $seen_aliases{$join} = 1; >> >> } >> >> else { >> >> push ( @keys, $join ); >> >> } >> >> >> >> } >> >> return ( >> >> join ( ", ", ($join_clause, @{ $sb->{'aliases'} }))) ; >> >> >> >> } >> >> >> >> >> >> >> >> >> >> >> >> ----------------------------------------- >> >> 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/ >> >> >> >> >> > >> > -- >> > jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com >> > 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 >> > >> > . . . when not in doubt, get in doubt. -- Old Discordian Proveb >> >> >> ----------------------------------------- >> 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/ >> >> > > -- > jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com > 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 > > . . . when not in doubt, get in doubt. -- Old Discordian Proveb ----------------------------------------- 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 Wed Oct 29 18:05: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 1B637D1B529 for ; Wed, 29 Oct 2003 22:05: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 04337-08 for ; Wed, 29 Oct 2003 18:04:32 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id B711ED1B52D for ; Wed, 29 Oct 2003 18:04: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 h9TM3kBv009602; Wed, 29 Oct 2003 15:03:46 -0700 (MST) Date: Wed, 29 Oct 2003 14:51:18 -0700 (MST) From: "scott.marlowe" To: Cc: , , Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with In-Reply-To: <33342.203.145.130.142.1067458976.squirrel@mail.trade-india.com> 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: 200310/732 X-Sequence-Number: 4480 On Thu, 30 Oct 2003 mallah@trade-india.com wrote: > >> So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. But the > >> question is my does PostgreSQL suffer so badly ?? I think not all developers write very nice > >> SQLs. > >> > >> Its really sad to see that a fine peice of work (RT) is performing sub-optimal becoz of > >> malformed SQLs. [ specially on database of my choice ;-) ] > > > > Post EXPLAIN ANALYZES of the queries you're running, then maybe you'll be able to get some > > useful help from this list. Until then, it's very hard to speculate as to why PostgreSQL is > > slower. -sc > > Here It is: > > in case they are illegeble please lemme know i will attach it as .txt > files. > > Slower One: > > explain analyze SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 > WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( > ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = > 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id = > Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( main.Domain > = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = ACL_2.PrincipalType AND main.id > = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND > ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ; Note here: Merge Join (cost=1788.68..4735.71 rows=1 width=85) (actual time=597.540..1340.526 rows=20153 loops=1) Merge Cond: ("outer".id = "inner".id) This estimate is WAY off. Are both of those fields indexed and analyzed? Have you tried upping the statistics target on those two fields? I assume they are compatible types. You might try 'set enable_mergejoin = false' and see if it does something faster here. Just a guess. From pgsql-performance-owner@postgresql.org Wed Oct 29 18:16: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 0E38FD1B559 for ; Wed, 29 Oct 2003 22:16: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 10836-03 for ; Wed, 29 Oct 2003 18:15:32 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id 7A99FD1B545 for ; Wed, 29 Oct 2003 18:15:29 -0400 (AST) Received: (qmail 9107 invoked from network); 29 Oct 2003 22:17:09 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 29 Oct 2003 22:17:09 -0000 Received: from 203.145.130.142 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 03:47:09 +0530 (IST) Message-ID: <33509.203.145.130.142.1067465829.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 03:47:09 +0530 (IST) Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) From: To: In-Reply-To: References: <33342.203.145.130.142.1067458976.squirrel@mail.trade-india.com> 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: 200310/733 X-Sequence-Number: 4481 > On Thu, 30 Oct 2003 mallah@trade-india.com wrote: > >> >> So its not just PostgreSQL that is suffering from the bad SQL but MySQL also. But the >> >> question is my does PostgreSQL suffer so badly ?? I think not all developers write very >> >> nice SQLs. >> >> >> >> Its really sad to see that a fine peice of work (RT) is performing sub-optimal becoz of >> >> malformed SQLs. [ specially on database of my choice ;-) ] >> > >> > Post EXPLAIN ANALYZES of the queries you're running, then maybe you'll be able to get some >> > useful help from this list. Until then, it's very hard to speculate as to why PostgreSQL is >> > slower. -sc >> >> Here It is: >> >> in case they are illegeble please lemme know i will attach it as .txt files. >> >> Slower One: >> >> explain analyze SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 >> WHERE ((ACL_2.RightName = 'OwnTicket')OR(ACL_2.RightName = 'SuperUser')) AND ( ( >> ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND ( main.Domain = >> 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id >> = Principals_1.id) OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR ( >> main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973) ) AND main.Type = >> ACL_2.PrincipalType AND main.id = Principals_1.id) ) AND (ACL_2.ObjectType = 'RT::System' OR >> (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25) ) ORDER BY main.Name ASC ; > > Note here: > > Merge Join > (cost=1788.68..4735.71 rows=1 width=85) > (actual time=597.540..1340.526 rows=20153 loops=1) > Merge Cond: ("outer".id = "inner".id) > > This estimate is WAY off. Are both of those fields indexed and analyzed? Yes both are primary keys. and i did vacuum full verbose analyze; Have you tried > upping the statistics target on those two fields? > I assume they are compatible types. Yes they are > > You might try 'set enable_mergejoin = false' and see if it does something faster here. Just a > guess. Did not help regds mallah. ----------------------------------------- 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 Wed Oct 29 18:27: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 910CDD1B55D for ; Wed, 29 Oct 2003 22:27: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 09587-06 for ; Wed, 29 Oct 2003 18:26:51 -0400 (AST) Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) by svr1.postgresql.org (Postfix) with ESMTP id 18D48D1B559 for ; Wed, 29 Oct 2003 18:26:48 -0400 (AST) Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) by mail.osdl.org (8.11.6/8.11.6) with ESMTP id h9TMQEC26620; Wed, 29 Oct 2003 14:26:15 -0800 Message-Id: <200310292226.h9TMQEC26620@mail.osdl.org> Date: Wed, 29 Oct 2003 14:26:11 -0800 (PST) From: markw@osdl.org Subject: Re: analyzing postgresql performance for dbt-2 To: pgman@candle.pha.pa.us Cc: pgsql-performance@postgresql.org, osdldbt-general@lists.sourceforge.net In-Reply-To: <200310260436.h9Q4a9f09899@candle.pha.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: 200310/734 X-Sequence-Number: 4482 I've done a better controlled series of tests where I restore the database before each test and have grabbed sar and oprofile data: http://developer.osdl.org/markw/dbt2-pgsql/176/ - load of 100 warehouses - metric 1234.52 http://developer.osdl.org/markw/dbt2-pgsql/177/ - load of 120 warehouses - metric 1259.43 http://developer.osdl.org/markw/dbt2-pgsql/178/ - load of 140 warehouses - metric 1244.33 For the most part our primary metric, and the vmstat and sar output look fairly close for each run. Here are a couple of things that I've found to be considerably different from run 176 to 178: - oprofile says postgresql calls to SearchCatCache increased ~ 20% - readprofile says there are 50% more calls in the linux kernel to do_signaction (in kernel/signal.c) Would these two things offer any insight to what might be throttling the throughput? Thanks, Mark From pgsql-performance-owner@postgresql.org Wed Oct 29 20:16: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 D79C1D1B4E8 for ; Thu, 30 Oct 2003 00:16: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 29253-04 for ; Wed, 29 Oct 2003 20:15:36 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 4E68BD1B503 for ; Wed, 29 Oct 2003 20:15:33 -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 h9U0FWNu012960 for ; Thu, 30 Oct 2003 00:15:32 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9U09xtm011798 for pgsql-performance@postgresql.org; Thu, 30 Oct 2003 00:09:59 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) Date: Wed, 29 Oct 2003 18:17:26 -0500 Organization: Hub.Org Networking Services Lines: 13 Message-ID: <601xsviqgp.fsf@dev6.int.libertyrms.info> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> 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:mXYtn6jo9Dn9URaaNGdw3CtkE88= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/738 X-Sequence-Number: 4486 mallah@trade-india.com writes: > I really not intend to start a flame war here but i am genuinely > seeking help to retain PostgreSQL as my database for my RT system. If there are things that can be discovered to feed back to the RT developers to improve PostgreSQL's usefulness as a data store for RT, that would be a Good Thing for anyone that would be interested in using PG+RT. -- output = reverse("ofni.smrytrebil" "@" "enworbbc") Christopher Browne (416) 646 3304 x124 (land) From pgsql-performance-owner@postgresql.org Wed Oct 29 19:23: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 F0FDAD1B4E8 for ; Wed, 29 Oct 2003 23:23: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 26407-03 for ; Wed, 29 Oct 2003 19:23:08 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 02C27D1B56A for ; Wed, 29 Oct 2003 19:23: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 h9TNN7it023781; Wed, 29 Oct 2003 18:23:07 -0500 (EST) To: mallah@trade-india.com Cc: pgsql-performance@postgresql.org, jesse@fsck.com Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) In-reply-to: <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> Comments: In-reply-to message dated "Thu, 30 Oct 2003 01:15:44 +0530" Date: Wed, 29 Oct 2003 18:23:07 -0500 Message-ID: <23780.1067469787@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/735 X-Sequence-Number: 4483 writes: > Actually PostgreSQL is at par with MySQL when the query is being > Properly Written(simplified) These are not the same query, though. Your original looks like SELECT DISTINCT main.* FROM Groups main , Principals Principals_1, ACL ACL_2 WHERE ((ACL_2.RightName = 'OwnTicket') OR (ACL_2.RightName = 'SuperUser')) AND ((ACL_2.PrincipalId = Principals_1.id AND ACL_2.PrincipalType = 'Group' AND (main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence') AND main.id = Principals_1.id) OR (((main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR (main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973)) AND main.Type = ACL_2.PrincipalType AND main.id = Principals_1.id)) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25)) ORDER BY main.Name ASC where the replacement is SELECT DISTINCT main.* FROM Groups main join Principals Principals_1 using(id) join ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) WHERE ((ACL_2.RightName = 'OwnTicket') OR (ACL_2.RightName = 'SuperUser')) AND ((ACL_2.PrincipalType = 'Group' AND (main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR main.Domain = 'ACLEquivalence')) OR (((main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR (main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973)) AND main.Type = ACL_2.PrincipalType)) AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25)) ORDER BY main.Name ASC ; You have made the condition "ACL_2.PrincipalId = Principals_1.id" required for all cases, where before it appeared in only one arm of an OR condition. If the second query is correct, then the first one is wrong, and your real problem is that your SQL generator is broken. (I'd argue that the SQL generator is broken anyway ;-) if it generates such horrible conditions as that. Or maybe the real problem is that the database schema is a mess and needs rethinking.) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 29 19:33: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 1EBCDD1B575 for ; Wed, 29 Oct 2003 23:33: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 18844-10 for ; Wed, 29 Oct 2003 19:32:34 -0400 (AST) Received: from jump.bivio.com (jump.bivio.com [216.87.82.232]) by svr1.postgresql.org (Postfix) with ESMTP id D3333D1B56A for ; Wed, 29 Oct 2003 19:32:30 -0400 (AST) Received: (from nagler@localhost) by jump.bivio.com (8.11.6/8.11.6) id h9TNWIa08744; Wed, 29 Oct 2003 16:32:18 -0700 X-Authentication-Warning: jump.bivio.com: nagler set sender to nagler@bivio.biz using -f From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16288.19970.172547.319577@jump.bivio.com> Date: Wed, 29 Oct 2003 16:32:18 -0700 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <87d6ciy3bf.fsf@stark.dyndns.tv> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> <16285.17811.994000.543635@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> X-Mailer: VM 6.96 under Emacs 20.7.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/736 X-Sequence-Number: 4484 Greg Stark writes: > > > SELECT a, (SELECT name FROM t2 WHERE t2.f2 = t1.f2) > > > FROM t1 > > > GROUP BY f2 > > > > This doesn't solve the problem. It's the GROUP BY that is doing the > > wrong thing. It's grouping, then aggregating. > > But at least in the form above it will consider using an index on f2, and it > will consider using indexes on t1 and t2 to do the join. There are 20 rows in t2, so an index actually slows down the join. I had to drop the index on t1.f2, because it was trying to use it instead of simply sorting 20 rows. I've got preliminary results for a number of "hard" queries between oracle and postgres (seconds): PG ORA 0 5 q1 1 0 q2 0 5 q3 2 1 q4 219 7 q5 217 5 q6 79 2 q7 31 1 q8 These are averages of 10 runs of each query. I didn't optimize pctfree, etc., but I did run analyze after the oracle import. One of the reason postgres is faster on the q1-4 is that postgres supports OFFSET/LIMIT, and oracle doesn't. q7 and q8 are the queries that I've referred to recently (avg of group by). q5 and q6 are too complex to discuss here, but the fundamental issue is the order in which postgres decides to do things. The choice for me is clear: the developer time trying to figure out how to make the planner do the "obviously right thing" has been too high with postgres. These tests demonstate to me that for even complex queries, oracle wins for our problem. It looks like we'll be migrating to oracle for this project from these preliminary results. It's not just the planner problems. The customer is more familiar with oracle, and the vacuum performance is another problem. Rob From pgsql-performance-owner@postgresql.org Wed Oct 29 20:03: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 C2853D1B55F for ; Thu, 30 Oct 2003 00:03: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 29587-01 for ; Wed, 29 Oct 2003 20:03:19 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id B12EDD1B544 for ; Wed, 29 Oct 2003 20:03:16 -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 h9U03Iit024019; Wed, 29 Oct 2003 19:03:18 -0500 (EST) To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-reply-to: <16288.19970.172547.319577@jump.bivio.com> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> <16285.17811.994000.543635@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> Comments: In-reply-to Rob Nagler message dated "Wed, 29 Oct 2003 16:32:18 -0700" Date: Wed, 29 Oct 2003 19:03:18 -0500 Message-ID: <24018.1067472198@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/737 X-Sequence-Number: 4485 Rob Nagler writes: > q5 and q6 are too complex to discuss here, How do you expect us to get better if you don't show us the problems? BTW, have you tried any of this with a 7.4beta release? Another project that I'm aware of saw several bottlenecks in their Oracle-centric code go away when they tested 7.4 instead of 7.3. For instance, there is hash aggregation capability, which would probably solve the aggregate query problem you were complaining about in http://archives.postgresql.org/pgsql-performance/2003-10/msg00640.php regards, tom lane From pgsql-performance-owner@postgresql.org Wed Oct 29 20:58: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 0EBEED1B4F1 for ; Thu, 30 Oct 2003 00:58: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 35832-10 for ; Wed, 29 Oct 2003 20:57:32 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 0013FD1B4E4 for ; Wed, 29 Oct 2003 20:57:28 -0400 (AST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3842102; Wed, 29 Oct 2003 16:58:12 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Rob Nagler , pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Wed, 29 Oct 2003 16:55:07 -0800 User-Agent: KMail/1.4.3 References: <16272.318.870000.93584@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> In-Reply-To: <16288.19970.172547.319577@jump.bivio.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310291655.07363.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/739 X-Sequence-Number: 4487 Rob, > q5 and q6 are too complex to discuss here, but the fundamental issue > is the order in which postgres decides to do things. The choice for > me is clear: the developer time trying to figure out how to make the > planner do the "obviously right thing" has been too high with > postgres. These tests demonstate to me that for even complex queries, > oracle wins for our problem. >=20 > It looks like we'll be migrating to oracle for this project from these > preliminary results. It's not just the planner problems. The > customer is more familiar with oracle, and the vacuum performance is > another problem. Hey, we can't win 'em all. If we could, Larry would be circulating his=20 resume'. I hope that you'll stay current with PostgreSQL developments so that you ca= n=20 do a similarly thourough evaluation for your next project. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Oct 29 23:45: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 51EB0D1B4E5 for ; Thu, 30 Oct 2003 03:45: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 67366-02 for ; Wed, 29 Oct 2003 23:45:05 -0400 (AST) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id 2DC31D1B570 for ; Wed, 29 Oct 2003 23:44:59 -0400 (AST) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9U3ish0001786 for ; Thu, 30 Oct 2003 11:44:57 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9U3isJT025373 for ; Thu, 30 Oct 2003 11:44:54 +0800 (SGT) Subject: Postgresql vs OS compatibility matrix To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Thu, 30 Oct 2003 11:45:00 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/30/2003 11:45:01 AM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/740 X-Sequence-Number: 4488 Hi We installed our Postgresql package from the RH CDROM v9. The version is v7.3.2 Is there a compatibility matrix for Postgresql vs OS that I can verify? I have checked the ftp sites for Postgresql software under the binary/RPMS folder and discovered that v7.3.2 is not available for redhat 9.0 Only v7.3.3 and above is available for redhat 9.0 Thank you, REgards. From pgsql-performance-owner@postgresql.org Thu Oct 30 00:08: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 A8651D1B4E8 for ; Thu, 30 Oct 2003 04:08: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 67283-07 for ; Thu, 30 Oct 2003 00:08:01 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id A11E0D1B500 for ; Thu, 30 Oct 2003 00:08:00 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id C5EB036B2F; Wed, 29 Oct 2003 23:07:59 -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 1AF46J-0001sl-00; Wed, 29 Oct 2003 23:07:59 -0500 To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> <16285.17811.994000.543635@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> In-Reply-To: <16288.19970.172547.319577@jump.bivio.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 29 Oct 2003 23:07:59 -0500 Message-ID: <87d6cffjvk.fsf@stark.dyndns.tv> Lines: 28 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: 200310/741 X-Sequence-Number: 4489 Rob Nagler writes: > One of the reason postgres is faster on the q1-4 is that postgres > supports OFFSET/LIMIT, and oracle doesn't. q7 and q8 are the queries > that I've referred to recently (avg of group by). Well the way to do offset/limit in Oracle is: SELECT * FROM ( SELECT ... , rownum AS n WHERE rownum <= OFFSET+LIMIT ) WHERE n > OFFSET That's basically the same thing Postgres does anyways. It actually has to do the complete query and fetch and discard the records up to the OFFSET and then stop when it hits the LIMIT. > q5 and q6 are too complex to discuss here, but the fundamental issue > is the order in which postgres decides to do things. That true for pretty 99% of all query optimization whether it's on Postgres or Oracle. I'm rather curious to see the query and explain analyze output from q5 and q6. -- greg From pgsql-performance-owner@postgresql.org Thu Oct 30 00:14: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 C5DD1D1B4E5 for ; Thu, 30 Oct 2003 04:14: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 67305-07 for ; Thu, 30 Oct 2003 00:14:11 -0400 (AST) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id E9BC2D1B4E8 for ; Thu, 30 Oct 2003 00:14:09 -0400 (AST) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9U4E6h0003113 for ; Thu, 30 Oct 2003 12:14:08 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9U4E6JT026988 for ; Thu, 30 Oct 2003 12:14:06 +0800 (SGT) Subject: Duplicate user in pg_shadow To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Thu, 30 Oct 2003 12:14:12 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/30/2003 12:14:13 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/742 X-Sequence-Number: 4490 Hi When I do a SELECT * FROM pg_shadow, I can have more than one user with the same id. This caused the pg_dump to fail. I read that it happened in v7.1.2 and I am currently using v7.3.2 on Redhat v9.0 What can be the causes and how do we rectify it? Thank you, REgards. From pgsql-performance-owner@postgresql.org Thu Oct 30 00:21: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 02719D1B500 for ; Thu, 30 Oct 2003 04:20: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 68336-05 for ; Thu, 30 Oct 2003 00:20:00 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 3998FD1B4ED for ; Thu, 30 Oct 2003 00:20:00 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id F194436B2F; Wed, 29 Oct 2003 23:19:58 -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 1AF4Hu-0001tu-00; Wed, 29 Oct 2003 23:19:58 -0500 To: Tom Lane Cc: mallah@trade-india.com, pgsql-performance@postgresql.org, jesse@fsck.com Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> <23780.1067469787@sss.pgh.pa.us> In-Reply-To: <23780.1067469787@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 29 Oct 2003 23:19:58 -0500 Message-ID: <877k2nfjbl.fsf@stark.dyndns.tv> Lines: 24 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: 200310/744 X-Sequence-Number: 4492 Tom Lane writes: > (I'd argue that the SQL generator is broken anyway ;-) if it generates > such horrible conditions as that. Or maybe the real problem is that > the database schema is a mess and needs rethinking.) I had the same reaction when I first saw those queries. But I think the problem with the RT schema is that it needs to implement an ACL system that satisfies lots of different usage models. Some people that use it want tickets to be accessible implicitly by the opener like a bug tracking system, others want the tickets to be internal only like a network trouble ticketing system. Some people want to restrict specific operations at a fine-grain, others want to be have more sweeping acls. I've tried doing ACL systems before and they always turned into messes long before that point. I always end up pushing back and trying to force the client to make up his or her mind of exactly what he or she needs before my head explodes . If there's a nice general model for ACLs that can include completely different usage models I've never found it. -- greg From pgsql-performance-owner@postgresql.org Thu Oct 30 00:19: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 5F563D1B500 for ; Thu, 30 Oct 2003 04:19: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 68344-04 for ; Thu, 30 Oct 2003 00:19:00 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 11355D1B4E8 for ; Thu, 30 Oct 2003 00:18:59 -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 h9U4IloD072358; Thu, 30 Oct 2003 12:18:47 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3FA09292.2050906@familyhealth.com.au> Date: Thu, 30 Oct 2003 12:24:50 +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: CHEWTC@ap.nec.com.sg Cc: pgsql-performance@postgresql.org Subject: Re: Duplicate user in pg_shadow 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: 200310/743 X-Sequence-Number: 4491 Maybe you could delete one of the users from the pg_shadow table, do the dump and then after the dump is restored, recreate the dropped user (and it will get a new sysid) Chris CHEWTC@ap.nec.com.sg wrote: > Hi > > When I do a SELECT * FROM pg_shadow, I can have more than one user with the same id. This caused the pg_dump to > fail. > > I read that it happened in v7.1.2 and I am currently using v7.3.2 on Redhat v9.0 > > What can be the causes and how do we rectify it? > > > > > Thank you, > REgards. > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Thu Oct 30 00:26: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 94433D1B500 for ; Thu, 30 Oct 2003 04:26: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 67366-08 for ; Thu, 30 Oct 2003 00:26:20 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9ED0ED1B4E5 for ; Thu, 30 Oct 2003 00:26:19 -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 h9U4Q6it025475; Wed, 29 Oct 2003 23:26:06 -0500 (EST) To: CHEWTC@ap.nec.com.sg Cc: pgsql-performance@postgresql.org Subject: Re: Duplicate user in pg_shadow In-reply-to: References: Comments: In-reply-to CHEWTC@ap.nec.com.sg message dated "Thu, 30 Oct 2003 12:14:12 +0800" Date: Wed, 29 Oct 2003 23:26:06 -0500 Message-ID: <25474.1067487966@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/745 X-Sequence-Number: 4493 CHEWTC@ap.nec.com.sg writes: > When I do a SELECT * FROM pg_shadow, I can have more than one user > with the same id. This caused the pg_dump to fail. > I read that it happened in v7.1.2 and I am currently using v7.3.2 This is *real* hard to believe. Versions 7.2 and later have a unique index on pg_shadow.usesysid. Are you certain the server isn't 7.1 or older? regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 30 00:27: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 E5BF9D1B500 for ; Thu, 30 Oct 2003 04:27: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 74931-04 for ; Thu, 30 Oct 2003 00:26:49 -0400 (AST) Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) by svr1.postgresql.org (Postfix) with ESMTP id D3B29D1B4FE for ; Thu, 30 Oct 2003 00:26:47 -0400 (AST) Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) by necsin-fw.nec.com.sg with ESMTP id h9U4Qbh0003468; Thu, 30 Oct 2003 12:26:40 +0800 (SGT) Received: from necsind1.nec.com.sg ([203.127.252.220]) by kato.nec.com.sg with ESMTP id h9U4QbJT027448; Thu, 30 Oct 2003 12:26:37 +0800 (SGT) Subject: Re: Duplicate user in pg_shadow To: Christopher Kings-Lynne Cc: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 Message-ID: From: CHEWTC@ap.nec.com.sg Date: Thu, 30 Oct 2003 12:26:43 +0800 X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 |February 13, 2003) at 10/30/2003 12:26:44 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/746 X-Sequence-Number: 4494 Hi I tried to delete the user from the pg_user but couldnt. This username is being duplicated so we have the same 2 records. What is the cause ? Is it due to memory or wrong configuration? Thank you, REgards. Christopher Kings-Lynne To: CHEWTC@ap.nec.com.sg Subject: Re: [PERFORM] Duplicate user in pg_shadow 30/10/2003 12:24 PM Maybe you could delete one of the users from the pg_shadow table, do the dump and then after the dump is restored, recreate the dropped user (and it will get a new sysid) Chris CHEWTC@ap.nec.com.sg wrote: > Hi > > When I do a SELECT * FROM pg_shadow, I can have more than one user with the same id. This caused the pg_dump to > fail. > > I read that it happened in v7.1.2 and I am currently using v7.3.2 on Redhat v9.0 > > What can be the causes and how do we rectify it? > > > > > Thank you, > REgards. > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Thu Oct 30 00:46: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 9F2E6D1B53F for ; Thu, 30 Oct 2003 04:46: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 67840-09 for ; Thu, 30 Oct 2003 00:45:39 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 1A9F0D1B529 for ; Thu, 30 Oct 2003 00:45:39 -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 h9U4jcNw060985 for ; Thu, 30 Oct 2003 04:45:38 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9U4aW3g059895 for pgsql-performance@postgresql.org; Thu, 30 Oct 2003 04:36:32 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Postgresql vs OS compatibility matrix Date: Wed, 29 Oct 2003 23:33:21 -0500 Organization: cbbrowne Computing Inc Lines: 28 Message-ID: References: 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:5+u7HwmfQJFb28y6tdSYj4ziCj8= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/748 X-Sequence-Number: 4496 Oops! CHEWTC@ap.nec.com.sg was seen spray-painting on a wall: > We installed our Postgresql package from the RH CDROM v9. > The version is v7.3.2 > > Is there a compatibility matrix for Postgresql vs OS that I can verify? > > I have checked the ftp sites for Postgresql software under the > binary/RPMS folder and discovered that v7.3.2 is not available for > redhat 9.0 Only v7.3.3 and above is available for redhat 9.0 The reason for minor releases is to fix substantial problems. Nobody bothered packaging 7.3.2 for RH9.0 because by the time RH9.0 was available, 7.3.3 or 7.3.4 were available, and there was therefore no point in packaging a version KNOWN TO BE DEFECTIVE when there was a version available KNOWN TO ADDRESS THOSE DEFECTS. Unless you specifically want to live with the defects remedied in 7.3.3 and 7.3.4, then you should upgrade to 7.3.4. It actually appears likely, based on recent discussions, that there will be a 7.3.5; there might be merit in going to that. -- let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; http://www3.sympatico.ca/cbbrowne/lsf.html "If you pick up a starving dog and make him prosperous, he will not bite you; that is the principal difference between a dog and a man." -- Mark Twain From pgsql-performance-owner@postgresql.org Thu Oct 30 00:32: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 9C1D4D1B4E5 for ; Thu, 30 Oct 2003 04:32: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 67305-09 for ; Thu, 30 Oct 2003 00:31:43 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id C5A2FD1B559 for ; Thu, 30 Oct 2003 00:31:41 -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 h9U4VboD072461; Thu, 30 Oct 2003 12:31:37 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3FA09595.5020905@familyhealth.com.au> Date: Thu, 30 Oct 2003 12:37:41 +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: CHEWTC@ap.nec.com.sg Cc: pgsql-performance@postgresql.org Subject: Re: Duplicate user in pg_shadow 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: 200310/747 X-Sequence-Number: 4495 > I tried to delete the user from the pg_user but couldnt. This username is > being duplicated so we have the same 2 records. > > What is the cause ? Is it due to memory or wrong configuration? Maybe it's an index corruption issue. Try reindexing the pg_shadow table, based on the instructions here: http://www.postgresql.org/docs/7.3/static/sql-reindex.html Chris From pgsql-performance-owner@postgresql.org Thu Oct 30 00:57: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 14168D1B549 for ; Thu, 30 Oct 2003 04:57: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 68343-10 for ; Thu, 30 Oct 2003 00:56:59 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id C48ACD1B52D for ; Thu, 30 Oct 2003 00:56:58 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3842871; Wed, 29 Oct 2003 20:57:38 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: CHEWTC@ap.nec.com.sg, pgsql-performance@postgresql.org Subject: Re: Postgresql vs OS compatibility matrix Date: Wed, 29 Oct 2003 20:56:35 -0800 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310292056.35713.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/749 X-Sequence-Number: 4497 Chew, First off, this isn't the appropriate list. So if you have follow-up questions, please post them to NOVICE or GENERAL. > I have checked the ftp sites for Postgresql software under the binary/RPMS > folder and discovered that v7.3.2 is not available for redhat 9.0 > Only v7.3.3 and above is available for redhat 9.0 All versions of PostgreSQL from the last 3 years are compatible with RedHat as far as I know. However, 7.3.3 and 7.3.4 are "bug-fix" releases; they fix security problems and a few other known issues. As such, 7.3.2 is not recommended by *anyone* for *any OS*, becuase it has known sercurity, backup, and recovery issue. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 30 07:06: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 0276AD1B585 for ; Thu, 30 Oct 2003 11:06: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 23327-09 for ; Thu, 30 Oct 2003 07:05:52 -0400 (AST) Received: from rtlocal.trade-india.com (unknown [61.16.154.82]) by svr1.postgresql.org (Postfix) with SMTP id 05B44D1B561 for ; Thu, 30 Oct 2003 07:05:48 -0400 (AST) Received: (qmail 1624 invoked from network); 30 Oct 2003 11:22:25 -0000 Received: from unknown (HELO trade-india.com) (unknown) by unknown with SMTP; 30 Oct 2003 11:22:25 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: Tom Lane Subject: Re: PostgreSQL 7.4beta5 vs MySQL 4.0.16 with RT(DBIx::SearchBuilder) Date: Thu, 30 Oct 2003 16:34:38 +0530 User-Agent: KMail/1.5.1 References: <33280.203.145.130.142.1067455363.squirrel@mail.trade-india.com> <33288.203.145.130.142.1067456744.squirrel@mail.trade-india.com> <23780.1067469787@sss.pgh.pa.us> In-Reply-To: <23780.1067469787@sss.pgh.pa.us> Cc: pgsql-performance@postgresql.org, jesse@fsck.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310301634.38136.mallah@trade-india.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/750 X-Sequence-Number: 4498 On Thursday 30 Oct 2003 4:53 am, you wrote: > writes: > > Actually PostgreSQL is at par with MySQL when the query is being > > Properly Written(simplified) > > These are not the same query, though. Your original looks like Yes that was an optimisation on haste the simplification was not accurate. I will work on it again. But incidently both the SQLs produced the same results which *may* mean that the query could have been done in a simpler manner. > > SELECT DISTINCT main.* > FROM Groups main , Principals Principals_1, ACL ACL_2 > WHERE > ((ACL_2.RightName = 'OwnTicket') OR (ACL_2.RightName = 'SuperUser')) > AND ((ACL_2.PrincipalId = Principals_1.id AND > ACL_2.PrincipalType = 'Group' AND > (main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR > main.Domain = 'ACLEquivalence') AND main.id = Principals_1.id) > OR > (((main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR > (main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973)) AND > main.Type = ACL_2.PrincipalType AND > main.id = Principals_1.id)) > AND (ACL_2.ObjectType = 'RT::System' OR > (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25)) > ORDER BY main.Name ASC > > where the replacement is > > SELECT DISTINCT main.* > FROM Groups main join Principals Principals_1 using(id) > join ACL ACL_2 on (ACL_2.PrincipalId = Principals_1.id) > WHERE > ((ACL_2.RightName = 'OwnTicket') OR (ACL_2.RightName = 'SuperUser')) > AND ((ACL_2.PrincipalType = 'Group' AND > (main.Domain = 'SystemInternal' OR main.Domain = 'UserDefined' OR > main.Domain = 'ACLEquivalence')) OR > (((main.Domain = 'RT::Queue-Role' AND main.Instance = 25) OR > (main.Domain = 'RT::Ticket-Role' AND main.Instance = 6973)) AND > main.Type = ACL_2.PrincipalType)) > AND (ACL_2.ObjectType = 'RT::System' OR > (ACL_2.ObjectType = 'RT::Queue' AND ACL_2.ObjectId = 25)) > ORDER BY main.Name ASC ; > > You have made the condition "ACL_2.PrincipalId = Principals_1.id" > required for all cases, where before it appeared in only one arm of an > OR condition. If the second query is correct, then the first one is > wrong, and your real problem is that your SQL generator is broken. Yes the SQL generator is not doing the best things at the moment and the author(Jesse) is aware of it and looking forward to our help in optimising it. > > (I'd argue that the SQL generator is broken anyway ;-) if it generates > such horrible conditions as that. Or maybe the real problem is that > the database schema is a mess and needs rethinking.) I do not think the database schema is a mess. The ACL system in RT and RT itself is quite comprehensive. The problem is with the Query Generator. Apologies for delayed response to your email. Regards Mallah. > > regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 30 07:33: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 E8B87D1B559 for ; Thu, 30 Oct 2003 11:33: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 36574-02 for ; Thu, 30 Oct 2003 07:32:54 -0400 (AST) Received: from rtlocal.trade-india.com (unknown [61.16.154.82]) by svr1.postgresql.org (Postfix) with SMTP id 0A611D1B538 for ; Thu, 30 Oct 2003 07:32:48 -0400 (AST) Received: (qmail 1810 invoked from network); 30 Oct 2003 11:49:47 -0000 Received: from unknown (HELO trade-india.com) (unknown) by unknown with SMTP; 30 Oct 2003 11:49:47 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ] Date: Thu, 30 Oct 2003 17:02:00 +0530 User-Agent: KMail/1.5.1 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> In-Reply-To: <33402.203.145.130.142.1067460429.squirrel@mail.trade-india.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310301702.00275.mallah@trade-india.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/751 X-Sequence-Number: 4499 Dear Tom, 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%. Query: I have tried my best to indent it :) 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 On Thursday 30 Oct 2003 2:17 am, mallah@trade-india.com wrote: > ok this time it constructs a query which puts 7.3.4 on a infinite loop > but 7.4b5 is able to come out of it. > > since it may be of interest to the pgsql people i am Ccing it to the > pgsql-performance list i hope its ok. > > > > Pgsql 7.3.4 on an endless loop: > > 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 > > > But 7.4 beta5 seems to be able to handle it: > > 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; 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------+-------------+-------+--------+----------------+------------ >+-------+-------------------------+-----------------+---------------+------- >---+---------------+------------+--------+----------+------+---------------- >-----+---------------------+---------------------+---------------------+---- >-----------+---------------------+---------+---------------------+---------- > 13 | 13 | 23 | ticket | 0 | 0 | 31122 | > General Discussion > > | 0 | 0 | 0 | 0 | > | 0 | new | 0 > | > | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 > | | | 1970-01-01 00:00:00 > | > | 31122 | 2001-11-22 04:19:10 | 31122 | 2001-11-22 04:19:07 | > | 0 6018 | 6018 | 19 | ticket | 0 | > | 0 | 10 | EYP Prospective > > Clients | 0 | 0 | 0 | 0 | > 0 | new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | > 2002-09-11 18:29:37 | 1970-01-01 00:00:00 | 31122 | 2002-09-11 > 18:29:39 | 31122 | 2002-09-11 18:29:37 | 0 6336 | 6336 | > 19 | ticket | 0 | 0 | 10 | EYP Prospective Clients > | 0 | 0 | 0 | 0 | 0 | > new | 0 | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 2002-09-20 > 12:31:02 | 1970-01-01 00:00:00 | 31122 | 2002-09-20 12:31:09 | > 31122 | 2002-09-20 12:31:02 | 0 6341 | 6341 | 19 | ticket > | 0 | 0 | 10 | IP Prospective Clients | > 0 | 0 | 0 | 0 | 0 | new | 0 > | | 1970-01-01 00:00:00 | 1970-01-01 00:00:00 | 2002-09-20 14:34:25 | > 1970-01-01 00:00:00 | 31122 | 2002-09-20 14:34:26 | 31122 | > 2002-09-20 14:34:25 | 0(4 rows) > > Time: 900.930 ms > > > > With The explain analyze below: > > 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 ( ( ( (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) (actual time=854.302..854.433 rows=4 loops=1) -> Unique > (cost=582.27..582.34 rows=1 width=164) (actual time=854.297..854.418 rows=4 > loops=1) -> Sort (cost=582.27..582.28 rows=1 width=164) (actual > time=854.294..854.303 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=853.025..854.056 rows=8 loops=1) Hash Cond: > ("outer".groupid = "inner".id) -> Nested Loop (cost=0.00..105.97 rows=21 > width=4) (actual time=0.372..1.073 rows=37 loops=1) > -> Index Scan using users4 on users users_4 (cost=0.00..3.99 rows=2 > width=4) (actual time=0.182..0.188 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.165..0.703 rows=37 loops=1) Index > Cond: (cachedgroupmembers_3.memberid = "outer".id) -> Hash > (cost=476.17..476.17 rows=1 width=168) (actual time=852.267..852.267 rows=0 > loops=1) -> Nested Loop (cost=0.00..476.17 > rows=1 width=168) (actual time=0.684..842.401 rows=3209 loops=1) > -> Nested Loop (cost=0.00..471.54 rows=1 width=168) > (actual time=0.571..704.492 rows=3209 loops=1) > -> Seq Scan on tickets main (cost=0.00..465.62 rows=1 width=164) > (actual time=0.212..87.100 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.158..0.168 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.019..0.022 rows=1 > loops=3209) Index Cond: ("outer".id = > principals_2.objectid) Filter: ((principaltype)::text = 'Group'::text) > Total runtime: 855.472 ms > (22 rows) > > Time: 895.739 ms > rt3=# > > > http://backpan.cpan.org/authors/id/J/JE/JESSE/DBIx-SearchBuilder-0.90.tar > >.gz > > > > On Thu, Oct 30, 2003 at 01:57:31AM +0530, mallah@trade-india.com wrote: > >> > On Thu, Oct 30, 2003 at 01:30:26AM +0530, mallah@trade-india.com wrote: > >> >> Dear Jesse, > >> >> > >> >> I really want to add a Pg specific better query builder > >> >> the generic one is messing with postgresql. > >> > > >> > I've removed the CC to ivan, to my knowledge, he has nothing to do > >> > with SB these days anymore. > >> > > >> >> i think i have to work in : > >> >> DBIx/SearchBuilder/Handle/Pg.pm > >> >> > >> >> i hope u read my recent emails to pgsql-performance list. > >> > >> Yes. > >> > >> > And I hope you read my reply. There _is_ a postgres specific query > >> > builder. And there was a bug in 0.90 that caused a possible endless > >> > loop. The bugfix disabled some of the optimization. If you can tell me > >> > that 0.90 improves your performance (as it generated more correct > >> > queries for pg) then we can work on just fixing the little bug. > >> > >> where is .90 ? i dont see it in > >> > >> http://www.fsck.com/pub/rt/devel/ > >> > >> > >> regds > >> mallah. > >> > >> >> ===================================================================== > >> >>============== # this code is all hacky and evil. but people > >> >> desperately want _something_ and I'm # super tired. refactoring > >> >> gratefully appreciated. > >> >> ===================================================================== > >> >>============== > >> >> > >> >> sub _BuildJoins { > >> >> my $self = shift; > >> >> my $sb = shift; > >> >> my %seen_aliases; > >> >> > >> >> $seen_aliases{'main'} = 1; > >> >> > >> >> my $join_clause =$sb->{'table'} . " main " ; > >> >> > >> >> my @keys = ( keys %{ $sb->{'left_joins'} } ); > >> >> > >> >> while ( my $join = shift @keys ) { > >> >> if ( $seen_aliases{ $sb->{'left_joins'}{$join}{'depends_on'} > >> >> } ) { $join_clause = "(" . $join_clause; > >> >> $join_clause .= > >> >> $sb->{'left_joins'}{$join}{'alias_string'} . " ON ("; $join_clause .= > >> >> join ( ') AND( ', values %{ > >> >> $sb->{'left_joins'}{$join}{'criteria'} } ); $join_clause .= ")) "; > >> >> > >> >> $seen_aliases{$join} = 1; > >> >> } > >> >> else { > >> >> push ( @keys, $join ); > >> >> } > >> >> > >> >> } > >> >> return ( > >> >> join ( ", ", ($join_clause, @{ $sb->{'aliases'} > >> >> }))) ; > >> >> > >> >> } > >> >> > >> >> > >> >> > >> >> > >> >> > >> >> ----------------------------------------- > >> >> 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/ > >> > > >> > -- > >> > jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com > >> > 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 > >> > > >> > . . . when not in doubt, get in doubt. -- Old Discordian Proveb > >> > >> ----------------------------------------- > >> 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/ > > > > -- > > jesse reed vincent -- root@eruditorum.org -- jesse@fsck.com > > 70EBAC90: 2A07 FC22 7DB4 42C1 9D71 0108 41A3 3FB3 70EB AC90 > > > > . . . when not in doubt, get in doubt. -- Old Discordian Proveb > > ----------------------------------------- > 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/ > > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Thu Oct 30 07:35: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 512C2D1B523 for ; Thu, 30 Oct 2003 11:35: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 40120-01 for ; Thu, 30 Oct 2003 07:34:34 -0400 (AST) Received: from omikron.sk (cepr.nustep.sk [81.0.222.49]) by svr1.postgresql.org (Postfix) with SMTP id B625ED1B51A for ; Thu, 30 Oct 2003 07:34:29 -0400 (AST) Received: (qmail 22527 invoked from network); 30 Oct 2003 11:34:15 -0000 Received: from nustep.casablanca.sk (HELO stratos) (81.0.208.19) by 0 with SMTP; 30 Oct 2003 11:34:15 -0000 Message-ID: <022001c39ed9$bfb09b20$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: Thu, 30 Oct 2003 12:34:15 +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-Archive-Number: 200310/752 X-Sequence-Number: 4500 Are you seeing this question as totally off-topic in this list, or there is really no one who knows something about indexing "is null" bits in postgres? Regards CH > Hi, > > suppose, for simplicity, there is a table with index like this: > > create table TABLE1 ( > A integer > ); > create index TABLE1_A on TABLE1 (A); > > My question is: why psql (7.3.3) does not use index when filtering by A IS > NULL, A IS NOT > NULL expressions? > > In fact, I need to filter by expression ((A is null) or (A > const)). > > Is there a way to filter by this expression using index? > > Functional index cannot be used (except strange solution with CASE-ing and > converting NULL values into some integer constant) > > > > -------------------------------------------------------------------------- -- > -- > Index Scan using table1_a on table1 (cost=0.00..437.14 rows=29164 width=4) > Index Cond: (a > 1000) > -------------------------------------------------------------------------- -- > -- > Seq Scan on table1 (cost=0.00..448.22 rows=1 width=4) > Filter: (a IS NULL) > -------------------------------------------------------- > Seq Scan on table1 (cost=0.00..448.22 rows=30222 width=4) > Filter: (a IS NOT NULL) > ------------------------------------------------------------ > Seq Scan on table1 (cost=0.00..523.77 rows=29164 width=4) > Filter: ((a IS NULL) OR (a > 1000)) > ------------------------------------------------------------ > > > CH From pgsql-performance-owner@postgresql.org Thu Oct 30 09:16: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 2159AD1B549 for ; Thu, 30 Oct 2003 13:16: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 41740-09 for ; Thu, 30 Oct 2003 09:15:42 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 79833D1B514 for ; Thu, 30 Oct 2003 09:15:39 -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 h9UDFdNu040499 for ; Thu, 30 Oct 2003 13:15:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9UCqbT8036040 for pgsql-performance@postgresql.org; Thu, 30 Oct 2003 12:52:37 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ] Date: Thu, 30 Oct 2003 07:52:28 -0500 Organization: cbbrowne Computing Inc Lines: 25 Message-ID: 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> 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:5vv4YchUK+Al632gR+aykFsN370= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/753 X-Sequence-Number: 4501 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. -- wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). http://www3.sympatico.ca/cbbrowne/lsf.html Rules of the Evil Overlord #81. "If I am fighting with the hero atop a moving platform, have disarmed him, and am about to finish him off and he glances behind me and drops flat, I too will drop flat instead of quizzically turning around to find out what he saw." From pgsql-performance-owner@postgresql.org Thu Oct 30 09:57: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 07589D1B592 for ; Thu, 30 Oct 2003 13:57: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 60290-02 for ; Thu, 30 Oct 2003 09:56:56 -0400 (AST) Received: from lucifer.oficina (unknown [200.69.203.237]) by svr1.postgresql.org (Postfix) with ESMTP id C2026D1B57C for ; Thu, 30 Oct 2003 09:56:50 -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 h9UDuTrl013443; Thu, 30 Oct 2003 10:56:29 -0300 (ART) (envelope-from franco@akyasociados.com.ar) Subject: Re: Ignoring index on (A is null), (A is not null) From: Franco Bruno Borghesi To: Cestmir Hybl Cc: pgsql-performance@postgresql.org In-Reply-To: <022001c39ed9$bfb09b20$0200a8c0@stratos> References: <017201c39d85$533eed70$0200a8c0@stratos> <022001c39ed9$bfb09b20$0200a8c0@stratos> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-8zkkx1U5saUbh5mb/a4l" Organization: AK y Asociados S.R.L. Message-Id: <1067522189.781.14.camel@taz> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.4 Date: Thu, 30 Oct 2003 10:56:29 -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: 200310/754 X-Sequence-Number: 4502 --=-8zkkx1U5saUbh5mb/a4l Content-Type: multipart/alternative; boundary="=-SEiTixuZx7WWUudUILjA" --=-SEiTixuZx7WWUudUILjA Content-Type: text/plain Content-Transfer-Encoding: quoted-printable try this: EXPLAIN [ANALYZE] SELECT a FROM table1 WHERE a IS NULL OR a>2; SET enable_seqscan TO off; EXPLAIN [ANALYZE] SELECT a FROM table1 WHERE a IS NULL OR a>2; =20 and compare the costs and times of both executions. This will tell you why postgresql is not using an index. For example, if you have 1000 rows in your table, they will fit in only one page of the table, so postgresql will (correctly) think that fetching and procesing this only page will be faster than fetching the index page, procesing it, and fetching and procesing the table page. Or perhaps there are so many rows that match your condition, that postgresql realizes that using and index or not it will still have to visit almost every page in the table. Many things can cause postgresql to think that a seqscan is better than an indexscan, If after comparing the EXPLAINs you see that postgresql is wrong, you should tweak your postgresql.conf (for example the cpu_index_tuple_cost value). hope it helps. On Thu, 2003-10-30 at 08:34, Cestmir Hybl wrote: > Are you seeing this question as totally off-topic in this list, or there = is > really no one who knows something about indexing "is null" bits in postgr= es? >=20 > Regards > CH >=20 >=20 > > Hi, > > > > suppose, for simplicity, there is a table with index like this: > > > > create table TABLE1 ( > > A integer > > ); > > create index TABLE1_A on TABLE1 (A); > > > > My question is: why psql (7.3.3) does not use index when filtering by A= IS > > NULL, A IS NOT > > NULL expressions? > > > > In fact, I need to filter by expression ((A is null) or (A > const)). > > > > Is there a way to filter by this expression using index? > > > > Functional index cannot be used (except strange solution with CASE-ing = and > > converting NULL values into some integer constant) > > > > > > > > -----------------------------------------------------------------------= --- > -- > > -- > > Index Scan using table1_a on table1 (cost=3D0.00..437.14 rows=3D29164 > width=3D4) > > Index Cond: (a > 1000) > > -----------------------------------------------------------------------= --- > -- > > -- > > Seq Scan on table1 (cost=3D0.00..448.22 rows=3D1 width=3D4) > > Filter: (a IS NULL) > > -------------------------------------------------------- > > Seq Scan on table1 (cost=3D0.00..448.22 rows=3D30222 width=3D4) > > Filter: (a IS NOT NULL) > > ------------------------------------------------------------ > > Seq Scan on table1 (cost=3D0.00..523.77 rows=3D29164 width=3D4) > > Filter: ((a IS NULL) OR (a > 1000)) > > ------------------------------------------------------------ > > > > > > CH >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? >=20 > http://www.postgresql.org/docs/faqs/FAQ.html >=20 --=-SEiTixuZx7WWUudUILjA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable try this:
EXPLAIN [ANALYZE] SELECT a FROM table1 WHERE a IS NULL OR a>2;
SET enable_seqscan TO off;
EXPLAIN [ANALYZE] SELECT a FROM table1 WHERE a IS NULL OR a>2;

and compare the costs and times of both executions. This will tell you why = postgresql is not using an index.

For example, if you have 1000 rows in your table, they will fit in only one= page of the table, so postgresql will (correctly) think that fetching and = procesing this only page will be faster than fetching the index page, proce= sing it, and fetching and procesing the table page.
Or perhaps there are so many rows that match your condition, that postgresq= l realizes that using and index or not it will still have to visit almost e= very page in the table.

Many things can cause postgresql to think that a seqscan is better than an = indexscan, If after comparing the EXPLAINs you see that postgresql is wrong= , you should tweak your postgresql.conf (for example the cpu_index_tuple_co= st value).

hope it helps.

On Thu, 2003-10-30 at 08:34, Cestmir Hybl wrote:
Are you seeing this question as totally off=
-topic in this list, or there is
really no one who knows something about indexing "is null" bits i=
n postgres?

Regards
CH


> Hi,
>
> suppose, for simplicity, there is a table with index like this:
>
> create table TABLE1 (
>   A integer
> );
> create index TABLE1_A on TABLE1 (A);
>
> My question is: why psql (7.3.3) does not use index when filtering by =
A IS
> NULL, A IS NOT
> NULL expressions?
>
> In fact, I need to filter by expression ((A is null) or (A > const)=
).
>
> Is there a way to filter by this expression using index?
>
> Functional index cannot be used (except strange solution with CASE-ing=
 and
> converting NULL values into some integer constant)
>
>
>
> ----------------------------------------------------------------------=
----
--
> --
>  Index Scan using table1_a on table1  (cost=3D0.00..437.14 rows=3D29164
width=3D4)
>    Index Cond: (a > 1000)
> ----------------------------------------------------------------------=
----
--
> --
>  Seq Scan on table1  (cost=3D0.00..448.22 rows=3D1 width=3D4)
>    Filter: (a IS NULL)
> --------------------------------------------------------
>  Seq Scan on table1  (cost=3D0.00..448.22 rows=3D30222 width=3D4)
>    Filter: (a IS NOT NULL)
> ------------------------------------------------------------
>  Seq Scan on table1  (cost=3D0.00..523.77 rows=3D29164 width=3D4)
>    Filter: ((a IS NULL) OR (a > 1000))
> ------------------------------------------------------------
>
>
> CH


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html
--=-SEiTixuZx7WWUudUILjA-- --=-8zkkx1U5saUbh5mb/a4l 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/oRiN21dVnhLsBV0RAnIuAJ42ilTVJ7z8ByTxPWuNFvPfRTp/rwCgiXuy gyH/7fInjxlt/fCJXY8F8bk= =w+UK -----END PGP SIGNATURE----- --=-8zkkx1U5saUbh5mb/a4l-- From pgsql-performance-owner@postgresql.org Thu Oct 30 10:06: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 6CF8DD1B559 for ; Thu, 30 Oct 2003 14:06: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 61665-01 for ; Thu, 30 Oct 2003 10:06:07 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id E7CC2D1B566 for ; Thu, 30 Oct 2003 10:06:02 -0400 (AST) Received: (qmail 8098 invoked by uid 500); 30 Oct 2003 14:04:06 -0000 Date: Thu, 30 Oct 2003 08:04:06 -0600 From: Bruno Wolff III To: Cestmir Hybl Cc: pgsql-performance@postgresql.org Subject: Re: Ignoring index on (A is null), (A is not null) conditions Message-ID: <20031030140406.GA7870@wolff.to> Mail-Followup-To: Cestmir Hybl , pgsql-performance@postgresql.org References: <017201c39d85$533eed70$0200a8c0@stratos> <022001c39ed9$bfb09b20$0200a8c0@stratos> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <022001c39ed9$bfb09b20$0200a8c0@stratos> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/755 X-Sequence-Number: 4503 On Thu, Oct 30, 2003 at 12:34:15 +0100, Cestmir Hybl wrote: > Are you seeing this question as totally off-topic in this list, or there is > really no one who knows something about indexing "is null" bits in postgres? There was some talk about IS NULL not being able to use indexes (unless you specifically created a partial index using that condition) a number of months ago. You could search through the archives if you are interested in what was said. My memory is that people thought it would be a good idea but that it wasn't that important to get done. > > > Hi, > > > > suppose, for simplicity, there is a table with index like this: > > > > create table TABLE1 ( > > A integer > > ); > > create index TABLE1_A on TABLE1 (A); > > > > My question is: why psql (7.3.3) does not use index when filtering by A IS > > NULL, A IS NOT > > NULL expressions? That is a Postgres limitation. If there are only a few null values, but you query for them a lot it may be worth creating a partial index. > > > > In fact, I need to filter by expression ((A is null) or (A > const)). This is a whole different matter. Using an indexed search on > is not necessarily a good idea. Unless you know only a small fraction of the table (often 10% is quoted) is greater than the constant, a sequential scan is probably a better plan than an index scan. If you know that there is only a small fraction of the values above constant and you know some large value greater than all values, you can try using a between comparison to coax the planner into doing an index scan. From pgsql-performance-owner@postgresql.org Thu Oct 30 10:10: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 BF8FED1B545 for ; Thu, 30 Oct 2003 14: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 60045-05 for ; Thu, 30 Oct 2003 10:10:12 -0400 (AST) Received: from trade-india.com (ns1.trade-india.com [66.234.10.14]) by svr1.postgresql.org (Postfix) with SMTP id 939F8D1B51A for ; Thu, 30 Oct 2003 10:10:08 -0400 (AST) Received: (qmail 11033 invoked from network); 30 Oct 2003 14:12:00 -0000 Received: from ns1.trade-india.com (HELO trade-india.com) (66.234.10.14) by ns1.trade-india.com with SMTP; 30 Oct 2003 14:12:00 -0000 Received: from 61.16.154.82 (proxying for 192.168.0.45, 61.16.154.82) (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 30 Oct 2003 19:42:00 +0530 (IST) Message-ID: <13042.61.16.154.82.1067523120.squirrel@mail.trade-india.com> Date: Thu, 30 Oct 2003 19:42:00 +0530 (IST) Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ] From: To: In-Reply-To: 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> 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: 200310/756 X-Sequence-Number: 4504 > 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. Regds Mallah. > -- > wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','acm.org'). > http://www3.sympatico.ca/cbbrowne/lsf.html > Rules of the Evil Overlord #81. "If I am fighting with the hero atop a moving platform, have > disarmed him, and am about to finish him off and he glances behind me and drops flat, I too > will drop flat instead of quizzically turning around to find out what he saw." > > > ---------------------------(end of broadcast)--------------------------- TIP 6: Have you > searched our list archives? > > http://archives.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 Thu Oct 30 10:43: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 5C607D1B544 for ; Thu, 30 Oct 2003 14:43: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 61172-06 for ; Thu, 30 Oct 2003 10:43:08 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id D64D2D1B54B for ; Thu, 30 Oct 2003 10:42:59 -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 h9UEg5Bv022438; Thu, 30 Oct 2003 07:42:17 -0700 (MST) Date: Thu, 30 Oct 2003 07:29:32 -0700 (MST) From: "scott.marlowe" To: Rob Nagler Cc: Subject: Re: vacuum locking In-Reply-To: <16288.19970.172547.319577@jump.bivio.com> 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: 200310/757 X-Sequence-Number: 4505 On Wed, 29 Oct 2003, Rob Nagler wrote: > Greg Stark writes: > > > > SELECT a, (SELECT name FROM t2 WHERE t2.f2 = t1.f2) > > > > FROM t1 > > > > GROUP BY f2 > > > > > > This doesn't solve the problem. It's the GROUP BY that is doing the > > > wrong thing. It's grouping, then aggregating. > > > > But at least in the form above it will consider using an index on f2, and it > > will consider using indexes on t1 and t2 to do the join. > > There are 20 rows in t2, so an index actually slows down the join. > I had to drop the index on t1.f2, because it was trying to use it > instead of simply sorting 20 rows. t2 was 'vacuum full'ed and analyzed, right? Just guessing. From pgsql-performance-owner@postgresql.org Thu Oct 30 11:16: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 B5887D1B559 for ; Thu, 30 Oct 2003 15:16: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 73990-01 for ; Thu, 30 Oct 2003 11:15:44 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 53E68D1B54C for ; Thu, 30 Oct 2003 11:15:40 -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 h9UFFdNw064312 for ; Thu, 30 Oct 2003 15:15:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9UFCPBv063653 for pgsql-performance@postgresql.org; Thu, 30 Oct 2003 15:12:25 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ] Date: Thu, 30 Oct 2003 10:10:47 -0500 Organization: cbbrowne Computing Inc Lines: 32 Message-ID: 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> 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:W9i3b8qbxcDaHOvSI2NO/CWlbr8= To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/758 X-Sequence-Number: 4506 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. -- "cbbrowne","@","ntlug.org" http://www3.sympatico.ca/cbbrowne/oses.html This is Linux country. On a quiet night, you can hear NT re-boot. From pgsql-performance-owner@postgresql.org Thu Oct 30 12:24: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 489D8D1B566 for ; Thu, 30 Oct 2003 15:31: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 77748-01 for ; Thu, 30 Oct 2003 11:31:29 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C6541D1B51A for ; Thu, 30 Oct 2003 11:31:24 -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 h9UFVQit028215; Thu, 30 Oct 2003 10:31:26 -0500 (EST) To: "Cestmir Hybl" Cc: pgsql-performance@postgresql.org Subject: Re: Ignoring index on (A is null), (A is not null) conditions In-reply-to: <022001c39ed9$bfb09b20$0200a8c0@stratos> References: <017201c39d85$533eed70$0200a8c0@stratos> <022001c39ed9$bfb09b20$0200a8c0@stratos> Comments: In-reply-to "Cestmir Hybl" message dated "Thu, 30 Oct 2003 12:34:15 +0100" Date: Thu, 30 Oct 2003 10:31:26 -0500 Message-ID: <28214.1067527886@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/759 X-Sequence-Number: 4507 "Cestmir Hybl" writes: >> In fact, I need to filter by expression ((A is null) or (A > const)). I wonder whether you shouldn't reconsider your data representation. Perhaps the condition you are using "null" for would be better represented by setting A to infinity. (The float and timestamp datatypes actually have a concept of infinity; for other types you can fake it with a large positive value.) regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 30 13:04: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 7C60AD1B58D for ; Thu, 30 Oct 2003 16:11: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 80963-06 for ; Thu, 30 Oct 2003 12:11:13 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id EFB2DD1B561 for ; Thu, 30 Oct 2003 12:11:12 -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 h9UGBCit028552; Thu, 30 Oct 2003 11:11:12 -0500 (EST) To: Rajesh Kumar Mallah Cc: pgsql-performance@postgresql.org Subject: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ] In-reply-to: <200310301702.00275.mallah@trade-india.com> 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> Comments: In-reply-to Rajesh Kumar Mallah message dated "Thu, 30 Oct 2003 17:02:00 +0530" Date: Thu, 30 Oct 2003 11:11:12 -0500 Message-ID: <28551.1067530272@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/762 X-Sequence-Number: 4510 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. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 30 12:37: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 788B3D1B58D for ; Thu, 30 Oct 2003 16:33: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 87202-03 for ; Thu, 30 Oct 2003 12:32:39 -0400 (AST) Received: from pass.bivio.com (pass.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 8D9D8D1B8C2 for ; Thu, 30 Oct 2003 12:32:35 -0400 (AST) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB28298 for ; Thu, 30 Oct 2003 09:32:29 -0700 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16289.14916.51000.772555@gargle.gargle.HOWL> Date: Thu, 30 Oct 2003 09:20:20 -0700 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <200310291655.07363.josh@agliodbs.com> References: <16272.318.870000.93584@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> <200310291655.07363.josh@agliodbs.com> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/760 X-Sequence-Number: 4508 Josh Berkus writes: > I hope that you'll stay current with PostgreSQL developments so that you can > do a similarly thourough evaluation for your next project. Oh, no worries. This project just happens to be a tough one. We're heavily invested in Postgres. Other projects we maintain that use Postgres are zoescore.com, colosla.org, and paintedsnapshot.com. I am currently working on a very large project where the customer is very committed to Postgres/open source. We're in discussions about what to do about the scalability problems we saw in the other project. You can help by addressing a dilema we (my new customer and I) see. I apologize for the length of what follows, but I'm trying to be as clear as possible about our situation. I have had a lot push back from the core Postgres folks on the idea of planner hints, which would go a long way to solve the performance problems we are seeing. I presented an alternative approach: have a "style sheet" (Scribe, LaTex) type of solution in the postmaster, which can be customized by end users. That got no response so I assume it wasn't in line with the "Postgres way" (more below). The vacuum problem is very serious for the problematic database to the point that one of my customer's customers said: However, I am having a hard time understanding why the system is so slow... from my perspective it seems like you have some fundamental database issues that need to be addressed. This is simply unacceptable, and that's why we're moving to Oracle. It's very bad for my business reputation. I don't have a ready solution to vacuuming, and none on the list have been effective. We'll be adding more memory, but it seems to be disk bandwidth problem. I run Oracle on much slower system, and I've never noticed problems of this kind, even when a database-wide validation is running. When vacuum is running, it's going through the entire database, and that pretty much trashes all other queries, especially DSS queries. As always it is just software, and there's got to be 80/20 solution. Our new project is large, high-profile, but not as data intensive as the problematic one. We are willing to commit significant funding and effort to make Postgres faster. We are "business value" driven. That means we solve problems practically instead of theoretically. This seems to be in conflict with "the Postgres way", which seems to be more theoretical. Our business situation comes ahead of theories. My customer (who monitors this list) and I believe that our changes would not be accepted back into the Postgres main branch. That presents us with a difficult situation, because we don't want to own a separate branch. (Xemacs helped push emacs, and maybe that's what has to happen here, yet it's not a pretty situation.) We'll be meeting next week to discuss the situation, and how we'll go forward. We have budget in 2003 to spend on this, but only if the situation can be resolved. Otherwise, we'll have to respect the data we are seeing, and think about our choice of technologies. Thanks for the feedback. Rob From pgsql-performance-owner@postgresql.org Thu Oct 30 16:41: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 EB37FD1B54F for ; Thu, 30 Oct 2003 16:59: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 89564-10 for ; Thu, 30 Oct 2003 12:59:25 -0400 (AST) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id 50900D1B587 for ; Thu, 30 Oct 2003 12:59:24 -0400 (AST) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id JAB28316; Thu, 30 Oct 2003 09:59:23 -0700 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16289.17240.68000.402231@gargle.gargle.HOWL> Date: Thu, 30 Oct 2003 09:59:04 -0700 To: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-Reply-To: <24018.1067472198@sss.pgh.pa.us> References: <16272.318.870000.93584@gargle.gargle.HOWL> <16279.4988.496000.539525@gargle.gargle.HOWL> <200310230814.56738.mweilguni@sime.com> <29123.1066915615@sss.pgh.pa.us> <16279.61590.158000.290397@gargle.gargle.HOWL> <87vfqeveab.fsf@stark.dyndns.tv> <16281.45354.209000.280418@gargle.gargle.HOWL> <878ynaupgu.fsf@stark.dyndns.tv> <16285.17811.994000.543635@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> <24018.1067472198@sss.pgh.pa.us> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/777 X-Sequence-Number: 4525 Tom Lane writes: > Rob Nagler writes: > > q5 and q6 are too complex to discuss here, > > How do you expect us to get better if you don't show us the problems? With all due respect and thanks for the massive amount of help, I have presented the problems. q5 and q6 are a subset of the following general problems: * Multiple ORDER BY results in no index used. Solution: drop multiple ORDER BY, only use first * Vacuum locks out interactive users Solution: don't run vacuum full and only run vacuum at night * Low cardinality index on large table confuses planner Solution: Drop (foreign key) index, which hurts other performance * Grouped aggregates result in disk sort Solution: Wait to 7.4 (may work), or write in Perl (works today) * Extreme non-linear performance (crossing magic number in optimizer drops performance three orders of magnitude) Solution: Don't cross magic number, or code in Perl The general problem is that our system generates 90% of the SQL we need. There are many advantages to this, such as being able to add OFFSET/LIMIT support with a few lines of code in a matter of hours. Every time we have to custom code a query, or worse, code it in Perl, we lose many benefits. I understand the need to optimize queries, but my general experience with Oracle is that I don't have to do this very often. When the 80/20 rule inverts, there's something fundamentally wrong with the model. That's where we feel we're at. It's cost us a tremendous amount of money to deal with these query optimizations. The solution is not to fix the queries, but to address the root causes. That's what my other note in this thread is about. I hope you understand the spirit of my suggestion, and work with us to finding an acceptable approach to the general problems. > BTW, have you tried any of this with a 7.4beta release? I will, but for my other projects, not this one. I'll run this data, because it's a great test case. We have a business decision to make: devote more time to Postgres or go with Oracle. I spent less than a day getting the data into Oracle and to create the benchmark. The payoff is clear, now. The risk of 7.4 is still very high, because the vacuum problem still looms and a simple "past performance is a good indicator of future performance". Going forward, there's no choice. We've had to limit end-user functionality to get Postgres working as well as it does, and that's way below where Oracle is without those same limits and without any effort put into tuning. Thanks again for all your support. Rob From pgsql-performance-owner@postgresql.org Thu Oct 30 13:32: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 AAB91D1BA80 for ; Thu, 30 Oct 2003 17:08: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 91284-03 for ; Thu, 30 Oct 2003 13:08:07 -0400 (AST) Received: from pass.bivio.com (locker.bivio.com [216.87.82.238]) by svr1.postgresql.org (Postfix) with ESMTP id D4A4FD1C9F0 for ; Thu, 30 Oct 2003 13:07:42 -0400 (AST) Received: from LIFT.bivio.com (lift.bivio.com [216.87.82.233]) by pass.bivio.com (8.9.3/8.9.3) with ESMTP id KAB28346 for ; Thu, 30 Oct 2003 10:07:42 -0700 From: Rob Nagler MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16289.17560.847000.637384@gargle.gargle.HOWL> Date: Thu, 30 Oct 2003 10:04:24 -0700 To: Subject: Re: vacuum locking In-Reply-To: References: <16288.19970.172547.319577@jump.bivio.com> X-Mailer: VM 6.96 under Emacs 21.1.1 Organization: bivio Software Artisans, Inc. X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/764 X-Sequence-Number: 4512 scott.marlowe writes: > t2 was 'vacuum full'ed and analyzed, right? Just guessing. Fresh import. I've been told this includes a ANALYZE. Rob From pgsql-performance-owner@postgresql.org Thu Oct 30 13:47: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 80244D1B566 for ; Thu, 30 Oct 2003 17:19: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 97293-03 for ; Thu, 30 Oct 2003 13:18:59 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 4DC9ED1B55D for ; Thu, 30 Oct 2003 13:18:58 -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 h9UHHoBv003037; Thu, 30 Oct 2003 10:17:54 -0700 (MST) Date: Thu, 30 Oct 2003 10:05:15 -0700 (MST) From: "scott.marlowe" To: Rob Nagler Cc: Subject: Re: vacuum locking In-Reply-To: <16289.14916.51000.772555@gargle.gargle.HOWL> 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: 200310/766 X-Sequence-Number: 4514 On Thu, 30 Oct 2003, Rob Nagler wrote: > The vacuum problem is very serious for the problematic database to the > point that one of my customer's customers said: > > However, I am having a hard time understanding why the system is so > slow... from my perspective it seems like you have some fundamental > database issues that need to be addressed. > > This is simply unacceptable, and that's why we're moving to Oracle. > It's very bad for my business reputation. > > I don't have a ready solution to vacuuming, and none on the list have > been effective. We'll be adding more memory, but it seems to be disk > bandwidth problem. I run Oracle on much slower system, and I've never > noticed problems of this kind, even when a database-wide validation is > running. When vacuum is running, it's going through the entire > database, and that pretty much trashes all other queries, especially > DSS queries. As always it is just software, and there's got to be > 80/20 solution. Have you looked at the autovacuum daemon? Was it found wanting or what? I've had good luck with it so far, so I was just wondering if it might work for your needs as well. It's quite intelligent about which tables et.al. it vacuums. From pgsql-admin-owner@postgresql.org Fri Oct 31 14:14:12 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0E078D1B897; Thu, 30 Oct 2003 17:34: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 98369-08; Thu, 30 Oct 2003 13:34:15 -0400 (AST) Received: from Worldsecure.phs.org (worldsecure.phs.org [204.134.42.5]) by svr1.postgresql.org (Postfix) with ESMTP id B2F59D1B576; Thu, 30 Oct 2003 13:34:07 -0400 (AST) Received: from 190.249.2.66 by Worldsecure.phs.org with ESMTP (PHS Messaging System); Thu, 30 Oct 2003 10:33:13 -0600 Received: by pinemail1 with Internet Mail Service (5.5.2653.19) id ; Thu, 30 Oct 2003 10:28:11 -0700 Message-ID: From: CLeon@phs.org To: linux-lvm@sistina.com, tgl@sss.pgh.pa.us Cc: threshar@torgo.978.org, josh@agliodbs.com, markw@osdl.org, pgsql-performance@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [linux-lvm] RE: [PERFORM] backup/restore - another Date: Thu, 30 Oct 2003 10:28:10 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-WSS-ID: 13BF94D317281-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/410 X-Sequence-Number: 10971 Does xfs_freeze work on red hat 7.3? Cynthia Leon -----Original Message----- From: Murthy Kambhampaty [mailto:murthy.kambhampaty@goeci.com] Sent: Friday, October 17, 2003 11:34 AM To: 'Tom Lane'; Murthy Kambhampaty Cc: 'Jeff'; Josh Berkus; markw@osdl.org; pgsql-performance@postgresql.org; linux-lvm@sistina.com; pgsql-admin@postgresql.org Subject: [linux-lvm] RE: [ADMIN] [PERFORM] backup/restore - another area. Friday, October 17, 2003 12:05, Tom Lane [mailto:tgl@sss.pgh.pa.us] wrote: >Murthy Kambhampaty writes: >> ... The script handles situations >> where (i) the XFS filesystem containing $PGDATA has an >external log and (ii) >> the postmaster log ($PGDATA/pg_xlog) is written to a >filesystem different >> than the one containing the $PGDATA folder. > >It does? How exactly can you ensure snapshot consistency between >data files and XLOG if they are on different filesystem Say, you're setup looks something like this: mount -t xfs /dev/VG1/LV_data /home/pgdata mount -t xfs /dev/VG1/LV_xlog /home/pgdata/pg_xlog When you want to take the filesystem backup, you do: Step 1: xfs_freeze -f /dev/VG1/LV_xlog xfs_freeze -f /dev/VG1/LV_data This should finish any checkpoints that were in progress, and not start any new ones till you unfreeze. (writes to an xfs_frozen filesystem wait for the xfs_freeze -u, but reads proceed; see text from xfs_freeze manpage in postcript below.) Step2: create snapshots of /dev/VG1/LV_xlog and /dev/VG1/LV_xlog Step 3: xfs_freeze -u /dev/VG1/LV_data xfs_freeze -u /dev/VG1/LV_xlog Unfreezing in this order should assure that checkpoints resume where they left off, then log writes commence. Step4: mount the snapshots taken in Step2 somewhere; e.g. /mnt/snap_data and /mnt/snap_xlog. Copy (or rsync or whatever) /mnt/snap_data to /mnt/pgbackup/ and /mnt/snap_xlog to /mnt/pgbackup/pg_xlog. Upon completion, /mnt/pgbackup/ looks to the postmaster like /home/pgdata would if the server had crashed at the moment that Step1 was initiated. As I understand it, during recovery (startup) the postmaster will roll the database forward to this point, "checkpoint-ing" all the transactions that made it into the log before the crash. Step5: remove the snapshots created in Step2. The key is (i) xfs_freeze allows you to "quiesce" any filesystem at any point in time and, if I'm not mistaken, the order (LIFO) in which you freeze and unfreeze the two filesystems: freeze $PGDATA/pg_xlog then $PGDATA; unfreeze $PGDATA then $PGDATA/pg_xlog. (ii) WAL recovery assures consistency after a (file)sytem crash. Presently, the test server for my backup scripts is set-up this way, and the backup works flawlessly, AFAICT. (Note that the backup script starts a postmaster on the filesystem copy each time, so you get early warning of problems. Moreover the data in the "production" and "backup" copies are tested and found to be identical. Comments? Any suggestions for additional tests? Thanks, Murthy PS: From the xfs_freeze manpage: "xfs_freeze suspends and resumes access to an XFS filesystem (see xfs(5)). xfs_freeze halts new access to the filesystem and creates a stable image on disk. xfs_freeze is intended to be used with volume managers and hardware RAID devices that support the creation of snapshots. The mount-point argument is the pathname of the directory where the filesystem is mounted. The filesystem must be mounted to be frozen (see mount(8)). The -f flag requests the specified XFS filesystem to be frozen from new modifications. When this is selected, all ongoing transactions in the filesystem are allowed to complete, new write system calls are halted, other calls which modify the filesystem are halted, and all dirty data, metadata, and log information are written to disk. Any process attempting to write to the frozen filesystem will block waiting for the filesystem to be unfrozen. Note that even after freezing, the on-disk filesystem can contain information on files that are still in the process of unlinking. These files will not be unlinked until the filesystem is unfrozen or a clean mount of the snapshot is complete. The -u option is used to un-freeze the filesystem and allow operations to continue. Any filesystem modifications that were blocked by the freeze are unblocked and allowed to complete." _______________________________________________ linux-lvm mailing list linux-lvm@sistina.com http://lists.sistina.com/mailman/listinfo/linux-lvm read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/ ============================================================================== --- PRESBYTERIAN HEALTHCARE SERVICES DISCLAIMER --- This message originates from Presbyterian Healthcare Services or one of its affiliated organizations. It contains information, which may be confidential or privileged, and is intended only for the individual or entity named above. It is prohibited for anyone else to disclose, copy, distribute or use the contents of this message. All personal messages express views solely of the sender, which are not to be attributed to Presbyterian Healthcare Services or any of its affiliated organizations, and may not be distributed without this disclaimer. If you received this message in error, please notify us immediately at postmaster@phs.org. ============================================================================== From pgsql-performance-owner@postgresql.org Thu Oct 30 13:44:55 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 60119D1B55D for ; Thu, 30 Oct 2003 17:29: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 97293-06 for ; Thu, 30 Oct 2003 13:28:49 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id D1D6DD1B57E for ; Thu, 30 Oct 2003 13:28:48 -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 h9UHSlit001115; Thu, 30 Oct 2003 12:28:47 -0500 (EST) To: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking In-reply-to: <16289.14916.51000.772555@gargle.gargle.HOWL> References: <16272.318.870000.93584@gargle.gargle.HOWL> <87d6ciy3bf.fsf@stark.dyndns.tv> <16288.19970.172547.319577@jump.bivio.com> <200310291655.07363.josh@agliodbs.com> <16289.14916.51000.772555@gargle.gargle.HOWL> Comments: In-reply-to Rob Nagler message dated "Thu, 30 Oct 2003 09:20:20 -0700" Date: Thu, 30 Oct 2003 12:28:47 -0500 Message-ID: <1113.1067534927@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/765 X-Sequence-Number: 4513 Rob Nagler writes: > When vacuum is running, it's going through the entire > database, and that pretty much trashes all other queries, especially > DSS queries. As always it is just software, and there's got to be > 80/20 solution. One thing that's been discussed but not yet tried is putting a tunable delay into VACUUM's per-page loop (ie, sleep N milliseconds after each heap page is processed, and probably each index page too). This might be useless or it might be the 80/20 solution you want. Want to try it and report back? regards, tom lane From pgsql-performance-owner@postgresql.org Thu Oct 30 14: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 839BCD1B4E9 for ; Thu, 30 Oct 2003 18:11: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 01456-08 for ; Thu, 30 Oct 2003 14:11:04 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 6CA1CD1B588 for ; Thu, 30 Oct 2003 14:11:03 -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 h9UI86Bv006213; Thu, 30 Oct 2003 11:09:01 -0700 (MST) Date: Thu, 30 Oct 2003 10:55:32 -0700 (MST) From: "scott.marlowe" To: Rob Nagler Cc: Subject: Re: vacuum locking In-Reply-To: <16289.17560.847000.637384@gargle.gargle.HOWL> 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: 200310/767 X-Sequence-Number: 4515 On Thu, 30 Oct 2003, Rob Nagler wrote: > scott.marlowe writes: > > t2 was 'vacuum full'ed and analyzed, right? Just guessing. > > Fresh import. I've been told this includes a ANALYZE. You should probably run analyze by hand just to be sure. If the planner is using an index scan on a table with 20 rows, then it's likely it has the default statistics for the table, not real ones. From pgsql-performance-owner@postgresql.org Thu Oct 30 14:18: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 0F19DD1B4EB for ; Thu, 30 Oct 2003 18: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 05781-02 for ; Thu, 30 Oct 2003 14:18:22 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id F3D47D1B4E9 for ; Thu, 30 Oct 2003 14:18:20 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id BC11436AEB; Thu, 30 Oct 2003 13:18:05 -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 1AFHMz-0005S7-00; Thu, 30 Oct 2003 13:18:05 -0500 To: Rajesh Kumar Mallah Cc: Christopher Browne , 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> <3FA323C2.2060302@trade-india.com> In-Reply-To: <3FA323C2.2060302@trade-india.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 30 Oct 2003 13:18:05 -0500 Message-ID: <87znfid1ya.fsf@stark.dyndns.tv> Lines: 20 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: 200310/768 X-Sequence-Number: 4516 Rajesh Kumar Mallah writes: > -> 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))) This query has to read through every ticket in the system and check if the current user has access to it? It seems like this isn't going to be a terribly fast query no matter how you slice it. One thing that might help keep its run-time from growing is a partial index WHERE type = 'ticket' and (status = 'new' OR status = 'open') (I'm not sure what the point of the effectiveid=id clause is) That at least might help when 99% of your tickets are old closed tickets. But it will still have to scan through every new and open ticket which on some systems could be a large number. -- greg From pgsql-performance-owner@postgresql.org Thu Oct 30 14:22: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 E490AD1B4EB for ; Thu, 30 Oct 2003 18:22: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 03278-06 for ; Thu, 30 Oct 2003 14:21:35 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id CB223D1B538 for ; Thu, 30 Oct 2003 14:21:33 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3845148; Thu, 30 Oct 2003 10:22:15 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Rob Nagler , pgsql-performance@postgresql.org Subject: Re: vacuum locking Date: Thu, 30 Oct 2003 10:21:06 -0800 User-Agent: KMail/1.4.3 References: <16272.318.870000.93584@gargle.gargle.HOWL> <200310291655.07363.josh@agliodbs.com> <16289.14916.51000.772555@gargle.gargle.HOWL> In-Reply-To: <16289.14916.51000.772555@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310301021.06719.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/769 X-Sequence-Number: 4517 Rob, > I have had a lot push back from the core Postgres folks on the idea of > planner hints, which would go a long way to solve the performance > problems we are seeing. I can tell you that the general reaction that you'll get is "let's fix the problems with the planner instead of giving the user a workaround." Not that that helps people running on older versions, but it stems from a attitude of "let's heal the illness, not the symptoms" attitude that is one of our project's strengths. > I presented an alternative approach: have a > "style sheet" (Scribe, LaTex) type of solution in the postmaster, > which can be customized by end users. That got no response so I > assume it wasn't in line with the "Postgres way" (more below). Or you just posted it on a bad week. I don't remember your post; how about we try it out on Hackers again and we'll argue it out? > running. When vacuum is running, it's going through the entire > database, and that pretty much trashes all other queries, especially > DSS queries. As always it is just software, and there's got to be > 80/20 solution. See Tom's post. > Our new project is large, high-profile, but not as data intensive as > the problematic one. We are willing to commit significant funding and > effort to make Postgres faster. We are "business value" driven. That > means we solve problems practically instead of theoretically. This > seems to be in conflict with "the Postgres way", which seems to be > more theoretical. Our business situation comes ahead of theories. As always, it's a matter of balance. Our "theoretical purity" has given PostgreSQL a reliability and recoverability level only otherwise obtainable from Oracle for six figures. And has allowed us to build an extensability system that lets users define their own datatypes, operators, aggregates, etc., in a way that is not possible on *any* other database. This is what you're up against when you suggest changes to some of the core components ... people don't want to break what's not broken unless there are substantial, proven gains to be made. > My customer (who monitors this list) and I believe that our changes > would not be accepted back into the Postgres main branch. If you haven't posted, you don't know. A *lot* of suggestions get rejected because the suggestor wants Tom, Bruce, Peter, Joe and Jan to do the actual work or aren't willing to follow-through with testing and maintanence. As I said before, *I* don't remember earlier posts from you offering patches; perhaps it's time to try again? -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Oct 30 14:35: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 B2AE9D1B538 for ; Thu, 30 Oct 2003 18:35: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 10737-01 for ; Thu, 30 Oct 2003 14:34:40 -0400 (AST) Received: from candle.pha.pa.us (unknown [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 72D31D1B8B6 for ; Thu, 30 Oct 2003 14:34:38 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h9UIYO322264; Thu, 30 Oct 2003 13:34:24 -0500 (EST) From: Bruce Momjian Message-Id: <200310301834.h9UIYO322264@candle.pha.pa.us> Subject: Re: vacuum locking In-Reply-To: <200310301021.06719.josh@agliodbs.com> To: Josh Berkus Date: Thu, 30 Oct 2003 13:34:24 -0500 (EST) Cc: Rob Nagler , 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: 200310/770 X-Sequence-Number: 4518 Josh Berkus wrote: > > Our new project is large, high-profile, but not as data intensive as > > the problematic one. We are willing to commit significant funding and > > effort to make Postgres faster. We are "business value" driven. That > > means we solve problems practically instead of theoretically. This > > seems to be in conflict with "the Postgres way", which seems to be > > more theoretical. Our business situation comes ahead of theories. > > As always, it's a matter of balance. Our "theoretical purity" has given > PostgreSQL a reliability and recoverability level only otherwise obtainable > from Oracle for six figures. And has allowed us to build an extensibility > system that lets users define their own datatypes, operators, aggregates, > etc., in a way that is not possible on *any* other database. This is what > you're up against when you suggest changes to some of the core components ... > people don't want to break what's not broken unless there are substantial, > proven gains to be made. Let me add a little historical perspective here --- the PostgreSQL code base is almost 20 years old, and code size has doubled in the past 7 years. We are into PostgreSQL for the long haul --- that means we want code that will be working and maintainable 7 years from now. If your solution doesn't fit that case, well, you might be right, it might get rejected. However, we find that it is worth the time and effort to make our code sustainable, and it is possible your solution could be set up to do that. However, it requires you to go beyond your "business situation" logic and devote time to contribute something that will make PostgreSQL better 5 years in the future, as well as the next release. We have found very few companies that are not willing to work within that long-term perspective. -- 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 Oct 30 14:46: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 17719D1B8AA for ; Thu, 30 Oct 2003 18:46: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 08909-09 for ; Thu, 30 Oct 2003 14:45:57 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id D5DC9D1B58D for ; Thu, 30 Oct 2003 14:45:55 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id D0FC236C80; Thu, 30 Oct 2003 13:45:55 -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 1AFHnv-0005VF-00; Thu, 30 Oct 2003 13:45:55 -0500 To: Rajesh Kumar Mallah Cc: Christopher Browne , pgsql-performance@postgresql.org Cc: 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> In-Reply-To: <3FA323C2.2060302@trade-india.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 30 Oct 2003 13:45:55 -0500 Message-ID: <87r80ud0nw.fsf@stark.dyndns.tv> Lines: 59 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: 200310/771 X-Sequence-Number: 4519 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; -- greg From pgsql-performance-owner@postgresql.org Thu Oct 30 15:52: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 4DA85D1B537 for ; Thu, 30 Oct 2003 19:52: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 19687-10 for ; Thu, 30 Oct 2003 15:51:42 -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 28881D1B53A for ; Thu, 30 Oct 2003 15:51: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 h9UJn8E17218 for ; Thu, 30 Oct 2003 17:49:08 -0200 Received: from 192.168.1.120 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Thu, 30 Oct 2003 17:49:08 -0200 (BRST) Message-ID: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> Date: Thu, 30 Oct 2003 17:49:08 -0200 (BRST) Subject: Pg+Linux swap use 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: 200310/773 X-Sequence-Number: 4521 Hi, Old: Post 7.3.2, P4 1.8, 1 MB RAM, 2 x IDE SW RAID 1, RedHat 8 New: Post 7.3.4, Xeon 2.4, 1 MB RAM, 2 x SCSI 15k SW RAID 1, RedHat 9 Both use: Only postgresql on server. Buffers = 8192, effective cache = 100000 In old plataform the free and vmstat reports no use of swap. In new, the swap is in constant use (40-100 MB), with a low but constant swap out and swap in. The cache memory ~ 830000 and buffers ~ 43000 I try to reduce the buffers to 1024 with no effects. Thanks, Alexandre From pgsql-performance-owner@postgresql.org Thu Oct 30 16:23: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 050D5D1B936 for ; Thu, 30 Oct 2003 20:23: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 30657-01 for ; Thu, 30 Oct 2003 16:22:32 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 5BABCD1B549 for ; Thu, 30 Oct 2003 16:22:27 -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 h9UKLPBv014264; Thu, 30 Oct 2003 13:21:25 -0700 (MST) Date: Thu, 30 Oct 2003 13:08:50 -0700 (MST) From: "scott.marlowe" To: "alexandre :: aldeia digital" Cc: Subject: Re: Pg+Linux swap use In-Reply-To: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> 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: 200310/774 X-Sequence-Number: 4522 On Thu, 30 Oct 2003, alexandre :: aldeia digital wrote: > Hi, > > Old: Post 7.3.2, P4 1.8, 1 MB RAM, 2 x IDE SW RAID 1, RedHat 8 > New: Post 7.3.4, Xeon 2.4, 1 MB RAM, 2 x SCSI 15k SW RAID 1, RedHat 9 > > Both use: Only postgresql on server. Buffers = 8192, effective cache = 100000 > > In old plataform the free and vmstat reports no use of swap. > In new, the swap is in constant use (40-100 MB), with a low but constant > swap out and swap in. The cache memory ~ 830000 and buffers ~ 43000 Do both machines have the same amount of swap, and what kernels are the two running? Also, do the xeons have hyperthreading turned on. I doubt hyperthreading has anything to do with this problem, but I've found that turning off hyperthreading in the BIOS gets me a faster machine under Postgresql so I just thought I'd throw that out there. From pgsql-performance-owner@postgresql.org Thu Oct 30 17:33: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 E671BD1B4EB for ; Thu, 30 Oct 2003 21:33: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 41511-07 for ; Thu, 30 Oct 2003 17:33:00 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 0BB93D1B50A for ; Thu, 30 Oct 2003 17:32:58 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 6E13536D16; Thu, 30 Oct 2003 16:32: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 1AFKPM-0006Cf-00; Thu, 30 Oct 2003 16:32:44 -0500 To: Rajesh Kumar Mallah Cc: Greg Stark , 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> In-Reply-To: <3FA34827.1030705@trade-india.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 30 Oct 2003 16:32:43 -0500 Message-ID: <87ad7icsxw.fsf@stark.dyndns.tv> Lines: 30 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: 200310/779 X-Sequence-Number: 4527 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; -- greg From pgsql-admin-owner@postgresql.org Fri Oct 31 14:09:54 2003 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 69632D1B50D; Thu, 30 Oct 2003 23:16: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 54561-06; Thu, 30 Oct 2003 19:15:39 -0400 (AST) Received: from rj.sgi.com (mtvcafw.SGI.COM [192.48.171.6]) by svr1.postgresql.org (Postfix) with ESMTP id EF718D1B508; Thu, 30 Oct 2003 19:15:35 -0400 (AST) Received: from larry.melbourne.sgi.com ([134.14.52.130]) by rj.sgi.com (8.12.9/8.12.9/linux-outbound_gateway-1.1) with SMTP id h9ULKbOO020295; Thu, 30 Oct 2003 13:20:38 -0800 Received: from wobbly.melbourne.sgi.com (wobbly.melbourne.sgi.com [134.14.55.135]) by larry.melbourne.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id KAA13321; Fri, 31 Oct 2003 10:15:25 +1100 Received: from frodo.melbourne.sgi.com (root@frodo.melbourne.sgi.com [134.14.55.153]) by wobbly.melbourne.sgi.com (SGI-8.12.5/8.12.5) with ESMTP id h9UNFMUc923431; Fri, 31 Oct 2003 10:15:23 +1100 (EST) Received: from frodo.melbourne.sgi.com (nathans@localhost [127.0.0.1]) by frodo.melbourne.sgi.com (8.12.9/8.12.9/Debian-3) with ESMTP id h9UMCMbr001173; Fri, 31 Oct 2003 09:12:23 +1100 Received: (from nathans@localhost) by frodo.melbourne.sgi.com (8.12.9/8.12.9/Debian-3) id h9UMCLMm001171; Fri, 31 Oct 2003 09:12:21 +1100 Date: Fri, 31 Oct 2003 09:12:21 +1100 From: Nathan Scott To: linux-lvm@sistina.com Cc: tgl@sss.pgh.pa.us, threshar@torgo.978.org, josh@agliodbs.com, markw@osdl.org, pgsql-performance@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [linux-lvm] RE: [PERFORM] backup/restore - another ar ea. Message-ID: <20031030221221.GA1162@frodo> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.3i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/409 X-Sequence-Number: 10970 On Thu, Oct 30, 2003 at 10:28:10AM -0700, CLeon@phs.org wrote: > Does xfs_freeze work on red hat 7.3? It works on any kernel with XFS (it talks directly to XFS). cheers. -- Nathan From pgsql-performance-owner@postgresql.org Thu Oct 30 18:39: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 507DAD1B4F4 for ; Thu, 30 Oct 2003 22:39: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 52551-03 for ; Thu, 30 Oct 2003 18:38:38 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id C28F0D1B559 for ; Thu, 30 Oct 2003 18:38:34 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 9EDA336CA5; Thu, 30 Oct 2003 17:38:36 -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 1AFLR6-0006Ro-00; Thu, 30 Oct 2003 17:38:36 -0500 To: Rajesh Kumar Mallah Cc: Greg Stark , 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> In-Reply-To: <3FA34827.1030705@trade-india.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Date: 30 Oct 2003 17:38:36 -0500 Message-ID: <87vfq6bbbn.fsf@stark.dyndns.tv> Lines: 30 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/782 X-Sequence-Number: 4530 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; -- greg From pgsql-performance-owner@postgresql.org Thu Oct 30 21:31: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 CE114D1B52D for ; Fri, 31 Oct 2003 01:31: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 81318-02 for ; Thu, 30 Oct 2003 21:31:10 -0400 (AST) Received: from houston.familyhealth.com.au (fhnet.arach.net.au [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 52284D1B8BD for ; Thu, 30 Oct 2003 21:31:05 -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 h9V1UcoD079684; Fri, 31 Oct 2003 09:30:43 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Message-ID: <3FA1BD04.2090705@familyhealth.com.au> Date: Fri, 31 Oct 2003 09:38:12 +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: Rob Nagler Cc: pgsql-performance@postgresql.org Subject: Re: vacuum locking References: <16288.19970.172547.319577@jump.bivio.com> <16289.17560.847000.637384@gargle.gargle.HOWL> In-Reply-To: <16289.17560.847000.637384@gargle.gargle.HOWL> 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: 200310/783 X-Sequence-Number: 4531 > Fresh import. I've been told this includes a ANALYZE. Uh - no it doesn't. Chris From pgsql-performance-owner@postgresql.org Fri Oct 31 08:41: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 0FBEBD1B8D5 for ; Fri, 31 Oct 2003 12:41: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 80574-08 for ; Fri, 31 Oct 2003 08:41:21 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 63620D1B8EA for ; Fri, 31 Oct 2003 08:41:17 -0400 (AST) Received: (qmail 6828 invoked from network); 31 Oct 2003 12:43:51 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 31 Oct 2003 12:43:51 -0000 Date: Fri, 31 Oct 2003 07:41:14 -0500 From: Jeff To: "alexandre :: aldeia digital" Cc: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use Message-Id: <20031031074114.2fbad92c.threshar@torgo.978.org> In-Reply-To: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> References: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> 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: 200310/784 X-Sequence-Number: 4532 On Thu, 30 Oct 2003 17:49:08 -0200 (BRST) "alexandre :: aldeia digital" wrote: > Both use: Only postgresql on server. Buffers = 8192, effective cache = > 100000 > Well, I'm assuming you meant 1GB of ram, not 1MB :) Check a ps auxw to see what is running. Perhaps X is running gobbling up your precious mem. But still.. with 1GB there should be virtually no swap activity. How busy is the DB? How many connections? and is sort_mem set high? -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 31 08: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 41A54D1B583 for ; Fri, 31 Oct 2003 12:52: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 88263-03 for ; Fri, 31 Oct 2003 08:52:11 -0400 (AST) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id EC701D1B55A for ; Fri, 31 Oct 2003 08:52:06 -0400 (AST) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9VCqIAF023884 for ; Fri, 31 Oct 2003 18:22:18 +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 h9VCqI04023871 for ; Fri, 31 Oct 2003 18:22:18 +0530 Message-ID: <3FA25AF7.4060609@persistent.co.in> Date: Fri, 31 Oct 2003 18:22:07 +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: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use References: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> <20031031074114.2fbad92c.threshar@torgo.978.org> In-Reply-To: <20031031074114.2fbad92c.threshar@torgo.978.org> 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: 200310/785 X-Sequence-Number: 4533 Jeff wrote: > On Thu, 30 Oct 2003 17:49:08 -0200 (BRST) > "alexandre :: aldeia digital" wrote: > > >>Both use: Only postgresql on server. Buffers = 8192, effective cache = >>100000 > Well, I'm assuming you meant 1GB of ram, not 1MB :) > > Check a ps auxw to see what is running. Perhaps X is running gobbling up > your precious mem. But still.. with 1GB there should be virtually no > swap activity. > > How busy is the DB? How many connections? > > and is sort_mem set high? Also are two kernels exactly same? In my experience linux kernel behaves slightly different from version to version w.r.t swap aggressiveness... Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 31 09:49: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 01769D1B56A for ; Fri, 31 Oct 2003 13:49: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 97749-06 for ; Fri, 31 Oct 2003 09:49:01 -0400 (AST) Received: from email05.aon.at (WARSL402PIP4.highway.telekom.at [195.3.96.79]) by svr1.postgresql.org (Postfix) with SMTP id A216FD1B4E1 for ; Fri, 31 Oct 2003 09:48:56 -0400 (AST) Received: (qmail 432380 invoked from network); 31 Oct 2003 13:48:54 -0000 Received: from m169p005.dipool.highway.telekom.at (HELO cantor) ([62.46.11.5]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 31 Oct 2003 13:48:54 -0000 From: Manfred Koizar To: Rod Taylor Cc: Robert Treat , Postgresql Performance Subject: Re: redundent index? Date: Fri, 31 Oct 2003 14:47:14 +0100 Message-ID: References: <1067436236.2069.28785.camel@camel> <1067440627.5789.2.camel@jester> In-Reply-To: <1067440627.5789.2.camel@jester> 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: 200310/786 X-Sequence-Number: 4534 On Wed, 29 Oct 2003 10:17:24 -0500, Rod Taylor wrote: >On Wed, 2003-10-29 at 09:03, Robert Treat wrote: >> Indexes: entity_watch_map_pkey primary key btree (entity_id, watch_id), >> ewm_entity_id btree (entity_id), >> >> I can't think of why the second index is there, as ISTM there is no >> instance where the first index wouldn't be used in place of the second > >The cost in evaluating the first index will be a little higher Yes, the actual cost may be a little higher. But the cost estimation might be significantly higher, so there can be border cases where the planner chooses a sequential scan over a multi-column index scan while a single-column index would correctly be recognized as being faster ... Servus Manfred From pgsql-performance-owner@postgresql.org Fri Oct 31 10:06: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 089ADD1B56F for ; Fri, 31 Oct 2003 14:06: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 01014-02 for ; Fri, 31 Oct 2003 10:06:29 -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 94A9FD1B56D for ; Fri, 31 Oct 2003 10:06:23 -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 h9VE3wI19975 for ; Fri, 31 Oct 2003 12:03:59 -0200 Received: from 192.168.1.120 (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Fri, 31 Oct 2003 12:03:59 -0200 (BRST) Message-ID: <3456.192.168.1.120.1067609039.squirrel@webmail.ad2.com.br> In-Reply-To: <3FA25AF7.4060609@persistent.co.in> References: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> <20031031074114.2fbad92c.threshar@torgo.978.org> <3FA25AF7.4060609@persistent.co.in> Date: Fri, 31 Oct 2003 12:03:59 -0200 (BRST) Subject: Re: Pg+Linux swap use 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: 200310/787 X-Sequence-Number: 4535 Scott, Jeff and Shridhar: 1 GB RAM :) The stock kernels are not the same, HyperThreading enabled. 80 simultaneous connections. sort_mem = 4096 I will compile my own kernel on this weekend, and I will report to the list after. Thank's all Alexandre > Also are two kernels exactly same? In my experience linux kernel behaves > slightly different from version to version w.r.t swap aggressiveness... > > Shridhar > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Fri Oct 31 10:36:55 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 D974BD1B55A for ; Fri, 31 Oct 2003 14:36: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 07656-03 for ; Fri, 31 Oct 2003 10:36:24 -0400 (AST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 45A62D1B923 for ; Fri, 31 Oct 2003 10:36:20 -0400 (AST) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AFaO0-0000P4-00 for ; Fri, 31 Oct 2003 09:36:24 -0500 Received: by dba2 (Postfix, from userid 1019) id 65BC4CD8A; Fri, 31 Oct 2003 09:36:24 -0500 (EST) Date: Fri, 31 Oct 2003 09:36:24 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use Message-ID: <20031031143624.GB5394@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <1311.192.168.1.120.1067543348.squirrel@webmail.ad2.com.br> <20031031074114.2fbad92c.threshar@torgo.978.org> <3FA25AF7.4060609@persistent.co.in> <3456.192.168.1.120.1067609039.squirrel@webmail.ad2.com.br> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3456.192.168.1.120.1067609039.squirrel@webmail.ad2.com.br> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/788 X-Sequence-Number: 4536 On Fri, Oct 31, 2003 at 12:03:59PM -0200, alexandre :: aldeia digital wrote: > Scott, Jeff and Shridhar: > > 1 GB RAM :) > > The stock kernels are not the same, HyperThreading enabled. 80 Some people have reported that things actually slow down with HT enabled. Have you tried turning it off? 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 Oct 31 11:32: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 0A716D1B4E1 for ; Fri, 31 Oct 2003 15:32: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 10308-09 for ; Fri, 31 Oct 2003 11:31:36 -0400 (AST) Received: from facnd.com (dslstatic-236-59.ideaone.net [64.21.236.59]) by svr1.postgresql.org (Postfix) with ESMTP id 75CBFD1B508 for ; Fri, 31 Oct 2003 11:31:28 -0400 (AST) Received: by facnd.com (Postfix on SuSE Linux 7.3 (i386), from userid 553) id E35D9FAB; Fri, 31 Oct 2003 09:31:24 -0600 (CST) Received: from rob (unknown [192.1.1.100]) by facnd.com (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id 42F93FA6; Fri, 31 Oct 2003 09:31:24 -0600 (CST) Reply-To: From: "Rob Sell" To: "'Andrew Sullivan'" , Subject: Re: Pg+Linux swap use Date: Fri, 31 Oct 2003 09:31:19 -0600 Organization: Fargo Assembly Company Message-ID: <007c01c39fc4$0844f850$640101c0@rob> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal In-Reply-To: <20031031143624.GB5394@libertyrms.info> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/790 X-Sequence-Number: 4538 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. I have read everything I could find on Pg performance tweaked all the variables that were suggested and nothing. Which is why I subscribed to this list, just been lurking so far but this caught my eye.= =20 Rob -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan Sent: Friday, October 31, 2003 8:36 AM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Pg+Linux swap use On Fri, Oct 31, 2003 at 12:03:59PM -0200, alexandre :: aldeia digital wrote: > Scott, Jeff and Shridhar: >=20 > 1 GB RAM :) >=20 > The stock kernels are not the same, HyperThreading enabled. 80 Some people have reported that things actually slow down with HT enabled. Have you tried turning it off? A --=20 ---- Andrew Sullivan 204-4141 Yonge Street Afilias Canada Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend From pgsql-performance-owner@postgresql.org Fri Oct 31 11:39: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 7EBE3D1B583 for ; Fri, 31 Oct 2003 15:39: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 17295-09 for ; Fri, 31 Oct 2003 11:39:08 -0400 (AST) Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com [209.202.205.1]) by svr1.postgresql.org (Postfix) with SMTP id 45099D1B54F for ; Fri, 31 Oct 2003 11:39:03 -0400 (AST) Received: (qmail 9409 invoked from network); 31 Oct 2003 15:41:40 -0000 Received: from dhcp-7-41.ma.lycos.com (HELO squeegit) (10.124.7.41) by dhcp-7-248.ma.lycos.com with SMTP; 31 Oct 2003 15:41:40 -0000 Date: Fri, 31 Oct 2003 10:39:02 -0500 From: Jeff To: Cc: andrew@libertyrms.info, pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use Message-Id: <20031031103902.0443c135.threshar@torgo.978.org> In-Reply-To: <007c01c39fc4$0844f850$640101c0@rob> References: <20031031143624.GB5394@libertyrms.info> <007c01c39fc4$0844f850$640101c0@rob> 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: 200310/791 X-Sequence-Number: 4539 On Fri, 31 Oct 2003 09:31:19 -0600 "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. I have > read everything I could find on Pg performance tweaked all the > variables that were suggested and nothing. Which is why I subscribed > to this list, just been lurking so far but this caught my eye. > > Rob There's benchmarks around that show in _some_ cases HT is not all it is cracked up to be, somtimes running slower. But the real point of this thread isn't all this stuff about hyperthreading, the problem is the guy is seeing swapping.. I'm guessing RH is running some useless stuff in the BG.. or maybe he's running a retarded kernel... or.. maybe.. just.. maybe.. little elves are doing it. -- Jeff Trout http://www.jefftrout.com/ http://www.stuarthamm.net/ From pgsql-performance-owner@postgresql.org Fri Oct 31 11:55: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 842DFD1B54E for ; Fri, 31 Oct 2003 15:55: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 17027-10 for ; Fri, 31 Oct 2003 11:54:45 -0400 (AST) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 7266AD1B56A for ; Fri, 31 Oct 2003 11:54:40 -0400 (AST) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id h9VFsvPw010700 for ; Fri, 31 Oct 2003 21:24:57 +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 h9VFsu04010687 for ; Fri, 31 Oct 2003 21:24:56 +0530 Message-ID: <3FA285C3.8050904@persistent.co.in> Date: Fri, 31 Oct 2003 21:24:43 +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: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use References: <20031031143624.GB5394@libertyrms.info> <007c01c39fc4$0844f850$640101c0@rob> <20031031103902.0443c135.threshar@torgo.978.org> In-Reply-To: <20031031103902.0443c135.threshar@torgo.978.org> 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: 200310/792 X-Sequence-Number: 4540 Jeff wrote: > On Fri, 31 Oct 2003 09:31:19 -0600 > "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. I have >>read everything I could find on Pg performance tweaked all the >>variables that were suggested and nothing. Which is why I subscribed >>to this list, just been lurking so far but this caught my eye. >> >>Rob > There's benchmarks around that show in _some_ cases HT is not all it is > cracked up to be, somtimes running slower. To use HT effectively on needs. 1. A kernel that understands HT. 2. A task scheduler that understands HT 3. A CPU intensive load. So if you are running a stock RedHat and production postgresql database, turn it off. It won't hurt certainly(Almost certainly) > I'm guessing RH is running some useless stuff in the BG.. or maybe he's > running a retarded kernel... or.. maybe.. just.. maybe.. little elves > are doing it. Too much..:-) I guess Alexandre can tune bdflush to be little less agressive. Comparing bdflush values on two machines might turn up something. His idea of compiling kernel is also good one. He can also try tuning some values in /proc/sys/vm but I don't find any documentation offhand. I usually run slackware and a handcompiled 2.6-test4. None of them use any swap unless true memory starts falling low. This touch-swap-even-if-oodles-of-ram-is-free is something I have't experienced on my desktop for quite a while. Shridhar From pgsql-performance-owner@postgresql.org Fri Oct 31 11:56: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 0E233D1B54E for ; Fri, 31 Oct 2003 15: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 19763-02 for ; Fri, 31 Oct 2003 11:55:35 -0400 (AST) Received: from mta13.adelphia.net (mta13.mail.adelphia.net [68.168.78.44]) by svr1.postgresql.org (Postfix) with ESMTP id E666ED1B8B5 for ; Fri, 31 Oct 2003 11:55:29 -0400 (AST) Received: from potentialtech.com ([68.68.113.33]) by mta13.adelphia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031031155534.UAEC20181.mta13.adelphia.net@potentialtech.com> for ; Fri, 31 Oct 2003 10:55:34 -0500 Message-ID: <3FA285F5.6020408@potentialtech.com> Date: Fri, 31 Oct 2003 10:55:33 -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: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use References: <007c01c39fc4$0844f850$640101c0@rob> In-Reply-To: <007c01c39fc4$0844f850$640101c0@rob> 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: 200310/793 X-Sequence-Number: 4541 Just for an additional viewpoint. I'm finishing up a project based on FreeBSD and PostgreSQL. The target server is a Dual 2.4G Intel machine. I have tested the application with hyperthreading enabled and disabled. To all appearances, enabling hyperthreading makes the box act like a quad, with the expected increase in processing capability - _for_this_application_. I have also heard the claims and seen the tests that show hyperthreading occasionally decreasing performance. I think in the end, you just have to test your particular application to see how it reacts. 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. I have read everything I could find on Pg performance > tweaked all the variables that were suggested and nothing. Which is why I > subscribed to this list, just been lurking so far but this caught my eye. > > Rob > > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: Friday, October 31, 2003 8:36 AM > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Pg+Linux swap use > > On Fri, Oct 31, 2003 at 12:03:59PM -0200, alexandre :: aldeia digital wrote: > >>Scott, Jeff and Shridhar: >> >>1 GB RAM :) >> >>The stock kernels are not the same, HyperThreading enabled. 80 > > > Some people have reported that things actually slow down with HT > enabled. Have you tried turning it off? > > A > -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Oct 31 12:00: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 467D3D1B54F for ; Fri, 31 Oct 2003 16:00: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 18494-07 for ; Fri, 31 Oct 2003 12:00:00 -0400 (AST) Received: from mta6.srv.hcvlny.cv.net (mta6.srv.hcvlny.cv.net [167.206.5.72]) by svr1.postgresql.org (Postfix) with ESMTP id C7904D1B54E for ; Fri, 31 Oct 2003 11:59:54 -0400 (AST) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta6.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNM006YKPRRGX@mta6.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 31 Oct 2003 10:59:54 -0500 (EST) Date: Fri, 31 Oct 2003 11:02:24 -0500 From: Allen Landsidel Subject: index creation order? X-Sender: bsdasym@pop.hotpop.com To: pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 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: 200310/794 X-Sequence-Number: 4542 Yet another question.. thanks to everyone responding to all these so far.. ;) This one is basically.. given I have a big table already in COPY format, about 28 million rows, all keys guaranteed to be unique, I'm trying to find out which of the following will get the import finished the fastest: a) CREATE TABLE with no indexes or keys. Run the COPY (fast, ~30min), then CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk and each fk needed. b) Same as above, but instead of ALTER TABLE -- ditch the FK, and CREATE UNIQUE INDEX on the PK. c) CREATE TABLE with the PK/FK's in the table structure, CREATE INDEX on needed columns, then run the COPY. d) .. is to c as b is to a .. Don't create PK/FK's, just CREATE UNIQUE INDEX after table creation, then run the COPY. My gut instinct tells me that in order, fastest to slowest, it's going to be d,b,c,a; this is what I've experienced on other DBs such as MSSQL and Oracle. If there isn't a significant difference between all of them, performance wise, I think something is dreadfully wrong here. Running "a", the ALTER TABLE to add the PK ran for 17 hours and still wasn't finished. The table without indexes or keys is: CREATE TABLE foo ( id BIGINT NOT NULL DEFAULT nextval('foo_id_sequence'), master_id BIGINT NOT NULL, other_id INTEGER NOT NULL, status INTEGER NOT NULL, addtime TIMESTAMP WITH TIME ZONE DEFAULT now() ); Details on machine and configuration are: The machine is the same one I've mentioned before.. SMP AthlonMP 2800+ (2.1GHz), 4x18GB 15krpm SCSI RAID-0 with 256MB onboard cache on a quad-channel ICP-Vortex controller, 2GB physical memory. Running FreeBSD RELENG_4, relevant filesystems with softupdates enabled and mounted noatime. kernel options are: maxusers 0 options MAXDSIZ="(1536UL*1024*1024)" # maximum limit options MAXSSIZ="(512UL*1024*1024)" # maximum stack options DFLDSIZ="(512UL*1024*1024)" # default limit options VM_BCACHE_SIZE_MAX="(384UL*1024*1024)" # cache size upped from default 200MB options SYSVSHM #SYSV-style shared memory options SYSVMSG #SYSV-style message queues options SYSVSEM #SYSV-style semaphores options SHMMAXPGS=262144 options SHMALL=262144 options SHMSEG=256 options SEMMNI=384 options SEMMNS=768 options SEMMNU=384 options SEMMAP=384 postgresql.conf settings are: shared_buffers = 30000 max_fsm_relations = 10000 max_fsm_pages = 2000000 max_locks_per_transaction = 64 wal_buffers = 128 sort_mem = 1310720 (1.2GB) vacuum_mem = 262144 (256MB) checkpoint_segments = 64 checkpoint_timeout = 1200 commit_delay = 20000 commit_siblings = 2 fsync=true random_page_cost = 1.7 cpu_tuple_cost = 0.005 cpu_index_tuple_cost = 0.005 cpu_operator_cost = 0.0012 stats_start_collector = true stats_command_string = true stats_row_level = true stats_block_level = true From pgsql-performance-owner@postgresql.org Fri Oct 31 12:24: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 0E67CD1B8B4 for ; Fri, 31 Oct 2003 16:24: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 19042-10 for ; Fri, 31 Oct 2003 12:23:28 -0400 (AST) Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) by svr1.postgresql.org (Postfix) with SMTP id 7734CD1B56A for ; Fri, 31 Oct 2003 12:23:27 -0400 (AST) Received: (qmail 2692 invoked from network); 31 Oct 2003 16:23:49 -0000 Received: from unknown (HELO ?10.0.2.5?) (216.208.117.7) by 205.178.180.9 with SMTP; 31 Oct 2003 16:23:49 -0000 Subject: Re: index creation order? From: Rod Taylor To: Allen Landsidel Cc: Postgresql Performance In-Reply-To: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-9KKvaj9OInRImQz+c2Ho" Message-Id: <1067617409.17097.7.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 31 Oct 2003 11:23:30 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/795 X-Sequence-Number: 4543 --=-9KKvaj9OInRImQz+c2Ho Content-Type: text/plain Content-Transfer-Encoding: quoted-printable If it is 7.4 beta 5 or later, I would definitely go with A. Adding indexes after the fact seems to be much quicker. Foreign keys use the same algorithm prior to beta 5 regardless of timing.=20 A primary key and unique index will have approx the same performance (a check for NULL isn't very costly). On Fri, 2003-10-31 at 11:02, Allen Landsidel wrote: > Yet another question.. thanks to everyone responding to all these so far.= . ;) >=20 > This one is basically.. given I have a big table already in COPY format,= =20 > about 28 million rows, all keys guaranteed to be unique, I'm trying to fi= nd=20 > out which of the following will get the import finished the fastest: >=20 > a) CREATE TABLE with no indexes or keys. Run the COPY (fast, ~30min), th= en=20 > CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk an= d=20 > each fk needed. >=20 > b) Same as above, but instead of ALTER TABLE -- ditch the FK, and CREATE= =20 > UNIQUE INDEX on the PK. >=20 > c) CREATE TABLE with the PK/FK's in the table structure, CREATE INDEX on= =20 > needed columns, then run the COPY. >=20 > d) .. is to c as b is to a .. Don't create PK/FK's, just CREATE UNIQUE=20 > INDEX after table creation, then run the COPY. >=20 > My gut instinct tells me that in order, fastest to slowest, it's going to= =20 > be d,b,c,a; this is what I've experienced on other DBs such as MSSQL and= =20 > Oracle. >=20 > If there isn't a significant difference between all of them, performance= =20 > wise, I think something is dreadfully wrong here. Running "a", the ALTER= =20 > TABLE to add the PK ran for 17 hours and still wasn't finished. >=20 > The table without indexes or keys is: > CREATE TABLE foo ( > id BIGINT NOT NULL DEFAULT nextval('foo_id_sequence'), > master_id BIGINT NOT NULL, > other_id INTEGER NOT NULL, > status INTEGER NOT NULL, > addtime TIMESTAMP WITH TIME ZONE DEFAULT now() > ); >=20 > Details on machine and configuration are: >=20 > The machine is the same one I've mentioned before.. SMP AthlonMP 2800+=20 > (2.1GHz), 4x18GB 15krpm SCSI RAID-0 with 256MB onboard cache on a=20 > quad-channel ICP-Vortex controller, 2GB physical memory. Running FreeBSD= =20 > RELENG_4, relevant filesystems with softupdates enabled and mounted noati= me. >=20 > kernel options are: > maxusers 0 >=20 > options MAXDSIZ=3D"(1536UL*1024*1024)" # maximum limit > options MAXSSIZ=3D"(512UL*1024*1024)" # maximum stack > options DFLDSIZ=3D"(512UL*1024*1024)" # default limit > options VM_BCACHE_SIZE_MAX=3D"(384UL*1024*1024)" # cache size upp= ed=20 > from default 200MB > options SYSVSHM #SYSV-style shared memory > options SYSVMSG #SYSV-style message queues > options SYSVSEM #SYSV-style semaphores > options SHMMAXPGS=3D262144 > options SHMALL=3D262144 > options SHMSEG=3D256 > options SEMMNI=3D384 > options SEMMNS=3D768 > options SEMMNU=3D384 > options SEMMAP=3D384 >=20 > postgresql.conf settings are: >=20 > shared_buffers =3D 30000 > max_fsm_relations =3D 10000 > max_fsm_pages =3D 2000000 > max_locks_per_transaction =3D 64 > wal_buffers =3D 128 > sort_mem =3D 1310720 (1.2GB) > vacuum_mem =3D 262144 (256MB) > checkpoint_segments =3D 64 > checkpoint_timeout =3D 1200 > commit_delay =3D 20000 > commit_siblings =3D 2 > fsync=3Dtrue > random_page_cost =3D 1.7 > cpu_tuple_cost =3D 0.005 > cpu_index_tuple_cost =3D 0.005 > cpu_operator_cost =3D 0.0012 >=20 > stats_start_collector =3D true > stats_command_string =3D true > stats_row_level =3D true > stats_block_level =3D true >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >=20 --=-9KKvaj9OInRImQz+c2Ho Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/ooyB6DETLow6vwwRAv/9AJ9Zma6DsVEj3wYqtVqpZOZ5z8qhoACcCuGr kRlIUuL8WSYcTO8xA6MVa5I= =25jG -----END PGP SIGNATURE----- --=-9KKvaj9OInRImQz+c2Ho-- From pgsql-performance-owner@postgresql.org Fri Oct 31 12:38: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 4A299D1B8B0 for ; Fri, 31 Oct 2003 16:38: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 28886-02 for ; Fri, 31 Oct 2003 12:37:47 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 1A72ED1B8D0 for ; Fri, 31 Oct 2003 12:37:47 -0400 (AST) Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 412A1369BE; Fri, 31 Oct 2003 11:37:46 -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 1AFcHS-0000oL-00; Fri, 31 Oct 2003 11:37:46 -0500 To: Bill Moran Cc: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use References: <007c01c39fc4$0844f850$640101c0@rob> <3FA285F5.6020408@potentialtech.com> In-Reply-To: <3FA285F5.6020408@potentialtech.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 31 Oct 2003 11:37:45 -0500 Message-ID: <87ekwtbbxi.fsf@stark.dyndns.tv> Lines: 23 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: 200310/796 X-Sequence-Number: 4544 Bill Moran writes: > Just for an additional viewpoint. I'm finishing up a project based on FreeBSD > and PostgreSQL. The target server is a Dual 2.4G Intel machine. I have tested > the application with hyperthreading enabled and disabled. To all appearances, > enabling hyperthreading makes the box act like a quad, with the expected increase > in processing capability - _for_this_application_. > > I have also heard the claims and seen the tests that show hyperthreading > occasionally decreasing performance. I think in the end, you just have to > test your particular application to see how it reacts. My understanding is that the case where HT hurts is precisely your case. When you have two real processors with HT the kernel will sometimes schedule two jobs on the two virtual processors on the same real processor leaving the two virtual processors on the other real processor idle. As far as I know a single processor machine with HT does not benefit from disabling HT. -- greg From pgsql-performance-owner@postgresql.org Fri Oct 31 12:42: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 9582FD1B8E4 for ; Fri, 31 Oct 2003 16:42: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 29012-02 for ; Fri, 31 Oct 2003 12:42:05 -0400 (AST) Received: from facnd.com (dslstatic-236-59.ideaone.net [64.21.236.59]) by svr1.postgresql.org (Postfix) with ESMTP id B991CD1B90B for ; Fri, 31 Oct 2003 12:42:04 -0400 (AST) Received: by facnd.com (Postfix on SuSE Linux 7.3 (i386), from userid 553) id 6D3D2FAB; Fri, 31 Oct 2003 10:42:11 -0600 (CST) Received: from rob (unknown [192.1.1.100]) by facnd.com (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id 95075FA6; Fri, 31 Oct 2003 10:42:10 -0600 (CST) Reply-To: From: "Rob Sell" To: "'Bill Moran'" , Subject: Re: Pg+Linux swap use Date: Fri, 31 Oct 2003 10:42:06 -0600 Organization: Fargo Assembly Company Message-ID: <008a01c39fcd$eb8a0930$640101c0@rob> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal In-Reply-To: <3FA285F5.6020408@potentialtech.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/797 X-Sequence-Number: 4545 For the record I am running on SuSE with a pretty much stock kernel. Not to sound na=EFve, but is turning of HT something done in the bios? Rob -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Bill Moran Sent: Friday, October 31, 2003 9:56 AM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Pg+Linux swap use Just for an additional viewpoint. I'm finishing up a project based on FreeBSD and PostgreSQL. The target server is a Dual 2.4G Intel machine. I have tested the application with hyperthreading enabled and disabled. To all appearances, enabling hyperthreading makes the box act like a quad, with the expected increase in processing capability - _for_this_application_. I have also heard the claims and seen the tests that show hyperthreading occasionally decreasing performance. I think in the end, you just have to test your particular application to see how it reacts. 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. I have read everything I could find on Pg performance > tweaked all the variables that were suggested and nothing. Which is why I > subscribed to this list, just been lurking so far but this caught my eye.= =20 >=20 > Rob >=20 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan > Sent: Friday, October 31, 2003 8:36 AM > To: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] Pg+Linux swap use >=20 > On Fri, Oct 31, 2003 at 12:03:59PM -0200, alexandre :: aldeia digital wrote: >=20 >>Scott, Jeff and Shridhar: >> >>1 GB RAM :) >> >>The stock kernels are not the same, HyperThreading enabled. 80 >=20 >=20 > Some people have reported that things actually slow down with HT > enabled. Have you tried turning it off? >=20 > A >=20 --=20 Bill Moran Potential Technologies http://www.potentialtech.com ---------------------------(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 Fri Oct 31 12:56: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 091A4D1B8A0 for ; Fri, 31 Oct 2003 16: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 29780-02 for ; Fri, 31 Oct 2003 12:55:51 -0400 (AST) Received: from mta3.adelphia.net (mta3.adelphia.net [68.168.78.181]) by svr1.postgresql.org (Postfix) with ESMTP id E01D7D1B54F for ; Fri, 31 Oct 2003 12:55:50 -0400 (AST) Received: from potentialtech.com ([68.68.113.33]) by mta3.adelphia.net (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP id <20031031165553.OLWA16926.mta3.adelphia.net@potentialtech.com>; Fri, 31 Oct 2003 11:55:53 -0500 Message-ID: <3FA29415.7080901@potentialtech.com> Date: Fri, 31 Oct 2003 11:55:49 -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: Greg Stark Cc: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use References: <007c01c39fc4$0844f850$640101c0@rob> <3FA285F5.6020408@potentialtech.com> <87ekwtbbxi.fsf@stark.dyndns.tv> In-Reply-To: <87ekwtbbxi.fsf@stark.dyndns.tv> 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: 200310/798 X-Sequence-Number: 4546 Greg Stark wrote: > Bill Moran writes: > >>Just for an additional viewpoint. I'm finishing up a project based on FreeBSD >>and PostgreSQL. The target server is a Dual 2.4G Intel machine. I have tested >>the application with hyperthreading enabled and disabled. To all appearances, >>enabling hyperthreading makes the box act like a quad, with the expected increase >>in processing capability - _for_this_application_. >> >>I have also heard the claims and seen the tests that show hyperthreading >>occasionally decreasing performance. I think in the end, you just have to >>test your particular application to see how it reacts. > > My understanding is that the case where HT hurts is precisely your case. When > you have two real processors with HT the kernel will sometimes schedule two > jobs on the two virtual processors on the same real processor leaving the two > virtual processors on the other real processor idle. Yup, that's why I tested it. While more testing is probably in order, I could find no disadvantages to running with HTT enabled. And when I ran many background jobs (which is likely to happen during batch processing on this sytem) the system seemed to perform as if it really had 4 processors. Perhaps this is an indication of the quality of the FreeBSD scheduler (maybe it's HTT aware and makes decisions accordingly?), but I'm not involved enough in that level of development to do any more than speculate. Again, this is pure speculation ... can anyone with a more technical insight comment on whether my guess is correct, or whether I'm not testing enough? -- Bill Moran Potential Technologies http://www.potentialtech.com From pgsql-performance-owner@postgresql.org Fri Oct 31 13:07: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 C1C15D1B8C2 for ; Fri, 31 Oct 2003 17: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 30645-03 for ; Fri, 31 Oct 2003 13:06:39 -0400 (AST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id 20E7BD1B4E6 for ; Fri, 31 Oct 2003 13:06:38 -0400 (AST) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 1AFcjN-0002hq-00 for ; Fri, 31 Oct 2003 12:06:37 -0500 Received: by dba2 (Postfix, from userid 1019) id BDA35CD8A; Fri, 31 Oct 2003 12:06:37 -0500 (EST) Date: Fri, 31 Oct 2003 12:06:37 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Pg+Linux swap use Message-ID: <20031031170637.GF5394@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <3FA285F5.6020408@potentialtech.com> <008a01c39fcd$eb8a0930$640101c0@rob> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008a01c39fcd$eb8a0930$640101c0@rob> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/799 X-Sequence-Number: 4547 On Fri, Oct 31, 2003 at 10:42:06AM -0600, Rob Sell wrote: > For the record I am running on SuSE with a pretty much stock kernel. Not to > sound na?ve, but is turning of HT something done in the bios? As far as I know, yes. 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 Oct 31 13:11: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 E626BD1B8B5 for ; Fri, 31 Oct 2003 17:11: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 36911-04 for ; Fri, 31 Oct 2003 13:11:16 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id C9481D1B89E for ; Fri, 31 Oct 2003 13:11:15 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3849758; Fri, 31 Oct 2003 09:11:46 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Allen Landsidel , pgsql-performance@postgresql.org Subject: Re: index creation order? Date: Fri, 31 Oct 2003 09:10:30 -0800 User-Agent: KMail/1.4.3 References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> In-Reply-To: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310310910.30504.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/800 X-Sequence-Number: 4548 Allen, > a) CREATE TABLE with no indexes or keys. Run the COPY (fast, ~30min), then > CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk and > each fk needed. Did you ANALYZE after the copy? > If there isn't a significant difference between all of them, performance > wise, I think something is dreadfully wrong here. Running "a", the ALTER > TABLE to add the PK ran for 17 hours and still wasn't finished. Adding the *primary key* locked up? This seems unlikely; we have a known problem with *foreign* keys until the current beta. But I've added primary keys on 20Gb tables and had it complete in a couple of hours. Ignore this adivice and look for Stephan Szabo's FK patch instead if what you really meant was that the FK creation locked up. > shared_buffers = 30000 hmmm ... 236MB .... > max_fsm_pages = 2000000 2MB, fine ... > wal_buffers = 128 1MB, also fine ... > sort_mem = 1310720 (1.2GB) Problem here. As documented everywhere, sort_mem is allocated *per sort* not per query, user, or shared. This means that if the "add PK" operation involves 2 or more sorts (not sure, haven't tested it), then you're allocating .7GB RAM more than you acutally have. This may be the cause of your problem, particularly if *anything* is going on concurrent to the load. > checkpoint_segments = 64 IF you have the disk space (+ 2GB) I'd raise this to 150-300 during the load operation. > commit_delay = 20000 > commit_siblings = 2 These settings are for heavy multi-user update activity. They are not useful for a single-user load, and may even lower performance. > stats_start_collector = true > stats_command_string = true > stats_row_level = true > stats_block_level = true If you can do without stats collection during load, I would suggest that you do so. The above add both RAM and I/O overhead to your operation. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Nov 1 13:54: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 A170AD1B89E for ; Fri, 31 Oct 2003 17:46: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 38464-06 for ; Fri, 31 Oct 2003 13:45:59 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id E3CA7D1B56A for ; Fri, 31 Oct 2003 13:45: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 h9VHjwNw050161 for ; Fri, 31 Oct 2003 17:45:58 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9VHHS5U045554 for pgsql-performance@postgresql.org; Fri, 31 Oct 2003 17:17:28 GMT From: William Yu X-Newsgroups: comp.databases.postgresql.performance Subject: Re: Pg+Linux swap use Date: Fri, 31 Oct 2003 09:17:26 -0800 Organization: Hub.Org Networking Services Lines: 26 Message-ID: References: <20031031143624.GB5394@libertyrms.info> <007c01c39fc4$0844f850$640101c0@rob> 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: <007c01c39fc4$0844f850$640101c0@rob> To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/2 X-Sequence-Number: 4562 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. I have read everything I could find on Pg performance > tweaked all the variables that were suggested and nothing. Which is why I > subscribed to this list, just been lurking so far but this caught my eye. 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. Then you throw in the fact that (1) QS ratings for slower AMD chips are understated (but overstated for the fastest chips), (2) AMD uses a point-to-point CPU/memory interface (much better for SMP) versus the P4/Xeon's shared bus, (3) Athlon architecture is more suited for DB work compared to the P4, I'd say you're lucky to see 50% more performance from a Xeon 2.4. As for HT, I've seen quite a few benchmarks where HT hurts performance. The problem is it's not only app and workload specific but also system and usage specific. As it involves the internal rescheduling of processes, adding more simultaneous processes could help to a point and then start hurting or vice-versa. From pgsql-performance-owner@postgresql.org Fri Oct 31 14:26: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 783D9D1B9FF for ; Fri, 31 Oct 2003 18:26: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 48648-08 for ; Fri, 31 Oct 2003 14:26:20 -0400 (AST) Received: from mta6.srv.hcvlny.cv.net (mta6.srv.hcvlny.cv.net [167.206.5.72]) by svr1.postgresql.org (Postfix) with ESMTP id 497B6D1B8E4 for ; Fri, 31 Oct 2003 14:24:43 -0400 (AST) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta6.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNM00BMJWH36Y@mta6.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 31 Oct 2003 13:24:44 -0500 (EST) Date: Fri, 31 Oct 2003 13:27:12 -0500 From: Allen Landsidel Subject: Re: index creation order? In-reply-to: <200310310910.30504.josh@agliodbs.com> X-Sender: bsdasym@pop.hotpop.com To: Josh Berkus , pgsql-performance@postgresql.org Message-id: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/801 X-Sequence-Number: 4549 At 12:10 10/31/2003, Josh Berkus wrote: >Allen, > > > a) CREATE TABLE with no indexes or keys. Run the COPY (fast, ~30min), then > > CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk and > > each fk needed. > >Did you ANALYZE after the copy? No, and this was my major mistake. I normally run analyze periodically from cron, anywhere from once an hour to ever 15 minutes depending on the db.. I had disabled that for this because I didn't want anything competing with this stuff for disk I/O. I followed your other suggestions as well, canceled the index that was running, analyzed the whole db, and ran the queries again. All of them are running in under 10 or so minutes after the analyze. I'll just be adding the PKs and the Indexes, I can add triggers/rules of my own for the RI, rather than worry about FK creation screwing up. I had no idea analyze was playing such a big role in this sense.. I really thought that other than saving space, it wasn't doing much for tables that don't have indexes on the. Thanks for the help. > > shared_buffers = 30000 >hmmm ... 236MB .... > > max_fsm_pages = 2000000 >2MB, fine ... > > wal_buffers = 128 >1MB, also fine ... > > sort_mem = 1310720 (1.2GB) >Problem here. As documented everywhere, sort_mem is allocated *per sort* >not >per query, user, or shared. This means that if the "add PK" operation >involves 2 or more sorts (not sure, haven't tested it), then you're >allocating .7GB RAM more than you acutally have. This may be the cause of >your problem, particularly if *anything* is going on concurrent to the load. I didn't know this was per-sort per-backend, I thought it was per-backend for all sorts running on that backend. I've dropped it down to 256MB. > > checkpoint_segments = 64 >IF you have the disk space (+ 2GB) I'd raise this to 150-300 during the load >operation. Done, at 128, which seems to be enough for now. I'll fiddle more with this later on. > > commit_delay = 20000 > > commit_siblings = 2 >These settings are for heavy multi-user update activity. They are not useful >for a single-user load, and may even lower performance. That's what's going on.. this database I'm working on isn't the only one in the system, and some things are using different schemas in the database I'm working on, so this isn't something I can afford to turn off. Most of the activity is heavy and transient.. many INSERT/UPDATE/DELETE cycles. Again, thanks for the help, I really do appreciate it. It's gratifying and depressing to know the last two or so days work could've been compressed into 3 hours if I'd just run that damn analyze. ;) From pgsql-performance-owner@postgresql.org Fri Oct 31 14:27: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 D2971D1B93D for ; Fri, 31 Oct 2003 18:27: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 48317-10 for ; Fri, 31 Oct 2003 14:26:51 -0400 (AST) Received: from mta8.srv.hcvlny.cv.net (mta8.srv.hcvlny.cv.net [167.206.5.75]) by svr1.postgresql.org (Postfix) with ESMTP id 72094D1B58F for ; Fri, 31 Oct 2003 14:26:12 -0400 (AST) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta8.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNM0038FWJNZU@mta8.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 31 Oct 2003 13:26:12 -0500 (EST) Date: Fri, 31 Oct 2003 13:28:44 -0500 From: Allen Landsidel Subject: Re: index creation order? In-reply-to: <1067617409.17097.7.camel@jester> X-Sender: bsdasym@pop.hotpop.com To: Rod Taylor Cc: Postgresql Performance Message-id: <6.0.0.22.0.20031031132741.02405968@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <1067617409.17097.7.camel@jester> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/802 X-Sequence-Number: 4550 Nope, still 7.3.4 here.. I am very excited about 7.4 though.. almost as excited as I am about FreeBSD 5.x going -STABLE.. it's a close race between the two.. I'll keep this in mind for when I update though, thanks. At 11:23 10/31/2003, Rod Taylor wrote: >If it is 7.4 beta 5 or later, I would definitely go with A. > >Adding indexes after the fact seems to be much quicker. Foreign keys use >the same algorithm prior to beta 5 regardless of timing. > >A primary key and unique index will have approx the same performance (a >check for NULL isn't very costly). > >On Fri, 2003-10-31 at 11:02, Allen Landsidel wrote: > > Yet another question.. thanks to everyone responding to all these so > far.. ;) > > > > This one is basically.. given I have a big table already in COPY format, > > about 28 million rows, all keys guaranteed to be unique, I'm trying to > find > > out which of the following will get the import finished the fastest: > > > > a) CREATE TABLE with no indexes or keys. Run the COPY (fast, ~30min), > then > > CREATE INDEX on each column it's needed on, and ALTER TABLE for the pk and > > each fk needed. > > > > b) Same as above, but instead of ALTER TABLE -- ditch the FK, and CREATE > > UNIQUE INDEX on the PK. > > > > c) CREATE TABLE with the PK/FK's in the table structure, CREATE INDEX on > > needed columns, then run the COPY. > > > > d) .. is to c as b is to a .. Don't create PK/FK's, just CREATE UNIQUE > > INDEX after table creation, then run the COPY. > > > > My gut instinct tells me that in order, fastest to slowest, it's going to > > be d,b,c,a; this is what I've experienced on other DBs such as MSSQL and > > Oracle. > > > > If there isn't a significant difference between all of them, performance > > wise, I think something is dreadfully wrong here. Running "a", the ALTER > > TABLE to add the PK ran for 17 hours and still wasn't finished. > > > > The table without indexes or keys is: > > CREATE TABLE foo ( > > id BIGINT NOT NULL DEFAULT nextval('foo_id_sequence'), > > master_id BIGINT NOT NULL, > > other_id INTEGER NOT NULL, > > status INTEGER NOT NULL, > > addtime TIMESTAMP WITH TIME ZONE DEFAULT now() > > ); > > > > Details on machine and configuration are: > > > > The machine is the same one I've mentioned before.. SMP AthlonMP 2800+ > > (2.1GHz), 4x18GB 15krpm SCSI RAID-0 with 256MB onboard cache on a > > quad-channel ICP-Vortex controller, 2GB physical memory. Running FreeBSD > > RELENG_4, relevant filesystems with softupdates enabled and mounted > noatime. > > > > kernel options are: > > maxusers 0 > > > > options MAXDSIZ="(1536UL*1024*1024)" # maximum limit > > options MAXSSIZ="(512UL*1024*1024)" # maximum stack > > options DFLDSIZ="(512UL*1024*1024)" # default limit > > options VM_BCACHE_SIZE_MAX="(384UL*1024*1024)" # cache size upped > > from default 200MB > > options SYSVSHM #SYSV-style shared memory > > options SYSVMSG #SYSV-style message queues > > options SYSVSEM #SYSV-style semaphores > > options SHMMAXPGS=262144 > > options SHMALL=262144 > > options SHMSEG=256 > > options SEMMNI=384 > > options SEMMNS=768 > > options SEMMNU=384 > > options SEMMAP=384 > > > > postgresql.conf settings are: > > > > shared_buffers = 30000 > > max_fsm_relations = 10000 > > max_fsm_pages = 2000000 > > max_locks_per_transaction = 64 > > wal_buffers = 128 > > sort_mem = 1310720 (1.2GB) > > vacuum_mem = 262144 (256MB) > > checkpoint_segments = 64 > > checkpoint_timeout = 1200 > > commit_delay = 20000 > > commit_siblings = 2 > > fsync=true > > random_page_cost = 1.7 > > cpu_tuple_cost = 0.005 > > cpu_index_tuple_cost = 0.005 > > cpu_operator_cost = 0.0012 > > > > stats_start_collector = true > > stats_command_string = true > > stats_row_level = true > > stats_block_level = true > > > > > > ---------------------------(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 Oct 31 14:40: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 F1FA3D1B4F1 for ; Fri, 31 Oct 2003 18: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 49354-08 for ; Fri, 31 Oct 2003 14:40:27 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id DA778D1B89E for ; Fri, 31 Oct 2003 14:40:25 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id AC25A1E2E; Fri, 31 Oct 2003 13:40:24 -0500 (EST) Subject: Re: index creation order? From: Neil Conway To: Allen Landsidel Cc: Josh Berkus , PostgreSQL Performance In-Reply-To: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> Content-Type: text/plain Message-Id: <1067625622.451.0.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 31 Oct 2003 13:40:22 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/803 X-Sequence-Number: 4551 On Fri, 2003-10-31 at 13:27, Allen Landsidel wrote: > I had no idea analyze was playing such a big role in this sense.. I really > thought that other than saving space, it wasn't doing much for tables that > don't have indexes on the. ANALYZE doesn't save any space at all -- VACUUM is probably what you're thinking of. -Neil From pgsql-performance-owner@postgresql.org Fri Oct 31 14:46: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 97855D1B8DE for ; Fri, 31 Oct 2003 18:46: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 49184-10 for ; Fri, 31 Oct 2003 14:45:51 -0400 (AST) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id B67E8D1B58F for ; Fri, 31 Oct 2003 14:45:50 -0400 (AST) Received: from 6-allhosts (d226-89-59.home.cgocable.net [24.226.89.59]) by bob.samurai.com (Postfix) with ESMTP id 80A891ED2; Fri, 31 Oct 2003 13:45:50 -0500 (EST) Subject: Re: Pg+Linux swap use From: Neil Conway To: Greg Stark Cc: Bill Moran , PostgreSQL Performance In-Reply-To: <87ekwtbbxi.fsf@stark.dyndns.tv> References: <007c01c39fc4$0844f850$640101c0@rob> <3FA285F5.6020408@potentialtech.com> <87ekwtbbxi.fsf@stark.dyndns.tv> Content-Type: text/plain Message-Id: <1067625948.447.4.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 31 Oct 2003 13:45:48 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/804 X-Sequence-Number: 4552 On Fri, 2003-10-31 at 11:37, Greg Stark wrote: > My understanding is that the case where HT hurts is precisely your case. When > you have two real processors with HT the kernel will sometimes schedule two > jobs on the two virtual processors on the same real processor leaving the two > virtual processors on the other real processor idle. If you're seeing this behavior, it's sounds like a bug/deficiency in your kernel's scheduler: if it is HT-aware, it should go to some lengths to avoid this kind of processor allocation. -Neil From pgsql-performance-owner@postgresql.org Fri Oct 31 15:31: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 A40FFD1B91A for ; Fri, 31 Oct 2003 19: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 52451-06 for ; Fri, 31 Oct 2003 15:06:58 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 3C3B4D1B936 for ; Fri, 31 Oct 2003 15:06:57 -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 h9VJ5HBv007992; Fri, 31 Oct 2003 12:05:18 -0700 (MST) Date: Fri, 31 Oct 2003 11:52:35 -0700 (MST) From: "scott.marlowe" To: "alexandre :: aldeia digital" Cc: Subject: Re: Pg+Linux swap use In-Reply-To: <3456.192.168.1.120.1067609039.squirrel@webmail.ad2.com.br> 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: 200310/807 X-Sequence-Number: 4555 We had a problem at work that when a windows box would connect to a samba share with a lot of files in it, the kswapd was going nuts, even though we weren't low on memory at all. Updating to the 2.4.18 or so of the later redhats fixed that issue. It might be related. I think the kflush daemon can get fooled into thinking it needs to get hoppin right now in older 2.4.x kernels. On Fri, 31 Oct 2003, alexandre :: aldeia digital wrote: > Scott, Jeff and Shridhar: > > 1 GB RAM :) > > The stock kernels are not the same, HyperThreading enabled. 80 > simultaneous connections. sort_mem = 4096 > > I will compile my own kernel on this weekend, and I will report > to the list after. > > Thank's all > > Alexandre > > > > Also are two kernels exactly same? In my experience linux kernel behaves > > slightly different from version to version w.r.t swap aggressiveness... > > > > Shridhar > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > > ---------------------------(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 Fri Oct 31 15:08: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 8B8C0D1B8D7 for ; Fri, 31 Oct 2003 18:59: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 51644-04 for ; Fri, 31 Oct 2003 14:58:55 -0400 (AST) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 9B8C7D1B53F for ; Fri, 31 Oct 2003 14:58:53 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3850277; Fri, 31 Oct 2003 10:59:35 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Allen Landsidel , pgsql-performance@postgresql.org Subject: Re: index creation order? Date: Fri, 31 Oct 2003 10:58:19 -0800 User-Agent: KMail/1.4.3 References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> In-Reply-To: <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310311058.19455.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/805 X-Sequence-Number: 4553 Allen, > I had no idea analyze was playing such a big role in this sense.. I really > thought that other than saving space, it wasn't doing much for tables that > don't have indexes on the. Among other things, ANALYZE tells postgres how many rows are in the table. So if you add a PK constraint after loading 10 million rows without ANALYZE, PostgreSQL is likely to think that there is only one row in the table ... and choose a nested loop or some other really inefficient method of checking for uniqueness. -- Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Oct 31 15:10: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 169D4D1B4F1 for ; Fri, 31 Oct 2003 18:59: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 51534-07 for ; Fri, 31 Oct 2003 14:59:14 -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 20F07D1B8B5 for ; Fri, 31 Oct 2003 14:59:13 -0400 (AST) Received: from megalomaniac.biosys.net (ool-43529ac2.dyn.optonline.net [67.82.154.194]) by mta10.srv.hcvlny.cv.net (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNM00JY4Y2OLZ@mta10.srv.hcvlny.cv.net> for pgsql-performance@postgresql.org; Fri, 31 Oct 2003 13:59:13 -0500 (EST) Date: Fri, 31 Oct 2003 14:01:28 -0500 From: Allen Landsidel Subject: Re: index creation order? In-reply-to: <1067625622.451.0.camel@tokyo> X-Sender: bsdasym@pop.hotpop.com To: Neil Conway Cc: Josh Berkus , PostgreSQL Performance Message-id: <6.0.0.22.0.20031031135905.023f9140@pop.hotpop.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <6.0.0.22.0.20031031104214.024853b0@pop.hotpop.com> <200310310910.30504.josh@agliodbs.com> <6.0.0.22.0.20031031131506.024864b0@pop.hotpop.com> <1067625622.451.0.camel@tokyo> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/806 X-Sequence-Number: 4554 At 13:40 10/31/2003, Neil Conway wrote: >On Fri, 2003-10-31 at 13:27, Allen Landsidel wrote: > > I had no idea analyze was playing such a big role in this sense.. I really > > thought that other than saving space, it wasn't doing much for tables that > > don't have indexes on the. > >ANALYZE doesn't save any space at all -- VACUUM is probably what you're >thinking of. Actually, I was thinking VACUUM ANALYZE.. which is what I ran after the COPY.. sorry for my lack of precision. I've yet to run straight-up ANALYZE AFAIK. -Allen From pgsql-performance-owner@postgresql.org Fri Oct 31 16:33: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 8AE8CD1B4E9 for ; Fri, 31 Oct 2003 20:33: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 73367-06 for ; Fri, 31 Oct 2003 16:32:54 -0400 (AST) Received: from arbor.net (division.aa.arbor.net [204.181.64.2]) by svr1.postgresql.org (Postfix) with ESMTP id D32F3D1B4F2 for ; Fri, 31 Oct 2003 16:32:45 -0400 (AST) Received: by arbor.net (Postfix, from userid 1065) id A6CAA2A891; Fri, 31 Oct 2003 15:32:30 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by arbor.net (Postfix) with ESMTP id A521A2A88C for ; Fri, 31 Oct 2003 15:32:30 -0500 (EST) Date: Fri, 31 Oct 2003 15:32:30 -0500 (EST) From: Chester Kustarz To: pgsql-performance@postgresql.org Subject: Re: index creation order? In-Reply-To: <200310311058.19455.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: 200310/808 X-Sequence-Number: 4556 is there any way to update the stats inside a transaction? what i have is something like: select count(*) from foo; -> 0 begin; copy foo from '/tmp/foo'; -- about 100k rows -- run some queries on foo which perform horribly because the stats -- are way off (100k rows v. 0 rows) commit; it seems that you cannot run analyze inside a transaction: begin; analyze foo; ERROR: ANALYZE cannot run inside a BEGIN/END block i am using version 7.2.3. any work-a-rounds? should i try updating pg_statistic manually? On Fri, 31 Oct 2003, Josh Berkus wrote: > Among other things, ANALYZE tells postgres how many rows are in the table. So > if you add a PK constraint after loading 10 million rows without ANALYZE, > PostgreSQL is likely to think that there is only one row in the table ... and > choose a nested loop or some other really inefficient method of checking for > uniqueness. From pgsql-performance-owner@postgresql.org Fri Oct 31 16:51: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 CD88AD1B4E6 for ; Fri, 31 Oct 2003 20: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 74292-06 for ; Fri, 31 Oct 2003 16:51:28 -0400 (AST) Received: from wlesca.coopelesca.co.cr (wlesca.coopelesca.co.cr [200.9.39.10]) by svr1.postgresql.org (Postfix) with ESMTP id 5D045D1B4E8 for ; Fri, 31 Oct 2003 16:51:26 -0400 (AST) Received: from coopelesca.co.cr (mailhost [172.16.0.10]) by wlesca.coopelesca.co.cr (8.12.8+Sun/8.12.2) with SMTP id h9VKmtU7003515 for ; Fri, 31 Oct 2003 14:48:55 -0600 (CST) Received: from WorldClient by coopelesca.co.cr (MDaemon.PRO.v6.8.5.R) with ESMTP id 30-md50000000014.tmp; Fri, 31 Oct 2003 14:55:12 -0600 Received: from [200.9.39.12] via WorldClient with HTTP; Fri, 31 Oct 2003 14:55:12 -0600 Date: Fri, 31 Oct 2003 14:55:12 -0600 From: "PostgreSQL" To: pgsql-performance@postgresql.org Subject: Postgres 7.3.4 + Slackware 9.1 Message-ID: X-Mailer: WorldClient 6.8.5 X-Priority: 1 (Highest) X-Spam-Processed: coopelesca.co.cr, Fri, 31 Oct 2003 14:55:12 -0600 (not processed: spam filter disabled) X-Return-Path: postgres@coopelesca.co.cr X-MDaemon-Deliver-To: pgsql-performance@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/809 X-Sequence-Number: 4557 Hello all! Do anyone have experience installing Postgres 7.3.4 on Slackware 9.1? Do exist any trouble, bug, problem... or is a good MIX? I want to "leave" RedHat (9) because is not "free" anymore and i don't want to use fedora BETA TEST versions. Any suggestion? THANKS ALL. From pgsql-performance-owner@postgresql.org Fri Oct 31 16:58: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 673F7D1B4F9 for ; Fri, 31 Oct 2003 20:58: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 76288-02 for ; Fri, 31 Oct 2003 16:57: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 374A3D1B4E9 for ; Fri, 31 Oct 2003 16:57:37 -0400 (AST) Received: (qmail 12536 invoked from network); 31 Oct 2003 20:56:49 -0000 Received: from unknown (HELO ?10.0.2.5?) (216.208.117.7) by 205.178.180.9 with SMTP; 31 Oct 2003 20:56:49 -0000 Subject: Re: index creation order? From: Rod Taylor To: Chester Kustarz Cc: Postgresql Performance In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-E5YI87qiqRrToanNbv0t" Message-Id: <1067633857.17097.110.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 31 Oct 2003 15:57:38 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/810 X-Sequence-Number: 4558 --=-E5YI87qiqRrToanNbv0t Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > begin; > analyze foo; > ERROR: ANALYZE cannot run inside a BEGIN/END block >=20 > i am using version 7.2.3. Time to upgrade. 7.3 / 7.4 allows this to happen. --=-E5YI87qiqRrToanNbv0t Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQA/oszB6DETLow6vwwRAnOLAJ96t9q790ha+fqff+wCmMCi6O3XXACggNQC WWhhVS/DHBMQ+/5a/WdqFWY= =tiIS -----END PGP SIGNATURE----- --=-E5YI87qiqRrToanNbv0t-- From pgsql-performance-owner@postgresql.org Fri Oct 31 17:32:21 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 6C2D1D1B592 for ; Fri, 31 Oct 2003 21:32: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 83100-07 for ; Fri, 31 Oct 2003 17:31:49 -0400 (AST) Received: from mailout04.sul.t-online.com (mailout04.sul.t-online.com [194.25.134.18]) by svr1.postgresql.org (Postfix) with ESMTP id BDC64D1B54F for ; Fri, 31 Oct 2003 17:31:46 -0400 (AST) Received: from fwd09.aul.t-online.de by mailout04.sul.t-online.com with smtp id 1AFgrz-0004OW-0B; Fri, 31 Oct 2003 22:31:47 +0100 Received: from router.azrael.de (ZYmU+QZdYeF2k+tx161cTKrGhbKxyY+wN7TTeV1lFYxvkAL-bn-44-@[80.141.228.6]) by fmrl09.sul.t-online.com with esmtp id 1AFgru-0BOhgu0; Fri, 31 Oct 2003 22:31:42 +0100 Received: from azrael.azrael.de (azrael.azrael.de [192.168.202.18]) by router.azrael.de (8.11.4/8.11.4) with ESMTP id h9VLV3N27520 for ; Fri, 31 Oct 2003 22:31:09 +0100 Date: Fri, 31 Oct 2003 22:31:43 +0100 From: Evil Azrael X-Mailer: The Bat! (v2.00.6) UNREG / CD5BF9353B3B7091 X-Priority: 3 (Normal) Message-ID: <9911159656.20031031223143@evilazrael.de> Cc: pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.4 + Slackware 9.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit X-Seen: false X-ID: ZYmU+QZdYeF2k+tx161cTKrGhbKxyY+wN7TTeV1lFYxvkAL-bn-44-@t-dialin.net X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/811 X-Sequence-Number: 4559 Hi! I haven�t really tested it on Slackware 9.1. But i am running Postgresql now for over two years on various Slackware versions. My current server is running on Slackware 8.0 with a lot of packages (especially the core libs) upgraded to slack 9.1 packages. I had never problems with postgresql related to slackware except that the old 8.0 readline packages was too old for postgresql 7.3.x, but that was not really a problem. But it seems, there�s no prepackaged Postgresql for Slackware, so you would have to compile it yourself. Christoph Nelles Am Freitag, 31. Oktober 2003 um 21:55 schrieben Sie: P> Hello all! P> Do anyone have experience installing Postgres 7.3.4 on Slackware 9.1? P> Do exist any trouble, bug, problem... or is a good MIX? P> I want to "leave" RedHat (9) because is not "free" anymore and i don't P> want to use fedora BETA TEST versions. P> Any suggestion? P> THANKS ALL. P> ---------------------------(end of P> broadcast)--------------------------- P> TIP 5: Have you checked our extensive FAQ? P> http://www.postgresql.org/docs/faqs/FAQ.html -- Mit freundlichen Gr�ssen Evil Azrael mailto:evilazrael@evilazrael.de From pgsql-performance-owner@postgresql.org Fri Oct 31 17:34: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 BCB4AD1B50A for ; Fri, 31 Oct 2003 21:34: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 84309-07 for ; Fri, 31 Oct 2003 17:33:44 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id C9A4BD1B8A2 for ; Fri, 31 Oct 2003 17:33: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 h9VLXWX6020010; Fri, 31 Oct 2003 16:33:32 -0500 (EST) To: Chester Kustarz Cc: pgsql-performance@postgresql.org Subject: Re: index creation order? In-reply-to: References: Comments: In-reply-to Chester Kustarz message dated "Fri, 31 Oct 2003 15:32:30 -0500" Date: Fri, 31 Oct 2003 16:33:32 -0500 Message-ID: <20009.1067636012@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/812 X-Sequence-Number: 4560 Chester Kustarz writes: > it seems that you cannot run analyze inside a transaction: You can in 7.3.* ... regards, tom lane From pgsql-performance-owner@postgresql.org Sat Nov 1 13:54: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 C1E85D1B93F for ; Fri, 31 Oct 2003 21:39: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 84235-07 for ; Fri, 31 Oct 2003 17:38:43 -0400 (AST) Received: from ctg-msnex01.staff.berbee.com (msn-office1.binc.net [64.73.12.254]) by svr1.postgresql.org (Postfix) with ESMTP id 6198ED1B523 for ; Fri, 31 Oct 2003 17:38:40 -0400 (AST) Received: from localhost ([172.30.254.220] RDNS failed) by ctg-msnex01.staff.berbee.com with Microsoft SMTPSVC(5.0.2195.5329); Fri, 31 Oct 2003 15:38:40 -0600 From: "Jeremy M. Guthrie" Reply-To: jeremy.guthrie@berbee.com Organization: Berbee Information Networks To: "PostgreSQL" , pgsql-performance@postgresql.org Subject: Re: Postgres 7.3.4 + Slackware 9.1 Date: Fri, 31 Oct 2003 15:38:38 -0600 User-Agent: KMail/1.5.4 References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200310311538.39888.jeremy.guthrie@berbee.com> X-OriginalArrivalTime: 31 Oct 2003 21:38:40.0898 (UTC) FILETIME=[59CEF620:01C39FF7] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/3 X-Sequence-Number: 4563 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I run Slackware 9.1 and Postgres 7.3.4. I compiled Postgres from source an= d I=20 have actually had fewer problems with it then on Redhat 8. On Friday 31 October 2003 02:55 pm, PostgreSQL wrote: > Hello all! > > Do anyone have experience installing Postgres 7.3.4 on Slackware 9.1? > > Do exist any trouble, bug, problem... or is a good MIX? > > I want to "leave" RedHat (9) because is not "free" anymore and i don't > want to use fedora BETA TEST versions. > > Any suggestion? > > THANKS ALL. > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html - --=20 Jeremy M. Guthrie Systems Engineer Berbee 5520 Research Park Dr. Madison, WI 53711 Phone: 608-298-1061 Berbee...Decade 1. 1993-2003 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/otZeqtjaBHGZBeURArn+AJ4leCrBQIm2fj01davX4n9FcMs2lgCeLisL C0+9VnkJn7EFelWLm4RGrRA=3D =3DumPm -----END PGP SIGNATURE-----