From pgsql-performance-owner@postgresql.org Tue Apr 1 07:23:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C83FF475F1B for ; Tue, 1 Apr 2003 07:23:30 -0500 (EST) Received: from spirit.aldeiadigital.com.br (iplus-fac-213-137.xdsl-fixo.ctbcnetsuper.com.br [200.225.213.137]) by postgresql.org (Postfix) with ESMTP id AE3B8475AF8 for ; Tue, 1 Apr 2003 07:23:28 -0500 (EST) Received: from aldeiadigital.com.br (localhost.localdomain [127.0.0.1]) by spirit.aldeiadigital.com.br (8.11.6/8.11.6) with SMTP id h31CNfa13948 for ; Tue, 1 Apr 2003 09:23:42 -0300 Received: from 200.170.156.137 (proxying for 126.0.0.10) (SquirrelMail authenticated user alepaes) by webmail.ad2.com.br with HTTP; Tue, 1 Apr 2003 09:23:42 -0300 (BRT) Message-ID: <39940.200.170.156.137.1049199822.squirrel@webmail.ad2.com.br> Date: Tue, 1 Apr 2003 09:23:42 -0300 (BRT) Subject: Re: 30-70 seconds query... From: "alexandre :: aldeia digital" To: In-Reply-To: <25846.1049151512@sss.pgh.pa.us> References: <10846.200.225.202.15.1049145207.squirrel@webmail.ad2.com.br> <25610.1049149040@sss.pgh.pa.us> <25846.1049151512@sss.pgh.pa.us> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-Mailer: SquirrelMail (version 1.2.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-25.1 required=5.0 tests=BAYES_10,IN_REP_TO,MISSING_MIMEOLE,MISSING_OUTLOOK_NAME, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/1 X-Sequence-Number: 1507 Tom, I will try the current snapshot and I will report in the list. Thanks to Tomasz Myrta too for the help. Alexandre > I said: >> PG 7.4 will be better prepared to handle this sort of query, but I >> don't think it will realize that the T1/T2 left join could be reduced >> to a plain join given these conditions > > I take that back --- actually, the algorithm used in CVS tip *does* > deduce that all these left joins can be plain joins. > > Don't suppose you'd like to experiment with a current snapshot to see > how well it does for you? > > regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 1 12:25:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 10E0C47621C for ; Tue, 1 Apr 2003 12:25:39 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id A9CF0476178 for ; Tue, 1 Apr 2003 12:25:34 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h31HFXr08210; Tue, 1 Apr 2003 12:15:33 -0500 Message-ID: <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Shankar K" , References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> Subject: Re: ext3 filesystem / linux 7.3 Date: Tue, 1 Apr 2003 12:33:15 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-16.9 required=5.0 tests=BAYES_20,MAILTO_TO_SPAM_ADDR,ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT,RCVD_IN_NJABL,REFERENCES, X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/2 X-Sequence-Number: 1508 What is the URL of that article? I understood that ext2 was faster with PG and so I went to a lot of trouble of creating an ext2 partition just for PG and gave up the journalling to do that. Something about double effort since PG already does a lot of that. Bruce, is there a final determination of which is faster/safer? Jeff ----- Original Message ----- From: "Shankar K" To: Sent: Monday, March 31, 2003 3:55 PM Subject: [PERFORM] ext3 filesystem / linux 7.3 > hi there, > > I was reading bruce's 'postgresql hardware performance > tuning' article and he has suggested ext3 filesystem > with data mode = writeback for high performance. > > I would really appreciate if anyone could share your > experiences with ext3 from a production stand point or > any other suggestions for best read/write performance. > > Our applications is an hybrid of heavy inserts/updates > and DSS queries. > > version - postgres 7.3.2 > hardware - raid 5 (5 x 73 g hardware raid), 4g ram, 2 > * 2.8 GHz cpu, redhat 7.3 > > Note : we don't have the luxury of raid 1+0 (dedicated > disks) for xlog and clog files to start with but may > be down the line we might look into those options, but > for now i've planned on having them on local drives > rather than raid 5. > > thanks for any inputs, > Shankar > > > > > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! > http://platinum.yahoo.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Tue Apr 1 12:39:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8037476348 for ; Tue, 1 Apr 2003 12:39:12 -0500 (EST) Received: from web21101.mail.yahoo.com (web21101.mail.yahoo.com [216.136.227.103]) by postgresql.org (Postfix) with SMTP id 9CA2C476304 for ; Tue, 1 Apr 2003 12:39:11 -0500 (EST) Message-ID: <20030401173917.19476.qmail@web21101.mail.yahoo.com> Received: from [208.253.218.33] by web21101.mail.yahoo.com via HTTP; Tue, 01 Apr 2003 09:39:17 PST Date: Tue, 1 Apr 2003 09:39:17 -0800 (PST) From: Shankar K Subject: Re: ext3 filesystem / linux 7.3 To: pgsql-performance@postgresql.org Cc: "Jeffrey D. Brower" In-Reply-To: <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-8.5 required=5.0 tests=BAYES_01,FROM_ENDS_IN_NUMS,IN_REP_TO,MAILTO_TO_SPAM_ADDR autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/3 X-Sequence-Number: 1509 hi jeff, go to http://www.ca.postgresql.org/docs/momjian/hw_performance/ under 'filesystems' slide. snip File system choice is particularly difficult on Linux because there are so many file system choices, and none of them are optimal: ext2 is not entirely crash-safe, ext3, XFS, and JFS are journal-based, and Reiser is optimized for small files and does journalling. The journalling file systems can be significantly slower than ext2 but when crash recovery is required, ext2 isn't an option. If ext2 must be used, mount it with sync enabled. Some people recommend XFS or an ext3 filesystem mounted with data=writeback. /snip --- "Jeffrey D. Brower" wrote: > What is the URL of that article? I understood that > ext2 was faster with PG > and so I went to a lot of trouble of creating an > ext2 partition just for PG > and gave up the journalling to do that. Something > about double effort since > PG already does a lot of that. > > Bruce, is there a final determination of which is > faster/safer? > > Jeff > > ----- Original Message ----- > From: "Shankar K" > To: > Sent: Monday, March 31, 2003 3:55 PM > Subject: [PERFORM] ext3 filesystem / linux 7.3 > > > > hi there, > > > > I was reading bruce's 'postgresql hardware > performance > > tuning' article and he has suggested ext3 > filesystem > > with data mode = writeback for high performance. > > > > I would really appreciate if anyone could share > your > > experiences with ext3 from a production stand > point or > > any other suggestions for best read/write > performance. > > > > Our applications is an hybrid of heavy > inserts/updates > > and DSS queries. > > > > version - postgres 7.3.2 > > hardware - raid 5 (5 x 73 g hardware raid), 4g > ram, 2 > > * 2.8 GHz cpu, redhat 7.3 > > > > Note : we don't have the luxury of raid 1+0 > (dedicated > > disks) for xlog and clog files to start with but > may > > be down the line we might look into those options, > but > > for now i've planned on having them on local > drives > > rather than raid 5. > > > > thanks for any inputs, > > Shankar > > > > > > > > > > > > > > __________________________________________________ > > Do you Yahoo!? > > Yahoo! Platinum - Watch CBS' NCAA March Madness, > live on your desktop! > > http://platinum.yahoo.com > > > > > > ---------------------------(end of > broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://platinum.yahoo.com From pgsql-performance-owner@postgresql.org Tue Apr 1 12:53:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 19FDD475EEE for ; Tue, 1 Apr 2003 12:53:55 -0500 (EST) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id ECDFF475E4D for ; Tue, 1 Apr 2003 12:53:49 -0500 (EST) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id 1481653B8B3; Tue, 1 Apr 2003 09:53:51 -0800 (PST) X-Mailer: UserLand Frontier 9.1b2 (Macintosh OS) (mailServer v1.1..144) Mime-Version: 1.0 Message-Id: <26287373.1162931668@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <20030401173917.19476.qmail@web21101.mail.yahoo.com> Date: Tue, 01 Apr 2003 09:53:48 -0800 To: Shankar K , pgsql-performance@postgresql.org Cc: Jeffrey D.Brower From: eric soroos Subject: Re: ext3 filesystem / linux 7.3 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-5.7 required=5.0 tests=BAYES_20,IN_REP_TO,MAILTO_TO_SPAM_ADDR autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/4 X-Sequence-Number: 1510 On Tue, 1 Apr 2003 09:39:17 -0800 (PST) in message <20030401173917.19476.qmail@web21101.mail.yahoo.com>, Shankar K wrote: > hi jeff, > > go to > http://www.ca.postgresql.org/docs/momjian/hw_performance/ > under 'filesystems' slide. > I suspect that is what he's seen. From my experience, ext3 is only a percent or two slower than ext2 under pg_bench. It saves an amazing amount of time on startup after a failure by not having to fsck to confirm that the filesystem is in a consistent state. I believe that ext3 is a metadata journaling system, and not a data journaling system. This would indicate that the PG transactioning is complimentary to the filesystem journaling, not duplication. eric From pgsql-performance-owner@postgresql.org Tue Apr 1 12:54:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 32E11475E4D for ; Tue, 1 Apr 2003 12:54:48 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 84FFA47592C for ; Tue, 1 Apr 2003 12:54:46 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h31HsjM25421; Tue, 1 Apr 2003 12:54:45 -0500 (EST) From: Bruce Momjian Message-Id: <200304011754.h31HsjM25421@candle.pha.pa.us> Subject: Re: ext3 filesystem / linux 7.3 In-Reply-To: <20030401173917.19476.qmail@web21101.mail.yahoo.com> To: Shankar K Date: Tue, 1 Apr 2003 12:54:45 -0500 (EST) Cc: pgsql-performance@postgresql.org, "Jeffrey D. Brower" X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, hits=-25.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,MAILTO_TO_SPAM_ADDR, QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/5 X-Sequence-Number: 1511 I have heard XFS with the mount option is fastest. --------------------------------------------------------------------------- Shankar K wrote: > hi jeff, > > go to > http://www.ca.postgresql.org/docs/momjian/hw_performance/ > under 'filesystems' slide. > > snip > > File system choice is particularly difficult on Linux > because there are so many file system choices, and > none of them are optimal: ext2 is not entirely > crash-safe, ext3, XFS, and JFS are journal-based, and > Reiser is optimized for small files and does > journalling. The journalling file systems can be > significantly slower than ext2 but when crash recovery > is required, ext2 isn't an option. If ext2 must be > used, mount it with sync enabled. Some people > recommend XFS or an ext3 filesystem mounted with > data=writeback. > > /snip > > --- "Jeffrey D. Brower" wrote: > > What is the URL of that article? I understood that > > ext2 was faster with PG > > and so I went to a lot of trouble of creating an > > ext2 partition just for PG > > and gave up the journalling to do that. Something > > about double effort since > > PG already does a lot of that. > > > > Bruce, is there a final determination of which is > > faster/safer? > > > > Jeff > > > > ----- Original Message ----- > > From: "Shankar K" > > To: > > Sent: Monday, March 31, 2003 3:55 PM > > Subject: [PERFORM] ext3 filesystem / linux 7.3 > > > > > > > hi there, > > > > > > I was reading bruce's 'postgresql hardware > > performance > > > tuning' article and he has suggested ext3 > > filesystem > > > with data mode = writeback for high performance. > > > > > > I would really appreciate if anyone could share > > your > > > experiences with ext3 from a production stand > > point or > > > any other suggestions for best read/write > > performance. > > > > > > Our applications is an hybrid of heavy > > inserts/updates > > > and DSS queries. > > > > > > version - postgres 7.3.2 > > > hardware - raid 5 (5 x 73 g hardware raid), 4g > > ram, 2 > > > * 2.8 GHz cpu, redhat 7.3 > > > > > > Note : we don't have the luxury of raid 1+0 > > (dedicated > > > disks) for xlog and clog files to start with but > > may > > > be down the line we might look into those options, > > but > > > for now i've planned on having them on local > > drives > > > rather than raid 5. > > > > > > thanks for any inputs, > > > Shankar > > > > > > > > > > > > > > > > > > > > > __________________________________________________ > > > Do you Yahoo!? > > > Yahoo! Platinum - Watch CBS' NCAA March Madness, > > live on your desktop! > > > http://platinum.yahoo.com > > > > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > > TIP 1: subscribe and unsubscribe commands go to > > majordomo@postgresql.org > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online, calculators, forms, and more > http://platinum.yahoo.com > > > ---------------------------(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-performance-owner@postgresql.org Tue Apr 1 12:55:15 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8A2A475F34 for ; Tue, 1 Apr 2003 12:55:13 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 3F21D475E4D for ; Tue, 1 Apr 2003 12:55:13 -0500 (EST) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 190Pyh-00017A-00 for ; Tue, 01 Apr 2003 12:55:19 -0500 Received: from andrew by dba2 with local (Exim 3.36 #1 (Debian)) id 190Pyh-0002Xm-00 for ; Tue, 01 Apr 2003 12:55:19 -0500 Date: Tue, 1 Apr 2003 12:55:19 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Message-ID: <20030401175519.GA9553@mail> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-34.8 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/6 X-Sequence-Number: 1512 On Tue, Apr 01, 2003 at 12:33:15PM -0500, Jeffrey D. Brower wrote: > What is the URL of that article? I understood that ext2 was faster with PG > and so I went to a lot of trouble of creating an ext2 partition just for PG > and gave up the journalling to do that. Something about double effort since > PG already does a lot of that. I don't know how ext3 could be faster than ext2, since it has to do more work. But ext2 is not crash-safe. So your data could well be hosed if you come back from a crash on ext2. Actually, I have my doubts about _any_ of the journaling filesystems for Linux: ext3 has a reputation for being slow if you journal in the real-safe mode, and there have been so many unrepeatable reiserfs problem reports that I'm loathe to use it for real systems. I had exceptionally good experiences with xfs when I was admining SGI boxes, but that's not part of the standard Linux kernel distribution, and with no idea why, I think my managers would get grumpy with me for using it. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Tue Apr 1 13:26:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8749E475CBC for ; Tue, 1 Apr 2003 13:26:13 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id 34DF4475AF8 for ; Tue, 1 Apr 2003 13:26:12 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h31IQ2S29201; Tue, 1 Apr 2003 13:26:02 -0500 (EST) From: Bruce Momjian Message-Id: <200304011826.h31IQ2S29201@candle.pha.pa.us> Subject: Re: ext3 filesystem / linux 7.3 In-Reply-To: <26287373.1162931668@[4.42.179.151]> To: eric soroos Date: Tue, 1 Apr 2003 13:26:02 -0500 (EST) Cc: Shankar K , pgsql-performance@postgresql.org, "Jeffrey D.Brower" X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, hits=-25.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,MAILTO_TO_SPAM_ADDR, QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/7 X-Sequence-Number: 1513 eric soroos wrote: > On Tue, 1 Apr 2003 09:39:17 -0800 (PST) in message > <20030401173917.19476.qmail@web21101.mail.yahoo.com>, Shankar > K wrote: > > hi jeff, > > > > go to > > http://www.ca.postgresql.org/docs/momjian/hw_performance/ > > under 'filesystems' slide. > > > > I suspect that is what he's seen. > > >From my experience, ext3 is only a percent or two slower than ext2 under pg_bench. It saves an amazing amount of time on startup after a failure by not having to fsck to confirm that the filesystem is in a consistent state. > > I believe that ext3 is a metadata journaling system, and not a > data journaling system. This would indicate that the PG > transactioning is complimentary to the filesystem journaling, > not duplication. Ext3 is only metadata journaling if you set the mount flags as described. I also don't think pgbench is the best test for testing file system 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 Tue Apr 1 14:27:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC04747621C for ; Tue, 1 Apr 2003 14:27:35 -0500 (EST) Received: from mailrelay (technicacorp.com [216.181.29.134]) by postgresql.org (Postfix) with ESMTP id D4A364760CC for ; Tue, 1 Apr 2003 14:27:34 -0500 (EST) thread-index: AcL4hLkaPHjk8tWvTL+s4AJ78XT9fw== Content-Transfer-Encoding: 7bit Received: from WWWSERVER.technicacorp.com ([216.181.29.149]) by mailrelay with Microsoft SMTPSVC(5.0.2195.5329); Tue, 1 Apr 2003 14:27:21 -0500 Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Received: by wwwserver with Internet Mail Service (5.5.2656.59) id ; Tue, 1 Apr 2003 14:31:13 -0500 Message-ID: <71F044551C53974EB0735B3737EFE2FC088645@wwwserver> From: "Scott Buchan" To: Subject: Postgresql performance on Solaris Date: Tue, 1 Apr 2003 14:31:13 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C2F885.4198FFC0" X-OriginalArrivalTime: 01 Apr 2003 19:27:21.0186 (UTC) FILETIME=[B7259420:01C2F884] X-Spam-Status: No, hits=-5.7 required=5.0 tests=BAYES_10,HTML_50_60,MISSING_OUTLOOK_NAME version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/8 X-Sequence-Number: 1514 This is a multi-part message in MIME format. ------_=_NextPart_001_01C2F885.4198FFC0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="iso-8859-1" Hi, I am getting poor performance from my postgresql (version 7.3.2 compiled with gcc 2.95.2) database when running load tests on my web application. The database works great until I get above 200 concurrent users. The following query runtime will vary from: explain analyze select TIMESTAMP, SPM_CONVSRCADDR, SPM_CONVDSTADDR, SPM_CONVSRCPORT, SPM_CONVDSTPORT, SPM_CONVPROTO, ACTION from FirewallLogs where TimeStamp>=1044939600000 and TimeStamp<=1047391020000 and spm_subid='462' and fqdn ='bs2@pcp' order by timestamp desc; QUERY PLAN ---------------------------------------------------------------------------- ----------------------------------------------------------------------- Sort (cost=3525.27..3527.49 rows=888 width=47) (actual time=55.65..56.16 rows=913 loops=1) Sort Key: "timestamp" -> Index Scan using firewalllogsindex on firewalllogs (cost=0.00..3481.77 rows=888 width=47) (actual time=0.40..50.33 rows=913 loops=1) Index Cond: ((fqdn = 'bs2@pcp'::character varying) AND ("timestamp" >= 1044939600000::bigint) AND ("timestamp" <= 1047391020000::bigint)) Filter: (spm_subid = 462) Total runtime: 57.36 msec (6 rows) to QUERY PLAN ---------------------------------------------------------------------------- ----------------------------------------------------------------------- Sort (cost=3525.27..3527.49 rows=888 width=47) (actual time=2323.79..2324.31 rows=913 loops=1) Sort Key: "timestamp" -> Index Scan using firewalllogsindex on firewalllogs (cost=0.00..3481.77 rows=888 width=47) (actual time=0.26..2318.11 rows=913 loops=1) Index Cond: ((fqdn = 'bs2@pcp'::character varying) AND ("timestamp" >= 1044939600000::bigint) AND ("timestamp" <= 1047391020000::bigint)) Filter: (spm_subid = 462) Total runtime: 2325.62 msec (6 rows) NOTE: I am only performing select queries - no inserts, deletes or updates. I am running postgresql on a SunFire v880 with 4 750MHz sparcv9 processors with 8 Gig of RAM running solaris 8. I have 2 tables with 500,000 records in each and both tables are indexed. I am connecting to the database through JDBC using a pool of connections (tried pools of 50, 100, and 200 with similar results). When running the load tests, the cpu of the box is always above 60% idle. I have run iostat and I am not seeing any problems with io. I have tried different size shared_buffers from 4100 to 64000, and I have added the following to the /etc/system file: set shmsys:shminfo_shmmax=0xffffffff set shmsys:shminfo_shmmin=1 set shmsys:shminfo_shmmni=256 set shmsys:shminfo_shmseg=256 set semsys:seminfo_semmap=256 set semsys:seminfo_semmni=512 set semsys:seminfo_semmns=512 set semsys:seminfo_semmsl=32 I understand that this could be a problem with the kernel and not postgresql but I am at a loss at what to change to get better performance out of the database or the kernel. Any help would be appreciated. ------_=_NextPart_001_01C2F885.4198FFC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi,

 

I am getting poor performance from my postgresql (version 7.3.2 compiled with gcc 2.95.2) database when running load tests on my web application.  The database works great until I get above 200 concurrent users.  The following query runtime will vary from:

 

explain analyze select TIMESTAMP, SPM_CONVSRCADDR,

SPM_CONVDSTADDR, SPM_CONVSRCPORT, SPM_CONVDSTPORT,

SPM_CONVPROTO, ACTION from FirewallLogs where TimeStamp&= gt;=3D1044939600000

and TimeStamp<=3D1047391020000 and spm_subid=3D'462' = and fqdn =3D'bs2@pcp' order by

timestamp desc;

         &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;        QUERY PLAN            = ;            &n= bsp;     

--------------------------------------------------------= ---------------------------------------------------------------------------= ----------------

 Sort  (cost=3D3525.27..3527.49 rows=3D888 wid= th=3D47) (actual time=3D55.65..56.16 rows=3D913 loops=3D1)

   Sort Key: "timestamp"

   ->  Index Scan using firewalllogsin= dex on firewalllogs  (cost=3D0.00..3481.77 rows=3D888 width=3D47) (actual time=3D0.40..50.33 rows=3D913 loops=3D1)

         Index C= ond: ((fqdn =3D 'bs2@pcp'::character varying) AND ("timestamp" >=3D 1044939600000::bigint) AND ("timestamp" <=3D 1047391020000::bi= gint))

         Filter:= (spm_subid =3D 462)

 Total runtime: 57.36 msec

(6 rows)

 

to

 

         &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;        QUERY PLAN            = ;            &n= bsp;     

--------------------------------------------------------= ---------------------------------------------------------------------------= ----------------

 Sort  (cost=3D3525.27..3527.49 rows=3D888 wid= th=3D47) (actual time=3D2323.79..2324.31 rows=3D913 loops=3D1)

   Sort Key: "timestamp"

   ->  Index Scan using firewalllogsin= dex on firewalllogs  (cost=3D0.00..3481.77 rows=3D888 width=3D47) (actual time=3D0.26..2318.11 rows=3D913 loops=3D1)

         Index C= ond: ((fqdn =3D 'bs2@pcp'::character varying) AND ("timestamp" >=3D 1044939600000::bigint) AND ("timestamp" <=3D 1047391020000::bi= gint))

         Filter:= (spm_subid =3D 462)

 Total runtime: 2325.62 msec

(6 rows)

 

NOTE:  I am only performing select queries - no ins= erts, deletes or updates. 

I am running postgresql on a SunFire v880 = with 4 750MHz sparcv9 processors with 8 Gig of RAM running solaris 8.  I ha= ve 2 tables with 500,000 records in each and both tables are indexed.  I am connecting to the database through JDBC using a pool of connections (tried pools of 50, 100, and 200 with similar results).  When running the load tests, the cpu of the box is always above 60% idle.  I have run iostat= and I am not seeing any problems with io.

 

I have tried different size shared_buffers from 4100 to 64000, and I have added the following to the /etc/system file:

 

set shmsys:shminfo_shmmax=3D0xffffffff

set shmsys:shminfo_shmmin=3D1

set shmsys:shminfo_shmmni=3D256

set shmsys:shminfo_shmseg=3D256

set semsys:seminfo_semmap=3D256

set semsys:seminfo_semmni=3D512

set semsys:seminfo_semmns=3D512

set semsys:seminfo_semmsl=3D32

 

I understand that this could be a problem with the kernel and not postgresql but I am at a loss at what to change to get better performance out of the database or the kernel.

 

Any help would be appreciated.

 

 

------_=_NextPart_001_01C2F885.4198FFC0-- From pgsql-performance-owner@postgresql.org Tue Apr 1 15:21:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3167A47621C for ; Tue, 1 Apr 2003 15:21:43 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 67417476178 for ; Tue, 1 Apr 2003 15:21:42 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h31KLh2L002852; Tue, 1 Apr 2003 15:21:43 -0500 (EST) To: "Scott Buchan" Cc: pgsql-performance@postgresql.org Subject: Re: Postgresql performance on Solaris In-reply-to: <71F044551C53974EB0735B3737EFE2FC088645@wwwserver> References: <71F044551C53974EB0735B3737EFE2FC088645@wwwserver> Comments: In-reply-to "Scott Buchan" message dated "Tue, 01 Apr 2003 14:31:13 -0500" Date: Tue, 01 Apr 2003 15:21:43 -0500 Message-ID: <2851.1049228503@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/9 X-Sequence-Number: 1515 "Scott Buchan" writes: > I am getting poor performance from my postgresql (version 7.3.2 compiled > with gcc 2.95.2) database when running load tests on my web application. > The database works great until I get above 200 concurrent users. Hmm ... that sounds kinda familiar; you might check the archives for similar reports from Solaris users. AFAIR we didn't figure out the problem yet, but there's some raw data available. > When running the load tests, the cpu of the box is always above 60% > idle. I have run iostat and I am not seeing any problems with io. [ scratches head ... ] If the bottleneck isn't CPU, and it isn't I/O, then what could it be? You sure about the above observations? (Does iostat include swap activity on that platform?) The only other idea I can think of is that there's some weird effect in the locking code (which only shows up with lots of concurrent backends) such that would-be lockers repeatedly fail and sleep when they should have gotten the lock. If you can figure out how to tell the difference between a backend waiting for disk I/O and one waiting for a semaphore or sleeping, it'd be interesting to see what the majority of the backends are doing. Another way to try to gather some data is to attach to one of the backend processes with a debugger, and just stop it to get a stack trace every so often. If the stack traces tend to point to the same place that would give some info about the bottleneck. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 1 15:36:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E5951475CBC for ; Tue, 1 Apr 2003 15:36:47 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id E6E2D475AF8 for ; Tue, 1 Apr 2003 15:36:46 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h31KPDr11175; Tue, 1 Apr 2003 15:25:13 -0500 Message-ID: <093201c2f88f$45e60730$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Bruce Momjian" , "eric soroos" Cc: "Shankar K" , References: <200304011826.h31IQ2S29201@candle.pha.pa.us> Subject: Re: ext3 filesystem / linux 7.3 Date: Tue, 1 Apr 2003 15:42:54 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-6.5 required=5.0 tests=BAYES_30,RCVD_IN_NJABL,REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/10 X-Sequence-Number: 1516 OK so am I hearing: XFS is the fastest (but is it the safest?) but does not come on Linux. Ext2 does less work than Ext3 so is fastest among what DOES come with Linux - but if you have a crash that fsck can't fix you're hosed. Ext3 is quite a bit slower if set to be real safe, a wee bit slower if run with standard options which makes it more crash-safe, and much slower if the mount flags are set to metadata journaling but that is much safer as a file system because the metadata journaling is complementary to the PG transactioning. To determine which you want you must choose which one feels to you like the right balance of speed and the setup work you are willing to perform and maintain. Do I have it right? Jeff From pgsql-performance-owner@postgresql.org Tue Apr 1 15:43:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC51C475AF8 for ; Tue, 1 Apr 2003 15:43:36 -0500 (EST) Received: from hal.istation.com (hal.istation.com [65.120.151.132]) by postgresql.org (Postfix) with ESMTP id D1E7247592C for ; Tue, 1 Apr 2003 15:43:35 -0500 (EST) Received: from sauron (sauron.istation.com [65.120.151.174]) (authenticated) by hal.istation.com (8.11.6/8.11.6) with ESMTP id h31KhXK03610; Tue, 1 Apr 2003 14:43:33 -0600 Reply-To: From: "Keith Bottner" To: "'Andrew Sullivan'" , Subject: Re: ext3 filesystem / linux 7.3 Date: Tue, 1 Apr 2003 14:43:35 -0600 Organization: istation.com Message-ID: <000a01c2f88f$5e288200$ae977841@istation.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 In-reply-to: <20030401175519.GA9553@mail> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-37.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES,SIGNATURE_LONG_SPARSE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/11 X-Sequence-Number: 1517 FYI, I believe that XFS will be included in the 2.6 kernel. Keith Bottner kbottner@istation.com -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan Sent: Tuesday, April 01, 2003 11:55 AM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] ext3 filesystem / linux 7.3 On Tue, Apr 01, 2003 at 12:33:15PM -0500, Jeffrey D. Brower wrote: > What is the URL of that article? I understood that ext2 was faster > with PG and so I went to a lot of trouble of creating an ext2 > partition just for PG and gave up the journalling to do that. > Something about double effort since PG already does a lot of that. I don't know how ext3 could be faster than ext2, since it has to do more work. But ext2 is not crash-safe. So your data could well be hosed if you come back from a crash on ext2. Actually, I have my doubts about _any_ of the journaling filesystems for Linux: ext3 has a reputation for being slow if you journal in the real-safe mode, and there have been so many unrepeatable reiserfs problem reports that I'm loathe to use it for real systems. I had exceptionally good experiences with xfs when I was admining SGI boxes, but that's not part of the standard Linux kernel distribution, and with no idea why, I think my managers would get grumpy with me for using it. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Tue Apr 1 16:48:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9549A475EC9 for ; Tue, 1 Apr 2003 16:48:01 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id A51E9475CBC for ; Tue, 1 Apr 2003 16:47:31 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h31LjHYS006757; Tue, 1 Apr 2003 14:45:17 -0700 (MST) Date: Tue, 1 Apr 2003 14:42:59 -0700 (MST) From: "scott.marlowe" To: Tom Lane Cc: Scott Buchan , Subject: Re: Postgresql performance on Solaris In-Reply-To: <2851.1049228503@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/12 X-Sequence-Number: 1518 On Tue, 1 Apr 2003, Tom Lane wrote: > The only other idea I can think of is that there's some weird effect in > the locking code (which only shows up with lots of concurrent backends) > such that would-be lockers repeatedly fail and sleep when they should > have gotten the lock. If you can figure out how to tell the difference > between a backend waiting for disk I/O and one waiting for a semaphore > or sleeping, it'd be interesting to see what the majority of the > backends are doing. I was thinking along the lines of it being something like the old Linux kernel had with apache and other programs with waking all the processes. It could be that something about Solaris is meaning that every backend process, no matter how idle they are, get "touched" every time something is done. Just guessing. From pgsql-performance-owner@postgresql.org Tue Apr 1 20:34:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4713A475AF8 for ; Tue, 1 Apr 2003 20:34:16 -0500 (EST) Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 1CA4F47592C for ; Tue, 1 Apr 2003 20:34:12 -0500 (EST) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6p2/8.11.6) id h321YC112120 for pgsql-performance@postgresql.org; Wed, 2 Apr 2003 09:34:12 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6p2/8.9.3) with SMTP id h321Xp711809; Wed, 2 Apr 2003 09:33:53 +0800 (WST) Message-ID: <061501c2f8b7$f5280720$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: "Jeffrey D. Brower" , "Bruce Momjian" , "eric soroos" Cc: "Shankar K" , References: <200304011826.h31IQ2S29201@candle.pha.pa.us> <093201c2f88f$45e60730$0b02a8c0@pointhere.net> Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 09:33:56 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: base64 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-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Spam-Status: No, hits=-10.5 required=5.0 tests=BASE64_ENC_TEXT,BAYES_20,MAILTO_TO_SPAM_ADDR, QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/13 X-Sequence-Number: 1519 SnVzdCBzd2l0Y2ggdG8gRnJlZUJTRCBhbmQgdXNlIFVGUyA7KQ0KDQpDaHJp cw0KDQotLS0tLSBPcmlnaW5hbCBNZXNzYWdlIC0tLS0tIA0KRnJvbTogIkpl ZmZyZXkgRC4gQnJvd2VyIiA8amVmZkBwb2ludGhlcmUubmV0Pg0KVG86ICJC cnVjZSBNb21qaWFuIiA8cGdtYW5AY2FuZGxlLnBoYS5wYS51cz47ICJlcmlj IHNvcm9vcyIgPGVyaWMtcHNxbEBzb3Jvb3MubmV0Pg0KQ2M6ICJTaGFua2Fy IEsiIDxzaGFuMDA3NUB5YWhvby5jb20+OyA8cGdzcWwtcGVyZm9ybWFuY2VA cG9zdGdyZXNxbC5vcmc+DQpTZW50OiBXZWRuZXNkYXksIEFwcmlsIDAyLCAy MDAzIDQ6NDIgQU0NClN1YmplY3Q6IFJlOiBbUEVSRk9STV0gZXh0MyBmaWxl c3lzdGVtIC8gbGludXggNy4zDQoNCg0KPiBPSyBzbyBhbSBJIGhlYXJpbmc6 DQo+IA0KPiBYRlMgaXMgdGhlIGZhc3Rlc3QgKGJ1dCBpcyBpdCB0aGUgc2Fm ZXN0PykgYnV0IGRvZXMgbm90IGNvbWUgb24gTGludXguDQo+IA0KPiBFeHQy IGRvZXMgbGVzcyB3b3JrIHRoYW4gRXh0MyBzbyBpcyBmYXN0ZXN0IGFtb25n IHdoYXQgRE9FUyBjb21lIHdpdGgNCj4gTGludXggLSBidXQgaWYgeW91IGhh dmUgYSBjcmFzaCB0aGF0IGZzY2sgY2FuJ3QgZml4IHlvdSdyZSBob3NlZC4N Cj4gDQo+IEV4dDMgaXMgcXVpdGUgYSBiaXQgc2xvd2VyIGlmIHNldCB0byBi ZSByZWFsIHNhZmUsIGEgd2VlIGJpdCBzbG93ZXIgaWYgcnVuDQo+IHdpdGgg c3RhbmRhcmQgb3B0aW9ucyB3aGljaCBtYWtlcyBpdCBtb3JlIGNyYXNoLXNh ZmUsIGFuZCBtdWNoIHNsb3dlciBpZiB0aGUNCj4gbW91bnQgZmxhZ3MgYXJl IHNldCB0byBtZXRhZGF0YSBqb3VybmFsaW5nIGJ1dCB0aGF0IGlzIG11Y2gg c2FmZXIgYXMgYSBmaWxlDQo+IHN5c3RlbSBiZWNhdXNlIHRoZSBtZXRhZGF0 YSBqb3VybmFsaW5nIGlzIGNvbXBsZW1lbnRhcnkgdG8gdGhlIFBHDQo+IHRy YW5zYWN0aW9uaW5nLg0KPiANCj4gVG8gZGV0ZXJtaW5lIHdoaWNoIHlvdSB3 YW50IHlvdSBtdXN0IGNob29zZSB3aGljaCBvbmUgZmVlbHMgdG8geW91IGxp a2UgdGhlDQo+IHJpZ2h0IGJhbGFuY2Ugb2Ygc3BlZWQgYW5kIHRoZSBzZXR1 cCB3b3JrIHlvdSBhcmUgd2lsbGluZyB0byBwZXJmb3JtIGFuZA0KPiBtYWlu dGFpbi4NCj4gDQo+IERvIEkgaGF2ZSBpdCByaWdodD8NCj4gDQo+ICAgIEpl ZmYNCj4gDQo+IA0KPiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5k IG9mIGJyb2FkY2FzdCktLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCj4g VElQIDM6IGlmIHBvc3RpbmcvcmVhZGluZyB0aHJvdWdoIFVzZW5ldCwgcGxl YXNlIHNlbmQgYW4gYXBwcm9wcmlhdGUNCj4gc3Vic2NyaWJlLW5vbWFpbCBj b21tYW5kIHRvIG1ham9yZG9tb0Bwb3N0Z3Jlc3FsLm9yZyBzbyB0aGF0IHlv dXINCj4gbWVzc2FnZSBjYW4gZ2V0IHRocm91Z2ggdG8gdGhlIG1haWxpbmcg bGlzdCBjbGVhbmx5DQo+IA== From pgsql-performance-owner@postgresql.org Tue Apr 1 20:49:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 87BE947592C for ; Tue, 1 Apr 2003 20:49:38 -0500 (EST) Received: from perrin.int.nxad.com (internal.ext.nxad.com [69.1.70.251]) by postgresql.org (Postfix) with ESMTP id A89D84758C9 for ; Tue, 1 Apr 2003 20:49:07 -0500 (EST) Received: by perrin.int.nxad.com (Postfix, from userid 1001) id DC4B22106C; Tue, 1 Apr 2003 17:49:06 -0800 (PST) Date: Tue, 1 Apr 2003 17:49:06 -0800 From: Sean Chittenden To: Christopher Kings-Lynne Cc: "Jeffrey D. Brower" , Bruce Momjian , eric soroos , Shankar K , pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Message-ID: <20030402014906.GL10799@perrin.int.nxad.com> References: <200304011826.h31IQ2S29201@candle.pha.pa.us> <093201c2f88f$45e60730$0b02a8c0@pointhere.net> <061501c2f8b7$f5280720$6500a8c0@fhp.internal> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <061501c2f8b7$f5280720$6500a8c0@fhp.internal> User-Agent: Mutt/1.4i 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/ X-Spam-Status: No, hits=-21.8 required=5.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/14 X-Sequence-Number: 1520 > Just switch to FreeBSD and use UFS ;) I must say, I found this whole discussion rather amusing on the sidelines given it's largely a non-problem for non-Linux users. :) "Better performance through engineering elegance." -sc -- Sean Chittenden seanc@FreeBSD.org From pgsql-performance-owner@postgresql.org Tue Apr 1 23:11:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9680C475AF8 for ; Tue, 1 Apr 2003 23:11:35 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 6DF134758C9 for ; Tue, 1 Apr 2003 23:11:33 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h324Bam30839 for ; Wed, 2 Apr 2003 09:41:36 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h324BZ730829 for ; Wed, 2 Apr 2003 09:41:36 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 09:42:18 +0530 User-Agent: KMail/1.5 References: <200304011826.h31IQ2S29201@candle.pha.pa.us> <061501c2f8b7$f5280720$6500a8c0@fhp.internal> <20030402014906.GL10799@perrin.int.nxad.com> In-Reply-To: <20030402014906.GL10799@perrin.int.nxad.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304020942.18320.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/15 X-Sequence-Number: 1521 On Wednesday 02 April 2003 07:19, you wrote: > > Just switch to FreeBSD and use UFS ;) > > I must say, I found this whole discussion rather amusing on the > sidelines given it's largely a non-problem for non-Linux users. :) > > "Better performance through engineering elegance." Well, this may sound like a troll, but I have said this before and will say that again. I found reiserfs to be faster than ext2, upto 40% at times when we tried a quasi closed source benchmark on a quad xeon machine with SCSI RAID. Everything else being same and defaults used out of box, reiserfs on mandrake9 was far faster in every respect than ext2. I personally find freeBSD UFS to be a better combo based on my workstation tests. I believe freeBSD has a better IO scheuler that utilises disk bandwidth in optimal manner. Scratching (my poor IDE) disk like mad does not happen with freeBSD but linux does it plenty. But I didn't benchmark it for throughput.. Shridhar From pgsql-performance-owner@postgresql.org Wed Apr 2 10:13:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8EF55475EC9 for ; Wed, 2 Apr 2003 10:13:48 -0500 (EST) Received: from smtp.inode.at (smtp-05.inode.at [62.99.194.7]) by postgresql.org (Postfix) with ESMTP id 2B4A94762A2 for ; Wed, 2 Apr 2003 10:13:17 -0500 (EST) Received: from line-f-208.adsl-dynamic.inode.at ([62.99.193.208]:50006 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 190juh-0002HL-00; Wed, 02 Apr 2003 17:12:31 +0200 Received: by andi-lap (sSMTP sendmail emulation); Wed, 2 Apr 2003 17:13:19 +0200 Subject: Re: ext3 filesystem / linux 7.3 From: Andreas Kostyrka To: eric soroos Cc: Shankar K , pgsql-performance@postgresql.org, "Jeffrey D.Brower" In-Reply-To: <26287373.1162931668@[4.42.179.151]> References: <26287373.1162931668@[4.42.179.151]> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-iHBxP95beFH/1eZFAO/T" Organization: Message-Id: <1049296398.20242.325.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 02 Apr 2003 17:13:19 +0200 X-Spam-Status: No, hits=-41.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,MAILTO_TO_SPAM_ADDR, PGP_SIGNATURE_2,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/16 X-Sequence-Number: 1522 --=-iHBxP95beFH/1eZFAO/T Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-04-01 at 19:53, eric soroos wrote: > On Tue, 1 Apr 2003 09:39:17 -0800 (PST) in message <20030401173917.19476.= qmail@web21101.mail.yahoo.com>, Shankar K wrote: > > hi jeff, > >=20 > > go to > > http://www.ca.postgresql.org/docs/momjian/hw_performance/ > > under 'filesystems' slide. > >=20 >=20 > I suspect that is what he's seen.=20 >=20 > >From my experience, ext3 is only a percent or two slower than ext2 under= pg_bench. It saves an amazing amount of time on startup after a failure by= not having to fsck to confirm that the filesystem is in a consistent state= .=20 >=20 > I believe that ext3 is a metadata journaling system, and not a data journ= aling system. This would indicate that the PG transactioning is complimenta= ry to the filesystem journaling, not duplication.=20 It's both. See the -o data=3Djournal|data=3Dordered|data=3Dwriteback mount time option. Andreas --=-iHBxP95beFH/1eZFAO/T Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+iv4LHJdudm4KnO0RArZyAKCO6sa/eRlkzAoNfF+NTzctQcWVCgCgnxL2 S5jjDm1agDbaXwJ5yfvsCAA= =hAhH -----END PGP SIGNATURE----- --=-iHBxP95beFH/1eZFAO/T-- From pgsql-performance-owner@postgresql.org Wed Apr 2 10:18:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0873C475E91 for ; Wed, 2 Apr 2003 10:18:56 -0500 (EST) Received: from smtp.inode.at (smtp-05.inode.at [62.99.194.7]) by postgresql.org (Postfix) with ESMTP id F1E044761BC for ; Wed, 2 Apr 2003 10:18:23 -0500 (EST) Received: from line-f-208.adsl-dynamic.inode.at ([62.99.193.208]:50007 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 190jze-0002NJ-00; Wed, 02 Apr 2003 17:17:39 +0200 Received: by andi-lap (sSMTP sendmail emulation); Wed, 2 Apr 2003 17:18:26 +0200 Subject: Re: ext3 filesystem / linux 7.3 From: Andreas Kostyrka To: Andrew Sullivan Cc: pgsql-performance@postgresql.org In-Reply-To: <20030401175519.GA9553@mail> References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> <20030401175519.GA9553@mail> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-5PeF+BN/Yk0fBfEJzJPZ" Organization: Message-Id: <1049296706.20242.331.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 02 Apr 2003 17:18:26 +0200 X-Spam-Status: No, hits=-44.9 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,QUOTE_TWICE_1,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/17 X-Sequence-Number: 1523 --=-5PeF+BN/Yk0fBfEJzJPZ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 2003-04-01 at 19:55, Andrew Sullivan wrote: > I don't know how ext3 could be faster than ext2, since it has to do > more work.=20=20 Depending upon certain parameters, it can be faster, because it writes the data to the journal serially without head movement. The kernel might be able to write that data in it spot later when the hdd would be idle. So yes, in certain cases, ext3 might be faster than ext2. >=20 > Actually, I have my doubts about _any_ of the journaling filesystems > for Linux: ext3 has a reputation for being slow if you journal in the Well, journaled filesystem usually means only meta-data journaling. ext3 is the only LinuxFS (AFAIK) that offers a fully journaled fs. > real-safe mode, and there have been so many unrepeatable reiserfs > problem reports that I'm loathe to use it for real systems. I had Well, I've been using ReiserFS now for years, and never had any problems with it.=20 Andreas --=20 Andreas Kostyrka Josef-Mayer-Strasse 5 83043 Bad Aibling --=-5PeF+BN/Yk0fBfEJzJPZ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+iv9CHJdudm4KnO0RAu8cAJ4+8s8WWe0/UeD6jGsTj5QFr76xTQCgs/M7 qgi3zPi80UTp8aLCDKdNxd4= =Pi/W -----END PGP SIGNATURE----- --=-5PeF+BN/Yk0fBfEJzJPZ-- From pgsql-performance-owner@postgresql.org Wed Apr 2 10:31:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0A354475CBC for ; Wed, 2 Apr 2003 10:31:46 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id 95B2C475EC9 for ; Wed, 2 Apr 2003 10:31:13 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h32FJs905259; Wed, 2 Apr 2003 10:19:54 -0500 Message-ID: <0a3001c2f92d$c975a490$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Andreas Kostyrka" , "eric soroos" Cc: "Shankar K" , References: <26287373.1162931668@[4.42.179.151]> <1049296398.20242.325.camel@andi-lap> Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 10:37:36 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-6.5 required=5.0 tests=BAYES_30,RCVD_IN_NJABL,REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/18 X-Sequence-Number: 1524 ... and what *exactly* is the difference? From pgsql-performance-owner@postgresql.org Wed Apr 2 10:48:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C4DE2474E44 for ; Wed, 2 Apr 2003 10:48:04 -0500 (EST) Received: from smtp.inode.at (smtp-05.inode.at [62.99.194.7]) by postgresql.org (Postfix) with ESMTP id C41A6474E44 for ; Wed, 2 Apr 2003 10:47:32 -0500 (EST) Received: from line-f-208.adsl-dynamic.inode.at ([62.99.193.208]:50055 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 190kRr-0002pX-00; Wed, 02 Apr 2003 17:46:48 +0200 Received: by andi-lap (sSMTP sendmail emulation); Wed, 2 Apr 2003 17:47:36 +0200 Subject: Re: ext3 filesystem / linux 7.3 From: Andreas Kostyrka To: "Jeffrey D. Brower" Cc: eric soroos , Shankar K , pgsql-performance@postgresql.org In-Reply-To: <0a3001c2f92d$c975a490$0b02a8c0@pointhere.net> References: <26287373.1162931668@[4.42.179.151]> <1049296398.20242.325.camel@andi-lap> <0a3001c2f92d$c975a490$0b02a8c0@pointhere.net> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-6Ll2Ced/E9Wr7KB18d4F" Organization: Message-Id: <1049298455.21669.333.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 02 Apr 2003 17:47:36 +0200 X-Spam-Status: No, hits=-41.1 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/19 X-Sequence-Number: 1525 --=-6Ll2Ced/E9Wr7KB18d4F Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-04-02 at 17:37, Jeffrey D. Brower wrote: > ... and what *exactly* is the difference? Between what? (how about a bit more context?) Andreas --=20 Andreas Kostyrka Josef-Mayer-Strasse 5 83043 Bad Aibling --=-6Ll2Ced/E9Wr7KB18d4F Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+iwYXHJdudm4KnO0RAthMAKChgPKCOqJ37fL9cQW5yuVvVla70ACbBJ4G kPOaBDTkD7fyJlJ0EohIQFU= =7cIv -----END PGP SIGNATURE----- --=-6Ll2Ced/E9Wr7KB18d4F-- From pgsql-performance-owner@postgresql.org Wed Apr 2 10:57:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 757A7475F16 for ; Wed, 2 Apr 2003 10:57:15 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 7E537475E91 for ; Wed, 2 Apr 2003 10:56:44 -0500 (EST) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 190kbZ-000418-00 for ; Wed, 02 Apr 2003 10:56:49 -0500 Received: by dba2 (Postfix, from userid 1019) id 1F2EBCBAB; Wed, 2 Apr 2003 10:56:49 -0500 (EST) Date: Wed, 2 Apr 2003 10:56:49 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Message-ID: <20030402155649.GC15624@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> <20030401175519.GA9553@mail> <1049296706.20242.331.camel@andi-lap> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1049296706.20242.331.camel@andi-lap> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/20 X-Sequence-Number: 1526 On Wed, Apr 02, 2003 at 05:18:26PM +0200, Andreas Kostyrka wrote: > Well, I've been using ReiserFS now for years, and never had any problems > with it. Me too. But the "known failure modes" that people keep reporting about have to do with completely trashing, say, a whole page of data. Your directories are fine, but the data is all hosed. I've never had it happen. I've never seen anyone who can consistently reproduce it. But I've certainly read about it often enough to have pretty serious reservations about relying on the filesystem for data I can't afford to lose. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Apr 2 11:45:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8A681474E44 for ; Wed, 2 Apr 2003 11:45:44 -0500 (EST) Received: from smtp.web.de (smtp01.web.de [217.72.192.180]) by postgresql.org (Postfix) with ESMTP id 08C4347630B for ; Wed, 2 Apr 2003 11:45:42 -0500 (EST) Received: from p5081806a.dip0.t-ipconnect.de ([80.129.128.106] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 190lMw-0003K5-00 for pgsql-performance@postgresql.org; Wed, 02 Apr 2003 18:45:46 +0200 Message-ID: <3E8B13BA.6000208@web.de> Date: Wed, 02 Apr 2003 18:45:46 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> <20030401175519.GA9553@mail> <1049296706.20242.331.camel@andi-lap> <20030402155649.GC15624@libertyrms.info> In-Reply-To: <20030402155649.GC15624@libertyrms.info> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-21.4 required=5.0 tests=BAYES_01,IN_REP_TO,RCVD_IN_NJABL,REFERENCES, USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/21 X-Sequence-Number: 1527 Are there any comments on JFS regarding real-life safety and speed? From pgsql-performance-owner@postgresql.org Wed Apr 2 12:01:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 23C6D476083 for ; Wed, 2 Apr 2003 12:01:00 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id C1EF1475ED4 for ; Wed, 2 Apr 2003 12:00:58 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h32GoE905563; Wed, 2 Apr 2003 11:50:15 -0500 Message-ID: <0a6f01c2f93a$6907bf50$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Andreas Kostyrka" Cc: "Bruce Momjian" , , "Shankar K" , "eric soroos" References: <26287373.1162931668@[4.42.179.151]> <1049296398.20242.325.camel@andi-lap> <0a3001c2f92d$c975a490$0b02a8c0@pointhere.net> <1049298455.21669.333.camel@andi-lap> Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 12:07:57 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-11.2 required=5.0 tests=BAYES_20,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL,REFERENCES, X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/22 X-Sequence-Number: 1528 >> This would indicate that the PG transactioning is complimentary to the filesystem journaling, not duplication. >It's both. See the -o data=journal|data=ordered|data=writeback mount >time option. I did a RTFM on that but I am now confused again. I am wondering what the *best* setting is with ext3. When I RTFM the man page for mount, the data=writeback option says plainly that it is fastest but in a crash old data is quite possibly on the dataset. The safest *looks* to be data=journal since the journaling happens before writes are committed to the file (and presumably the journal is used to update the file on the disk to apply the journal entry to the disk file?) and the default is data=ordered which says write to the disk AND THEN to the journal (which seems bizarre to me). How all of that works WITH and/or AGAINST PostgreSQL and what metadata REALLY means is my bottom line quandary. Obviously that is where finding the warm and fuzzy place between speed and safety is found. Jeff From pgsql-performance-owner@postgresql.org Wed Apr 2 15:05:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4F5CF4762D7 for ; Wed, 2 Apr 2003 15:05:44 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 8A3F94762F6 for ; Wed, 2 Apr 2003 15:05:39 -0500 (EST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2938646; Wed, 02 Apr 2003 12:05:26 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Jeffrey D. Brower" , "Andreas Kostyrka" Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 12:05:30 -0800 User-Agent: KMail/1.4.3 Cc: "Bruce Momjian" , , "Shankar K" , "eric soroos" References: <26287373.1162931668@[4.42.179.151]> <1049298455.21669.333.camel@andi-lap> <0a6f01c2f93a$6907bf50$0b02a8c0@pointhere.net> In-Reply-To: <0a6f01c2f93a$6907bf50$0b02a8c0@pointhere.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304021205.30075.josh@agliodbs.com> X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/23 X-Sequence-Number: 1529 Jeff, > How all of that works WITH and/or AGAINST PostgreSQL and what metadata > REALLY means is my bottom line quandary. Obviously that is where finding > the warm and fuzzy place between speed and safety is found. For your $PGDATA directory, your only need for filesystem journaling is to= =20 prevent a painful fsck process on an unexpected power-out. You are not, as= a=20 rule, terribly concerned with journaling the data as PostgreSQL already=20 provides some data recovery protection through WAL. As a result, on my one server where I have to use Ext3 (I use Reiser on mos= t=20 machines, and have never had a problem except for one disaster when upgradi= ng=20 Reiser versions), the $PGDATA is mounted "noatime,data=3Dwriteback" (BTW, I found that combining "data=3Dwriteback" with Linux LVM on RedHat 8.= 0=20 resulted in system-fatal mounting errors. Anyone else have this problem?) Of course, if you have a machine with a $60,000 disk array and disk I/O is= =20 unlimited, then maybe you want to enable data=3Djournal just for the protec= tion=20 against corruption of the WAL and clog files.=20=20=20 --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 2 19:23:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 108394762A2 for ; Wed, 2 Apr 2003 19:23:06 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id BF2A24762D7 for ; Wed, 2 Apr 2003 19:23:04 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h330CE906997; Wed, 2 Apr 2003 19:12:14 -0500 Message-ID: <0a8001c2f978$28959a80$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: , "Andreas Kostyrka" Cc: "Bruce Momjian" , , "Shankar K" , "eric soroos" References: <26287373.1162931668@[4.42.179.151]> <1049298455.21669.333.camel@andi-lap> <0a6f01c2f93a$6907bf50$0b02a8c0@pointhere.net> <200304021205.30075.josh@agliodbs.com> Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 19:29:57 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-16.9 required=5.0 tests=BAYES_20,MAILTO_TO_SPAM_ADDR,ORIGINAL_MESSAGE, QUOTED_EMAIL_TEXT,RCVD_IN_NJABL,REFERENCES, X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/24 X-Sequence-Number: 1530 Thanks for that Josh. I had previously understood that ext3 was a bad thing with PostgreSQL and I went way above and beyond to create it on an Ext2 filesystem (the only one on the server) and mount that. Should I undo that work and go back to Ext3? Jeff ----- Original Message ----- From: "Josh Berkus" To: "Jeffrey D. Brower" ; "Andreas Kostyrka" Cc: "Bruce Momjian" ; ; "Shankar K" ; "eric soroos" Sent: Wednesday, April 02, 2003 3:05 PM Subject: Re: [PERFORM] ext3 filesystem / linux 7.3 > Jeff, > > > How all of that works WITH and/or AGAINST PostgreSQL and what metadata > > REALLY means is my bottom line quandary. Obviously that is where finding > > the warm and fuzzy place between speed and safety is found. > > For your $PGDATA directory, your only need for filesystem journaling is to > prevent a painful fsck process on an unexpected power-out. You are not, as a > rule, terribly concerned with journaling the data as PostgreSQL already > provides some data recovery protection through WAL. > > As a result, on my one server where I have to use Ext3 (I use Reiser on most > machines, and have never had a problem except for one disaster when upgrading > Reiser versions), the $PGDATA is mounted "noatime,data=writeback" > > (BTW, I found that combining "data=writeback" with Linux LVM on RedHat 8.0 > resulted in system-fatal mounting errors. Anyone else have this problem?) > > Of course, if you have a machine with a $60,000 disk array and disk I/O is > unlimited, then maybe you want to enable data=journal just for the protection > against corruption of the WAL and clog files. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 2 19:47:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9FE8C47631B for ; Wed, 2 Apr 2003 19:46:53 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id E38B947631B for ; Wed, 2 Apr 2003 19:46:38 -0500 (EST) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2939157; Wed, 02 Apr 2003 16:46:33 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Jeffrey D. Brower" Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 16:46:36 -0800 User-Agent: KMail/1.4.3 Cc: References: <26287373.1162931668@[4.42.179.151]> <200304021205.30075.josh@agliodbs.com> <0a8001c2f978$28959a80$0b02a8c0@pointhere.net> In-Reply-To: <0a8001c2f978$28959a80$0b02a8c0@pointhere.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304021646.36965.josh@agliodbs.com> X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/25 X-Sequence-Number: 1531 Jeff, > Thanks for that Josh. Welcome > I had previously understood that ext3 was a bad thing with PostgreSQL and= I > went way above and beyond to create it on an Ext2 filesystem (the only one > on the server) and mount that. >=20 > Should I undo that work and go back to Ext3? I would. Not necessarily Ext3, mind you; you might want to consider Reiser= or=20 JFS, too. My experience has been better with Reiser than Ext3 with Postgre= s,=20 but I can't back that up with any statistics. (DISCLAIMER: This is not professional advice, and comes with no warranty. = If=20 you want professional advice, pay me.) --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 2 21:44:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BDE5247592C for ; Wed, 2 Apr 2003 21:44:39 -0500 (EST) Received: from moya.trilug.org (moya.trilug.org [64.244.27.141]) by postgresql.org (Postfix) with ESMTP id D3A11474E44 for ; Wed, 2 Apr 2003 21:44:38 -0500 (EST) Received: from trilug.org (pcp01389159pcs.walngs01.pa.comcast.net [68.80.176.197]) (using SSLv3 with cipher DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by moya.trilug.org (Postfix) with ESMTP id C25A2A0018 for ; Wed, 2 Apr 2003 21:44:42 -0500 (EST) Date: Wed, 2 Apr 2003 21:44:31 -0500 Subject: Re: ext3 filesystem / linux 7.3 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-1-163718617" Mime-Version: 1.0 (Apple Message framework v551) From: Chris Hedemark To: Content-Transfer-Encoding: 7bit In-Reply-To: <093201c2f88f$45e60730$0b02a8c0@pointhere.net> Message-Id: <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> X-Request-Pgp: http://yonderway.com/chris/hedemark.gpg X-Pgp-Agent: GPGMail 0.5.4 (v22 Jaguar) X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-24.9 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/26 X-Sequence-Number: 1532 --Apple-Mail-1-163718617 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Tuesday, April 1, 2003, at 03:42 PM, Jeffrey D. Brower wrote: > OK so am I hearing: Enough... ...there is waaay too much hearsay going on in this thread. Let's come up with an acceptable test battery and actually settle it once and for all with good hard numbers. It would be worth my while to spend some time on this since the developers I support currently hate pgsql due to performance complaints (on servers that predate my employment there). So if I am going to move them to better servers it would be worth my while to do some homework on what OS and FS is best. I'm not qualified at all to define the tests. I am willing to try it on any OS that will run on a Sun Ultra 5, which would include Linux, several BSD's and Solaris to name a few. It also runs the gammut of filesystems that have been talked about here. The machine isn't a barnstormer but I'm willing to put in an 18GB SCSI drive and try this with many different OS's and FS's if someone qualified will put together an acceptable test suite and it doesn't meet with too much opposition by the gurus here. The test machine: Sun UltraSPARC 5 333MHz UltraSPARC CPU, 2MB cache 256MB RAM whatever SCSI card I can find most quickly either a 9GB or 18GB SCSI drive (whichever I can find most quickly) The test client would likely be an Apple Powerbook G4 800MHz, 512MB, running OS X 10.2.4. Yes the client runs rings around the server but I can afford to abuse the server. While the server is admittedly an older machine, for the purpose of this test it should not matter as long as the hardware configuration is equal for all tests. If we agree on a test suite there is nothing to stop someone from running the same suite on their own hardware and reporting their own results. Anyone game to give a go at this? -- "What difference does it make to the dead, the orphans and the homeless, whether the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?" - Mahatma Gandhi --Apple-Mail-1-163718617 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-disposition: inline content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (Darwin) iEYEARECAAYFAj6LoBcACgkQYPuF4Zq9lvZoNgCgnHWhAbqErMYD26dsLHHU3b0x PHsAn3qSsrg8qykl0hb8GCXFRhkjCwN/ =fh7+ -----END PGP SIGNATURE----- --Apple-Mail-1-163718617-- From pgsql-performance-owner@postgresql.org Wed Apr 2 21:58:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 25CAC475ED4 for ; Wed, 2 Apr 2003 21:58:13 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 81309475CEE for ; Wed, 2 Apr 2003 21:58:12 -0500 (EST) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 190uvg-0004zW-00 for ; Wed, 02 Apr 2003 21:58:16 -0500 Received: by dba2 (Postfix, from userid 1019) id BA781CC11; Wed, 2 Apr 2003 21:58:16 -0500 (EST) Date: Wed, 2 Apr 2003 21:58:16 -0500 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Message-ID: <20030403025816.GA17411@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <093201c2f88f$45e60730$0b02a8c0@pointhere.net> <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/27 X-Sequence-Number: 1533 On Wed, Apr 02, 2003 at 09:44:31PM -0500, Chris Hedemark wrote: > While the server is admittedly an older machine, for the purpose of > this test it should not matter as long as the hardware configuration is > equal for all tests. If we agree on a test suite there is nothing to That's false. One of the big problems with a lot of tuning info is that it tends not to take int consideration hardware, &c. I can tell you for sure that if you have a giant-cache array connected by fibre channel, _it makes no difference_ what the filesystem is. The array is so fast that you can't really fill the cache under normal load anyway. Similarly, if you have enough memory, every read test is going to be as fast as any other: you'll get 100% cache hits, and the same memory configured the same way will always respond at about the same speed. That said, I think you're right to demand some tests, and to say that holding the machine constant and changing filesystems is a good filesystem test. So here are some suggested things, in no real order: 1. Make sure you run out of buffers before you start to read (for read filesystem speed tests). 2. Pull the power plug repeatedly while the server is under load. Judge robustness. 3. Put WAL and data area on different filesystems (to be fair, this should probably be different spindles, but I'll take what I can get) and configure the filesystems in various ways (including, say, writeback for data and full journalling for WAL). See tests above. 4. Make sure your controller doesn't lie about fsync. 5. Test under different loads. 10% writes vs. 90% reads; 20% writes; &c. Compare simple INSERT write with UPDATE write. Compare UPDATE writes where the UPDATEd row is the same one over and over. Make sure you do (2) several times. Lots of these are artificial. But it seems they might reveal something. I'd be particularly keen to hear about what _really_ is up with reiserfs. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Thu Apr 3 00:34:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4B66F4763A7 for ; Thu, 3 Apr 2003 00:34:03 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 7B81C4763AB for ; Thu, 3 Apr 2003 00:33:51 -0500 (EST) Received: from [63.195.55.98] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2939505; Wed, 02 Apr 2003 21:33:45 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Chris Hedemark , Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 2 Apr 2003 21:33:44 -0800 User-Agent: KMail/1.4.3 References: <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> In-Reply-To: <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304022133.44511.josh@agliodbs.com> X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/28 X-Sequence-Number: 1534 Chris, > ...there is waaay too much hearsay going on in this thread. Let's come= =20 > up with an acceptable test battery and actually settle it once and for=20 > all with good hard numbers. It would be worth my while to spend some=20 > time on this since the developers I support currently hate pgsql due to= =20 > performance complaints (on servers that predate my employment there).=20= =20 > So if I am going to move them to better servers it would be worth my=20 > while to do some homework on what OS and FS is best. You're not going to be able to determine this for certain, but at least you= =20 should be able to debunk some myths. Here's my suggested tests: 1) Read-only test -- numerous small rapidfire queries in the fashion of a P= HP=20 web application. PGBench already does this one test ok, maybe you could us= e=20 that. 2) Complex query test -- run a few 12-table queries with CASE statements,= =20 custom functions and subselects and/or UNIONs.=20=20=20 3) Transaction Test -- hit the database with numerous rapid-fire single row= =20 updates to a few tables. 4) OLAP Test -- do a few massive updates to thousands of rows based on rela= ted=20 data and/or cascading updates to multiple tables and dozens-hundreds of row= s.=20=20 Create large temp tables based on Joe Conway's Crosstab. 5) Mixed use test: combine 1, 2, & 3 in a ratio of 70% 10% 20% on several= =20 simultaneous connections. Of course this requires us to have a sample database with at least 100,000= =20 rows of data in one or two tables plus at least 5-10 additional tables with= =20 realistically complex relationships. Donor, anyone? Also, we'll have to talk about .conf files ... --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 3 00:46:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E64BE475ED4 for ; Thu, 3 Apr 2003 00:46:48 -0500 (EST) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by postgresql.org (Postfix) with ESMTP id 2A30B475CEE for ; Thu, 3 Apr 2003 00:46:48 -0500 (EST) Received: (from mail@localhost) by martin.sysdetect.com (8.11.3/8.11.3) id h335kpO17044; Thu, 3 Apr 2003 05:46:51 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdA10554; Thu Apr 3 05:46:48 2003 Received: from winwood.sysdetect.com (seth@localhost) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h335kmQ20311; Thu, 3 Apr 2003 00:46:48 -0500 Message-Id: <200304030546.h335kmQ20311@winwood.sysdetect.com> To: josh@agliodbs.com Cc: Chris Hedemark , pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 In-reply-to: <200304022133.44511.josh@agliodbs.com> References: <322CCBF8-657E-11D7-8752-0003939CC61E@trilug.org> <200304022133.44511.josh@agliodbs.com> Comments: In reply to a message from "Josh Berkus " dated "Wed, 02 Apr 2003 21:33:44 -0800." Date: Thu, 03 Apr 2003 00:46:48 -0500 From: Seth Robertson X-Spam-Status: No, hits=-27.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,MSG_ID_ADDED_BY_MTA_3, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/29 X-Sequence-Number: 1535 In message <200304022133.44511.josh@agliodbs.com>, Josh Berkus writes: Chris, > ...there is waaay too much hearsay going on in this thread. Let's come > up with an acceptable test battery and actually settle it once and for > all with good hard numbers. It would be worth my while to spend some > time on this since the developers I support currently hate pgsql due to > performance complaints (on servers that predate my employment there). > So if I am going to move them to better servers it would be worth my > while to do some homework on what OS and FS is best. You're not going to be able to determine this for certain, but at least you should be able to debunk some myths. Here's my suggested tests: [...] Also, we'll have to talk about .conf files ... When I installed my postgres, I tried a test program I wrote with all four values of wal_sync, and for my RedHat Linux 8.0 ext3 filesystem (default mount options), and my toy test; open_sync performed the best for me. Thus, I would suggest adding the wal_sync_method as another axis for your testing. -Seth Robertson seth@sysd.com From pgsql-performance-owner@postgresql.org Thu Apr 3 05:58:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9B863475CEE for ; Thu, 3 Apr 2003 05:58:02 -0500 (EST) Received: from moya.trilug.org (moya.trilug.org [64.244.27.141]) by postgresql.org (Postfix) with ESMTP id CDFAA475C3D for ; Thu, 3 Apr 2003 05:58:01 -0500 (EST) Received: from trilug.org (pcp01389159pcs.walngs01.pa.comcast.net [68.80.176.197]) (using SSLv3 with cipher DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by moya.trilug.org (Postfix) with ESMTP id D75BCA0027 for ; Thu, 3 Apr 2003 05:58:03 -0500 (EST) Date: Thu, 3 Apr 2003 05:58:01 -0500 Subject: Re: ext3 filesystem / linux 7.3 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Chris Hedemark To: Content-Transfer-Encoding: 7bit In-Reply-To: <200304022133.44511.josh@agliodbs.com> Message-Id: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> X-Request-Pgp: http://yonderway.com/chris/hedemark.gpg X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-28.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/30 X-Sequence-Number: 1536 On Thursday, April 3, 2003, at 12:33 AM, Josh Berkus wrote: > You're not going to be able to determine this for certain, but at > least you > should be able to debunk some myths. Here's my suggested tests: [snip] Being a mere sysadmin, it is creation of the test cases (perl script, maybe?) that I'll have to ask someone else with more of a development bent to help with. My talent is more along the lines of system administration. Plus I am willing to take the time to go through these tests over & over with a different OS or different tuning parameters on the same OS, different FS's, etc. Someone else needs to come up with the test code. The client machine has pgsql on it also if the results are going into a db that won't go away after every test. :) -- "What difference does it make to the dead, the orphans and the homeless, whether the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?" - Mahatma Gandhi From pgsql-performance-owner@postgresql.org Thu Apr 3 11:08:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0F18475CEE for ; Thu, 3 Apr 2003 11:08:44 -0500 (EST) Received: from irko.smoothcorp.com (unknown [208.49.241.41]) by postgresql.org (Postfix) with ESMTP id 4BF07475CE5 for ; Thu, 3 Apr 2003 11:08:44 -0500 (EST) Received: from taurus.ifloor.com ([10.0.1.20] helo=taurus.smoothcorp.com) by irko.smoothcorp.com with esmtp (Exim 4.12) id 1917Gi-00015l-00 for pgsql-performance@postgresql.org; Thu, 03 Apr 2003 08:08:48 -0800 Received: from localhost (chris@localhost) by taurus.smoothcorp.com (8.11.6/8.11.6) with ESMTP id h33G8kM14087 for ; Thu, 3 Apr 2003 08:08:46 -0800 X-Authentication-Warning: taurus.smoothcorp.com: chris owned process doing -bs Date: Thu, 3 Apr 2003 08:08:46 -0800 (PST) From: Chris Sutton To: pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 In-Reply-To: <200304021646.36965.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SA-Exim-Rcpt-To: pgsql-performance@postgresql.org X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Spam-Status: No, hits=-24.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTE_TWICE_1, USER_AGENT_PINE,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/31 X-Sequence-Number: 1537 On Wed, 2 Apr 2003, Josh Berkus wrote: > > I had previously understood that ext3 was a bad thing with PostgreSQL and I > > went way above and beyond to create it on an Ext2 filesystem (the only one > > on the server) and mount that. We recently started using Postgres on a new database server running RH 7.3 and ext3. Due to some kernel problems the machine would crash at random times. Each time it crashed it came back up extremly easily with no data loss. If we were on ext2 coming back up after a crash probably wouldn't have been quite as easy. We have since given up on RH 7.3 and gone with RH Enterprise ES. Just an FIY for any of you out there thinking about moving to RH 7.3 or those that are having problems with 7.3 and ext3. Chris From pgsql-performance-owner@postgresql.org Thu Apr 3 11:52:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6D83474E4F for ; Thu, 3 Apr 2003 11:52:38 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 74826474E44 for ; Thu, 3 Apr 2003 11:52:37 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2940289; Thu, 03 Apr 2003 08:52:35 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Chris Hedemark , Subject: Re: ext3 filesystem / linux 7.3 Date: Thu, 3 Apr 2003 08:52:34 -0800 User-Agent: KMail/1.4.3 References: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> In-Reply-To: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> MIME-Version: 1.0 Message-Id: <200304030852.34194.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-28.9 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/32 X-Sequence-Number: 1538 Chris, > Being a mere sysadmin, it is creation of the test cases (perl script, > maybe?) that I'll have to ask someone else with more of a development > bent to help with.=20=20 I'll write the test queries and perl scripts if someone else can supply the= =20 database. Unfortunately, while I have a few databases that meet the=20 criteria, they are all NDA.=20=20=20 Criteria again: Must have at least 100,000 rows with 12+ columns in "main" table. Must have at least 10-12 additional tables, some with FK relationships to t= he=20 main table and each other. Must be OK to make contents public. More is better up to 500MB. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 3 11:59:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 56FE0474E44 for ; Thu, 3 Apr 2003 11:59:43 -0500 (EST) Received: from moya.trilug.org (moya.trilug.org [64.244.27.141]) by postgresql.org (Postfix) with ESMTP id BFDAF474E4F for ; Thu, 3 Apr 2003 11:59:42 -0500 (EST) Received: from trilug.org (vpn.ccgroupnet.com [207.103.85.62]) (using SSLv3 with cipher DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by moya.trilug.org (Postfix) with ESMTP id 9EBF5A0027 for ; Thu, 3 Apr 2003 11:59:47 -0500 (EST) Date: Thu, 3 Apr 2003 11:59:44 -0500 Subject: Re: ext3 filesystem / linux 7.3 Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Chris Hedemark To: Content-Transfer-Encoding: 7bit In-Reply-To: <200304030852.34194.josh@agliodbs.com> Message-Id: X-Request-Pgp: http://yonderway.com/chris/hedemark.gpg X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-18.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/33 X-Sequence-Number: 1539 On Thursday, April 3, 2003, at 11:52 AM, Josh Berkus wrote: > Unfortunately, while I have a few databases that meet the > criteria, they are all NDA. I'm in the same boat. -- "What difference does it make to the dead, the orphans and the homeless, whether the mad destruction is wrought under the name of totalitarianism or the holy name of liberty or democracy?" - Mahatma Gandhi From pgsql-performance-owner@postgresql.org Thu Apr 3 12:04:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E26B0474E4F for ; Thu, 3 Apr 2003 12:04:42 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id 4B54F47636C for ; Thu, 3 Apr 2003 12:04:40 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h33GsV910691; Thu, 3 Apr 2003 11:54:32 -0500 Message-ID: <0b7a01c2fa04$2d299bf0$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Josh Berkus" , "Chris Hedemark" , References: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> <200304030852.34194.josh@agliodbs.com> Subject: Re: ext3 filesystem / linux 7.3 Date: Thu, 3 Apr 2003 12:12:16 -0500 Organization: Green Visor, Inc. 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-Spam-Status: No, hits=-17.5 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL, REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/34 X-Sequence-Number: 1540 Can't we generate data? Random data stored in random formats at random sizes would stress the file system wouldn't it? ----- Original Message ----- From: "Josh Berkus" To: "Chris Hedemark" ; Sent: Thursday, April 03, 2003 11:52 AM Subject: Re: [PERFORM] ext3 filesystem / linux 7.3 > Chris, > > > Being a mere sysadmin, it is creation of the test cases (perl script, > > maybe?) that I'll have to ask someone else with more of a development > > bent to help with. > > I'll write the test queries and perl scripts if someone else can supply the > database. Unfortunately, while I have a few databases that meet the > criteria, they are all NDA. > > Criteria again: > Must have at least 100,000 rows with 12+ columns in "main" table. > Must have at least 10-12 additional tables, some with FK relationships to the > main table and each other. > Must be OK to make contents public. > More is better up to 500MB. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Thu Apr 3 13:00:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CFD83476372 for ; Thu, 3 Apr 2003 12:43:07 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D397247635E for ; Thu, 3 Apr 2003 12:43:05 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2940377; Thu, 03 Apr 2003 09:43:03 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Jeffrey D. Brower" , "Chris Hedemark" , Subject: Re: ext3 filesystem / linux 7.3 Date: Thu, 3 Apr 2003 09:43:06 -0800 User-Agent: KMail/1.4.3 References: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> <200304030852.34194.josh@agliodbs.com> <0b7a01c2fa04$2d299bf0$0b02a8c0@pointhere.net> In-Reply-To: <0b7a01c2fa04$2d299bf0$0b02a8c0@pointhere.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304030943.06406.josh@agliodbs.com> X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/37 X-Sequence-Number: 1543 Jeffery, > Can't we generate data? Random data stored in random formats at random > sizes would stress the file system wouldn't it? In my experience, randomly generated data tends to resemble real data very= =20 little in distribution patterns and data types. This is one of the=20 limitations of PGBench. Surely there must be an OSS project out there with a medium-large PG databa= se=20 which is OSS-licensed? I'll post on GENERAL --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 3 12:59:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0FD7F476323 for ; Thu, 3 Apr 2003 12:49:43 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 564CF476334 for ; Thu, 3 Apr 2003 12:49:42 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h33Hn1hr029829; Thu, 3 Apr 2003 10:49:01 -0700 (MST) Date: Thu, 3 Apr 2003 10:45:50 -0700 (MST) From: "scott.marlowe" To: Chris Sutton Cc: Subject: Re: ext3 filesystem / linux 7.3 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-21.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/36 X-Sequence-Number: 1542 On Thu, 3 Apr 2003, Chris Sutton wrote: > On Wed, 2 Apr 2003, Josh Berkus wrote: > > > > I had previously understood that ext3 was a bad thing with PostgreSQL and I > > > went way above and beyond to create it on an Ext2 filesystem (the only one > > > on the server) and mount that. > > We recently started using Postgres on a new database server running RH 7.3 > and ext3. Due to some kernel problems the machine would crash at random > times. Each time it crashed it came back up extremly easily with no data > loss. If we were on ext2 coming back up after a crash probably wouldn't > have been quite as easy. > > We have since given up on RH 7.3 and gone with RH Enterprise ES. Just an > FIY for any of you out there thinking about moving to RH 7.3 or those that > are having problems with 7.3 and ext3. We're still running RH 7.2 due to issues we had with 7.3 as well. From pgsql-general-owner@postgresql.org Thu Apr 3 12:59:35 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DE269475B47; Thu, 3 Apr 2003 12:55:16 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0BCFB474E44; Thu, 3 Apr 2003 12:55:16 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2940404; Thu, 03 Apr 2003 09:55:14 -0800 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: OSS database needed for testing Date: Thu, 3 Apr 2003 09:55:16 -0800 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304030955.16543.josh@agliodbs.com> X-Spam-Status: No, hits=-12.2 required=5.0 tests=BAYES_10,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/224 X-Sequence-Number: 40289 Folks, Please pardon the cross-posting. A small group of us on the Performance list were discussing the first steps= =20 toward constructing a comprehensive Postgresql installation benchmarking=20 tool, mostly to compare different operating systems and file systemsm but= =20 later to be used as a foundation for a tuning wizard.=20=20=20 To do this, we need one or more real (not randomly generated*) medium-large= =20 database which is or can be BSD-licensed (data AND schema). This database= =20 must have: 1) At least one "main" table with 12+ columns and 100,000+ rows (each). 2) At least 10-12 additional tables of assorted sizes, at least half of whi= ch=20 should have Foriegn Key relationships to the main table(s) or each other. 3) At least one large text or varchar field among the various tables. In addition, the following items would be helpful, but are not required: 4) Views, triggers, and functions built on the database 5) A query log of database activity to give us sample queries to work with. 6) Some complex data types, such as geometric, network, and/or custom data= =20 types. Thanks for any leads you can give me! (* To forestall knee-jerk responses: Randomly generated data does not look= or=20 perform the same as real data in my professional opinion, and I'm the one= =20 writing the test scripts.) --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-general-owner@postgresql.org Mon Apr 7 12:40:19 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0EBBB47632B; Thu, 3 Apr 2003 13:09:00 -0500 (EST) Received: from cuthbert.rcsinc.local (unknown [205.217.85.84]) by postgresql.org (Postfix) with ESMTP id 49A98476326; Thu, 3 Apr 2003 13:08:59 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: Re: [HACKERS] OSS database needed for testing X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Date: Thu, 3 Apr 2003 13:12:12 -0500 Message-ID: <303E00EBDD07B943924382E153890E5434A939@cuthbert.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [HACKERS] OSS database needed for testing Thread-Index: AcL6C8ILN5HzpJkeQAuG0slbQhqdowAABjjg From: "Merlin Moncure" To: Cc: , , X-Spam-Status: No, hits=-15.5 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/452 X-Sequence-Number: 40517 Josh Berkus wrote: > 1) At least one "main" table with 12+ columns and 100,000+ rows (each). > 2) At least 10-12 additional tables of assorted sizes, at least half of > which > should have Foriegn Key relationships to the main table(s) or each other. > 3) At least one large text or varchar field among the various tables. >=20 > In addition, the following items would be helpful, but are not required: > 4) Views, triggers, and functions built on the database > 5) A query log of database activity to give us sample queries to work > with. > 6) Some complex data types, such as geometric, network, and/or custom data > types. >=20 Might I recommend the FCC database of transmitters. Its publicly available via anonymous FTP, medium largish with tables running 100k -> 1m+ records, and demonstrates many interesting test cases. For example, lat/lon spatial queries (RTree vs. GIST) can be tested with a decent volume. Also it demonstrates a good example of the use of schemas. Email me if you want info. Format is pipe delimited (non quoted), and data turnover is < 1% a week. Merlin From pgsql-general-owner@postgresql.org Mon Apr 7 12:21:47 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E0789476237; Thu, 3 Apr 2003 13:15:37 -0500 (EST) Received: from outland.mohawksoft.com (unknown [64.46.156.80]) by postgresql.org (Postfix) with ESMTP id B6B8B475D3B; Thu, 3 Apr 2003 13:15:32 -0500 (EST) Received: from mohawksoft.com (outland.mohawksoft.com [127.0.0.1]) by outland.mohawksoft.com (8.11.6/8.9.3) with SMTP id h33IQ1f01853; Thu, 3 Apr 2003 13:26:01 -0500 From: pgsql@mohawksoft.com Received: from 141.154.39.187 (SquirrelMail authenticated user pgsql) by mail.mohawksoft.com with HTTP; Thu, 3 Apr 2003 13:26:01 -0500 (EST) Message-ID: <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> Date: Thu, 3 Apr 2003 13:26:01 -0500 (EST) Subject: Re: [HACKERS] OSS database needed for testing To: josh@agliodbs.com In-Reply-To: <200304030955.16543.josh@agliodbs.com> References: <200304030955.16543.josh@agliodbs.com> Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org X-Mailer: SquirrelMail (version 1.0.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-24.2 required=5.0 tests=BAYES_10,IN_REP_TO,NO_REAL_NAME,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/430 X-Sequence-Number: 40495 I don't know that it meets your criteria, but..... I have a set of scripts and a program that will load the US Census TigerUA database into PostgreSQL. The thing is absolutely freak'n huge. I forget which, but it is either 30g or 60g of data excluding indexes. Also, if that is too much, I have a similar setup to load the FreeDB music database, from www.freedb.org. It has roughly 670,000 entries in "cdtitles" and 8 million entries in "cdsongs." Either one of which, I would be willing to send you the actual DB on cd(s) if you pay for postage and media.=20 =20 > Folks, >=20 > Please pardon the cross-posting. >=20 > A small group of us on the Performance list were discussing the first > steps toward constructing a comprehensive Postgresql installation > benchmarking tool, mostly to compare different operating systems and > file systemsm but later to be used as a foundation for a tuning > wizard.=20=20=20 >=20 > To do this, we need one or more real (not randomly generated*) > medium-large database which is or can be BSD-licensed (data AND > schema). This database must have: >=20 > 1) At least one "main" table with 12+ columns and 100,000+ rows (each). > 2) At least 10-12 additional tables of assorted sizes, at least half of > which should have Foriegn Key relationships to the main table(s) or > each other. 3) At least one large text or varchar field among the > various tables. >=20 > In addition, the following items would be helpful, but are not > required: 4) Views, triggers, and functions built on the database > 5) A query log of database activity to give us sample queries to work > with. 6) Some complex data types, such as geometric, network, and/or > custom data types. >=20 > Thanks for any leads you can give me! >=20 > (* To forestall knee-jerk responses: Randomly generated data does not > look or perform the same as real data in my professional opinion, and > I'm the one writing the test scripts.) >=20 > --=20 > -Josh Berkus > Aglio Database Solutions > San Francisco >=20 >=20 > ---------------------------(end of > broadcast)--------------------------- TIP 1: subscribe and unsubscribe > commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Thu Apr 3 14:45:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3FE1547636C for ; Thu, 3 Apr 2003 14:45:53 -0500 (EST) Received: from web21103.mail.yahoo.com (web21103.mail.yahoo.com [216.136.227.105]) by postgresql.org (Postfix) with SMTP id 0DE39476366 for ; Thu, 3 Apr 2003 14:45:52 -0500 (EST) Message-ID: <20030403194552.914.qmail@web21103.mail.yahoo.com> Received: from [208.253.218.33] by web21103.mail.yahoo.com via HTTP; Thu, 03 Apr 2003 11:45:52 PST Date: Thu, 3 Apr 2003 11:45:52 -0800 (PST) From: Shankar K Subject: Re: ext3 filesystem / linux 7.3 To: "scott.marlowe" , Chris Sutton Cc: pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-9.1 required=5.0 tests=BAYES_01,FROM_ENDS_IN_NUMS,IN_REP_TO autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/40 X-Sequence-Number: 1546 Hi Scott, Could you please share with us the problems you had with linux 7.3 would be really interested to know the kernel configs and ext3 filesystem modes Shankar --- "scott.marlowe" wrote: > On Thu, 3 Apr 2003, Chris Sutton wrote: > > > On Wed, 2 Apr 2003, Josh Berkus wrote: > > > > > > I had previously understood that ext3 was a > bad thing with PostgreSQL and I > > > > went way above and beyond to create it on an > Ext2 filesystem (the only one > > > > on the server) and mount that. > > > > We recently started using Postgres on a new > database server running RH 7.3 > > and ext3. Due to some kernel problems the machine > would crash at random > > times. Each time it crashed it came back up > extremly easily with no data > > loss. If we were on ext2 coming back up after a > crash probably wouldn't > > have been quite as easy. > > > > We have since given up on RH 7.3 and gone with RH > Enterprise ES. Just an > > FIY for any of you out there thinking about moving > to RH 7.3 or those that > > are having problems with 7.3 and ext3. > > We're still running RH 7.2 due to issues we had with > 7.3 as well. > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the > unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com From pgsql-performance-owner@postgresql.org Thu Apr 3 15:23:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 90270475A45 for ; Thu, 3 Apr 2003 15:22:59 -0500 (EST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id BE074474E4F for ; Thu, 3 Apr 2003 15:22:55 -0500 (EST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h33KMNhr014519; Thu, 3 Apr 2003 13:22:23 -0700 (MST) Date: Thu, 3 Apr 2003 13:19:10 -0700 (MST) From: "scott.marlowe" To: Shankar K Cc: Chris Sutton , Subject: Re: ext3 filesystem / linux 7.3 In-Reply-To: <20030403194552.914.qmail@web21103.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-22.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/41 X-Sequence-Number: 1547 On Thu, 3 Apr 2003, Shankar K wrote: > Hi Scott, > > Could you please share with us the problems you had > with linux 7.3 > > would be really interested to know the kernel configs > and ext3 filesystem modes Actually, I had a couple of problems with it, one of which was that I couldn't get it to book with ext3 file systems properly. I think it was something to do with ext3 on linux kernel RAID sets that wouldn't work right. There's probably a fix for it, but 7.2 is pretty stable, and we can wait for 8.0 or maybe look at another distro. I remember there being some other issues I had with configuration stuff like this, but now that it's been many months since I played with it I can't remember them all. My personal problem was that redhat stopped including linuxconf as an rpm package, and the only configuration programs they include don't seem to work well from a command line, but seemed to prefer to be used in X11. From pgsql-general-owner@postgresql.org Thu Apr 3 16:02:03 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91AF8475CEE for ; Thu, 3 Apr 2003 16:01:56 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id A9023475A45 for ; Thu, 3 Apr 2003 16:01:55 -0500 (EST) Received: (qmail 31207 invoked by uid 500); 3 Apr 2003 21:01:47 -0000 Date: Thu, 3 Apr 2003 15:01:47 -0600 From: Bruno Wolff III To: pgsql@mohawksoft.com Cc: josh@agliodbs.com, pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing Message-ID: <20030403210147.GB30860@wolff.to> Mail-Followup-To: pgsql@mohawksoft.com, josh@agliodbs.com, pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-34.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SUSPICIOUS_RECIPS, USER_AGENT_MUTT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/271 X-Sequence-Number: 40336 On Thu, Apr 03, 2003 at 13:26:01 -0500, pgsql@mohawksoft.com wrote: > I don't know that it meets your criteria, but..... > > I have a set of scripts and a program that will load the US Census TigerUA > database into PostgreSQL. The thing is absolutely freak'n huge. I forget > which, but it is either 30g or 60g of data excluding indexes. Are the data model or the loading scripts available publicly? I have the tiger data and a program that uses it to convert addresses to latitude and longitude, but I don't really like the program and was thinking about trying to load the data into a database and do queries against the database to find location. From pgsql-sql-owner@postgresql.org Thu Apr 3 16:02:08 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8372F474E4F for ; Thu, 3 Apr 2003 16:02:05 -0500 (EST) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id 93A0B474E44 for ; Thu, 3 Apr 2003 16:02:04 -0500 (EST) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.5) with ESMTP id h33LdAkj019039 for ; Thu, 3 Apr 2003 16:39:10 -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 h33L24x13931 for ; Thu, 3 Apr 2003 16:02:05 -0500 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 F3HTLZHR; Thu, 3 Apr 2003 16:02:04 -0500 Subject: can i make this sql query more efficiant? From: Robert Treat To: pgsql-sql@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 03 Apr 2003 16:02:04 -0500 Message-Id: <1049403724.13799.5473.camel@camel> Mime-Version: 1.0 X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/52 X-Sequence-Number: 12753 create table baz (event text, level int); insert into baz values ('x',1); insert into baz values ('x',2); insert into baz values ('x',3); insert into baz values ('y',2); insert into baz values ('y',3); insert into baz values ('y',3); select * from baz; event | level -------+------- x | 1 x | 2 x | 3 y | 2 y | 3 y | 3 (6 rows) I want to know how many ones, twos, and threes there are for each event: select event, (select count(*) from baz a where level = 1 and a.event=baz.event) as ones, (select count(*) from baz a where level = 2 and a.event=baz.event) as twos, (select count(*) from baz a where level = 3 and a.event=baz.event) as threes from baz group by event; which gives me: event | ones | twos | threes -------+------+------+-------- x | 1 | 1 | 1 y | 0 | 1 | 2 (2 rows) which is fine, but I am wondering if there is a better way to do this? I'd mainly like to reduce the number of subqueries involved. Another improvement would be to not have to explicitly query for each level, though this isn't as big since I know the range of levels in advance (famous last words for a dba :-) Thanks in advance, Robert Treat From pgsql-performance-owner@postgresql.org Thu Apr 3 17:05:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C3421475CE5 for ; Thu, 3 Apr 2003 17:05:08 -0500 (EST) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by postgresql.org (Postfix) with ESMTP id 7F104475ED4 for ; Thu, 3 Apr 2003 17:04:37 -0500 (EST) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Thu, 3 Apr 2003 16:04:24 -0600 Subject: Re: ext3 filesystem / linux 7.3 From: Will LaShell To: "scott.marlowe" Cc: Shankar K , Chris Sutton , pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-3NVcCrkYRDt2aUdedp9D" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 03 Apr 2003 15:04:19 -0700 Message-Id: <1049407460.22236.93.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Spam-Status: No, hits=-41.6 required=5.0 tests=BAYES_20,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/43 X-Sequence-Number: 1549 --=-3NVcCrkYRDt2aUdedp9D Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hey guys, On Thu, 2003-04-03 at 13:19, scott.marlowe wrote: > On Thu, 3 Apr 2003, Shankar K wrote: >=20 > > Hi Scott, > >=20 > > Could you please share with us the problems you had > > with linux 7.3 > >=20 > > would be really interested to know the kernel configs > > and ext3 filesystem modes >=20 > Actually, I had a couple of problems with it, one of which was that I=20 > couldn't get it to book with ext3 file systems properly. I think it was= =20 > something to do with ext3 on linux kernel RAID sets that wouldn't work=20 > right. There's probably a fix for it, but 7.2 is pretty stable, and we= =20 > can wait for 8.0 or maybe look at another distro. >=20 Normally I stay far far away from the distro wars / filesystem discussions. However I'd like to offer information about the systems we use here at OFS. The 2 core database servers are a matched pair of system with the following statistics.=20=20 Dual AMD MP 1800's Tyan Thunder K7x motherboard LSI Megaraid Elite 1650 controller w/ battery pack & 128 Mb cache 5 Seagate Cheetak 10k 36 Gig drives Configured in a raid 1+0 w/ hot spare. Both are using the stock redhat 7.3 kernel w/ the latest LSI megaraid drivers and firmware. The postgresql cluster itself contains the records and information necessary to process loans and loan applications.=20 We are using rserv ( from contrib ) to replicate data from three databases in the cluster between the two servers. ( Hahah, I think we may be the only people using this in production or something. ) At any rate we use ext3 on the filesystems and we've had no problems at all with the systems. Everything is stable and runs. We keep the machines running and available 24/7 with scheduled downtime transitions to the redundant servers as we need to for whatever kind of enhancements. The largest table in the cluster btw, has 4.2 million tuples in it and its the rserv log table. Hope this gives you some additional information to base your decisions on. Sincerely, Will LaShell --=-3NVcCrkYRDt2aUdedp9D 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+jK/jZr3R5kgOZd0RArpaAJwM0jTCeAZnB19u+krDCJn90pWJ8QCcDCbl GrHnL7zWSWCG3EKBhJyhQFg= =AKmS -----END PGP SIGNATURE----- --=-3NVcCrkYRDt2aUdedp9D-- From pgsql-sql-owner@postgresql.org Thu Apr 3 17:14:18 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6172E475CE5 for ; Thu, 3 Apr 2003 17:14:17 -0500 (EST) Received: from lucifer.akyasociados.com.ar (unknown [200.69.203.237]) by postgresql.org (Postfix) with ESMTP id 437F3475A8D for ; Thu, 3 Apr 2003 17:14:16 -0500 (EST) Received: from taz.oficina (taz.oficina [192.168.1.197]) (authenticated bits=0) by lucifer.akyasociados.com.ar (8.12.8/8.12.8) with ESMTP id h33MJjkw090858; Thu, 3 Apr 2003 19:19:45 -0300 (ART) (envelope-from franco@akyasociados.com.ar) From: Franco Bruno Borghesi Organization: AK y Asociados S.R.L. To: Robert Treat , pgsql-sql@postgresql.org Subject: Re: can i make this sql query more efficiant? Date: Thu, 3 Apr 2003 19:15:15 -0300 User-Agent: KMail/1.5 References: <1049403724.13799.5473.camel@camel> In-Reply-To: <1049403724.13799.5473.camel@camel> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_0JLj+LbEzho6ijt"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200304031915.16517.franco@akyasociados.com.ar> X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/54 X-Sequence-Number: 12755 --Boundary-02=_0JLj+LbEzho6ijt Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline if you're allowed to change the resultset structure, you could do: SELECT event, level,=20 count(*) FROM baz GROUP BY event, level;=20=20=20 event | level | count -------+-------+------- x | 1 | 1 x | 2 | 1 x | 3 | 1 y | 2 | 1 y | 3 | 2 (5 rows) of course it doesn't show you the rows where the count is zero. if you need the zeros, do this SELECT=20=20=20 EL.event, EL.level,=20 count(baz.*) FROM ( SELECT DISTINCT B1.event, B2.level=20 FROM=20 baz B1=20 CROSS JOIN baz B2 ) EL LEFT JOIN baz ON (baz.event=3DEL.event AND baz.level=3DEL.level)=20=20 GROUP BY EL.event, EL.level;=20=20=20 event | level | count -------+-------+------- x | 1 | 1 x | 2 | 1 x | 3 | 1 y | 1 | 0 y | 2 | 1 y | 3 | 2 (6 rows) hope it helps. On Thursday 03 April 2003 18:02, Robert Treat wrote: > create table baz (event text, level int); > > insert into baz values ('x',1); > insert into baz values ('x',2); > insert into baz values ('x',3); > insert into baz values ('y',2); > insert into baz values ('y',3); > insert into baz values ('y',3); > > select * from baz; > > event | level > -------+------- > x | 1 > x | 2 > x | 3 > y | 2 > y | 3 > y | 3 > (6 rows) > > > I want to know how many ones, twos, and threes there are for each event: > > select > event, > (select count(*) from baz a > where level =3D 1 and a.event=3Dbaz.event) as ones, > (select count(*) from baz a > where level =3D 2 and a.event=3Dbaz.event) as twos, > (select count(*) from baz a > where level =3D 3 and a.event=3Dbaz.event) as threes > from > baz > group by > event; > > which gives me: > > event | ones | twos | threes > -------+------+------+-------- > x | 1 | 1 | 1 > y | 0 | 1 | 2 > (2 rows) > > > which is fine, but I am wondering if there is a better way to do this? > I'd mainly like to reduce the number of subqueries involved. Another > improvement would be to not have to explicitly query for each level, > though this isn't as big since I know the range of levels in advance > (famous last words for a dba :-) > > Thanks in advance, > > Robert Treat > > > ---------------------------(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 --Boundary-02=_0JLj+LbEzho6ijt Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+jLJ0z/PwDAvtu7oRApe3AKCV0gNktohyYBn9I2eqQZ31RDlVQACcDWnx iJFOEWxG3uY6RCHyLbB1rAo= =6bXU -----END PGP SIGNATURE----- --Boundary-02=_0JLj+LbEzho6ijt-- From pgsql-general-owner@postgresql.org Mon Apr 7 12:21:53 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2C9D1476036; Thu, 3 Apr 2003 17:07:55 -0500 (EST) Received: from snoopy.mohawksoft.com (h0030f1382639.ne.client2.attbi.com [24.60.194.163]) by postgresql.org (Postfix) with ESMTP id 4ABDD475CE5; Thu, 3 Apr 2003 17:07:54 -0500 (EST) Received: from mohawksoft.com (snoopy.mohawksoft.com [127.0.0.1]) by snoopy.mohawksoft.com (8.11.6/8.11.6) with ESMTP id h33MJDZ23701; Thu, 3 Apr 2003 17:19:13 -0500 Message-ID: <3E8CB361.4010207@mohawksoft.com> Date: Thu, 03 Apr 2003 17:19:13 -0500 From: mlw User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Bruno Wolff III Cc: josh@agliodbs.com, pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <20030403210147.GB30860@wolff.to> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-25.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,REFERENCES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/431 X-Sequence-Number: 40496 Bruno Wolff III wrote: >On Thu, Apr 03, 2003 at 13:26:01 -0500, > pgsql@mohawksoft.com wrote: > > >>I don't know that it meets your criteria, but..... >> >>I have a set of scripts and a program that will load the US Census TigerUA >>database into PostgreSQL. The thing is absolutely freak'n huge. I forget >>which, but it is either 30g or 60g of data excluding indexes. >> >> > >Are the data model or the loading scripts available publicly? >I have the tiger data and a program that uses it to convert addresses >to latitude and longitude, but I don't really like the program and >was thinking about trying to load the data into a database and do >queries against the database to find location. > > > I have a set of scripts, SQL table defs, a small C program, along with a set of field with files that loads it into PGSQL using the "copy from stdin" It works fairly well, but takes a good long time to load it all. Should I put it in the download section of my website? From pgsql-general-owner@postgresql.org Thu Apr 3 17:20:52 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F124476323 for ; Thu, 3 Apr 2003 17:20:46 -0500 (EST) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 2A2F6476036 for ; Thu, 3 Apr 2003 17:20:45 -0500 (EST) Received: (qmail 32153 invoked by uid 500); 3 Apr 2003 22:20:37 -0000 Date: Thu, 3 Apr 2003 16:20:37 -0600 From: Bruno Wolff III To: mlw Cc: josh@agliodbs.com, pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing Message-ID: <20030403222037.GA32097@wolff.to> Mail-Followup-To: mlw , josh@agliodbs.com, pgsql-general@postgresql.org, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <20030403210147.GB30860@wolff.to> <3E8CB361.4010207@mohawksoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E8CB361.4010207@mohawksoft.com> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-34.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SUSPICIOUS_RECIPS, USER_AGENT_MUTT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/281 X-Sequence-Number: 40346 On Thu, Apr 03, 2003 at 17:19:13 -0500, mlw wrote: > > I have a set of scripts, SQL table defs, a small C program, along with a > set of field with files that loads it into PGSQL using the "copy from > stdin" It works fairly well, but takes a good long time to load it all. > > Should I put it in the download section of my website? Yes. I would be interested in looking at it even if I don't use exactly the same way to do stuff. Taking a logn time to load the data into the database isn't a big deal for me. reading through the tiger (and FIPS) data documentation it seemed like there might be some gotchas in unusual cases and I am not sure the google contest program really handled things right so I would like to see another implementation. I am also interested in the data model as that will save me some time. From pgsql-sql-owner@postgresql.org Fri Apr 4 01:02:13 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2C32D474E44 for ; Fri, 4 Apr 2003 01:02:12 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 8C78F474E42 for ; Fri, 4 Apr 2003 01:02:10 -0500 (EST) Received: from lamer.pl (localhost [127.0.0.1]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 2DEF16A283; Fri, 4 Apr 2003 08:02:09 +0200 (CEST) From: "Tomasz Myrta" To: Robert Treat , pgsql-sql@postgresql.org Subject: Re: can i make this sql query more efficiant? Date: Fri, 4 Apr 2003 08:02:09 +0900 Message-Id: <20030404080209.M3259@klaster.net> In-Reply-To: <1049403724.13799.5473.camel@camel> References: <1049403724.13799.5473.camel@camel> X-Mailer: Open WebMail 1.62 20020221 X-OriginatingIP: 217.96.97.171 (jasiek) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 X-Spam-Status: No, hits=-16.2 required=5.0 tests=BAYES_01,DATE_IN_PAST_06_12,IN_REP_TO,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/62 X-Sequence-Number: 12763 > select > event, > (select count(*) from baz a > where level = 1 and a.event=baz.event) as ones, > (select count(*) from baz a > where level = 2 and a.event=baz.event) as twos, > (select count(*) from baz a > where level = 3 and a.event=baz.event) as threes > from > baz > group by > event; > > which gives me: > > event | ones | twos | threes > -------+------+------+-------- > x | 1 | 1 | 1 > y | 0 | 1 | 2 > (2 rows) What about this: select event, sum(case when level=1 then 1 else 0 end) as ones, sum(case when level=2 then 1 else 0 end) as twos, sum(case when level=3 then 1 else 0 end) as threes from baz group by event; Regards, Tomasz Myrta From pgsql-performance-owner@postgresql.org Thu Apr 3 18:12:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A1883476237 for ; Thu, 3 Apr 2003 18:12:49 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 4CFA7475F5F for ; Thu, 3 Apr 2003 18:12:48 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2941177; Thu, 03 Apr 2003 15:12:43 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Will LaShell , "scott.marlowe" Subject: Re: ext3 filesystem / linux 7.3 Date: Thu, 3 Apr 2003 15:12:45 -0800 User-Agent: KMail/1.4.3 Cc: Shankar K , Chris Sutton , pgsql-performance@postgresql.org References: <1049407460.22236.93.camel@lyric.ofsloans.com> In-Reply-To: <1049407460.22236.93.camel@lyric.ofsloans.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304031512.45007.josh@agliodbs.com> X-Spam-Status: No, hits=-28.9 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/46 X-Sequence-Number: 1552 Will, > At any rate we use ext3 on the filesystems and we've had no problems at > all with the systems. Everything is stable and runs. We keep the > machines running and available 24/7 with scheduled downtime transitions > to the redundant servers as we need to for whatever kind of > enhancements. Hey, can we use you as a case study for advocacy.openoffice.org? --=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-sql-owner@postgresql.org Thu Apr 3 18:13:24 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8612B474E44 for ; Thu, 3 Apr 2003 18:13:23 -0500 (EST) Received: from email01.aon.at (WARSL401PIP8.highway.telekom.at [195.3.96.97]) by postgresql.org (Postfix) with SMTP id A0B1E474E42 for ; Thu, 3 Apr 2003 18:13:22 -0500 (EST) Received: (qmail 640924 invoked from network); 3 Apr 2003 23:13:24 -0000 Received: from m169p008.dipool.highway.telekom.at (HELO cantor) ([62.46.11.8]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 3 Apr 2003 23:13:24 -0000 From: Manfred Koizar To: Robert Treat Cc: pgsql-sql@postgresql.org Subject: Re: can i make this sql query more efficiant? Date: Fri, 04 Apr 2003 01:13:18 +0200 Message-ID: <2afp8vsf99lhrrtr411ncivnr577s1v394@4ax.com> References: <1049403724.13799.5473.camel@camel> In-Reply-To: <1049403724.13799.5473.camel@camel> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-31.4 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_FORTE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/56 X-Sequence-Number: 12757 On 03 Apr 2003 16:02:04 -0500, Robert Treat wrote: >select > event, > (select count(*) from baz a > where level = 1 and a.event=baz.event) as ones, > (select count(*) from baz a > where level = 2 and a.event=baz.event) as twos, > (select count(*) from baz a > where level = 3 and a.event=baz.event) as threes >from > baz >group by > event; >which is fine, but I am wondering if there is a better way to do this? >I'd mainly like to reduce the number of subqueries involved. SELECT event, SUM (CASE level WHEN 1 THEN 1 ELSE 0 END) AS ones, SUM (CASE level WHEN 2 THEN 1 ELSE 0 END) AS twos, SUM (CASE level WHEN 3 THEN 1 ELSE 0 END) AS threes FROM baz GROUP BY event; > Another >improvement would be to not have to explicitly query for each level, This might be a case for a clever set returning function, but that's not my realm. Wait for Joe to jump in ;-) Servus Manfred From pgsql-performance-owner@postgresql.org Thu Apr 3 21:36:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7635A474E44 for ; Thu, 3 Apr 2003 21:36:03 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id BEE4B474E42 for ; Thu, 3 Apr 2003 21:36:01 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h342Pg919254; Thu, 3 Apr 2003 21:25:42 -0500 Message-ID: <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: , Cc: References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> Subject: Re: [HACKERS] OSS database needed for testing Date: Thu, 3 Apr 2003 21:43:27 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-20.2 required=5.0 tests=BAYES_10,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL, REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/47 X-Sequence-Number: 1553 Hi Josh, Let me vote on the Tiger data. I used to use this database. It is public, updated by the government, VERY useful in own right, it works well with the earthdistance contribution, a real world database a lot of us use and I think you can put together some killer scripts on it. Can I vote twice? Jeff ----- Original Message ----- From: To: Cc: ; ; Sent: Thursday, April 03, 2003 1:26 PM Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing > I don't know that it meets your criteria, but..... > > I have a set of scripts and a program that will load the US Census TigerUA > database into PostgreSQL. The thing is absolutely freak'n huge. I forget > which, but it is either 30g or 60g of data excluding indexes. > > Also, if that is too much, I have a similar setup to load the FreeDB music > database, from www.freedb.org. It has roughly 670,000 entries in "cdtitles" > and 8 million entries in "cdsongs." > > Either one of which, I would be willing to send you the actual DB on cd(s) > if you pay for postage and media. > > > > Folks, > > > > Please pardon the cross-posting. > > > > A small group of us on the Performance list were discussing the first > > steps toward constructing a comprehensive Postgresql installation > > benchmarking tool, mostly to compare different operating systems and > > file systemsm but later to be used as a foundation for a tuning > > wizard. > > > > To do this, we need one or more real (not randomly generated*) > > medium-large database which is or can be BSD-licensed (data AND > > schema). This database must have: > > > > 1) At least one "main" table with 12+ columns and 100,000+ rows (each). > > 2) At least 10-12 additional tables of assorted sizes, at least half of > > which should have Foriegn Key relationships to the main table(s) or > > each other. 3) At least one large text or varchar field among the > > various tables. > > > > In addition, the following items would be helpful, but are not > > required: 4) Views, triggers, and functions built on the database > > 5) A query log of database activity to give us sample queries to work > > with. 6) Some complex data types, such as geometric, network, and/or > > custom data types. > > > > Thanks for any leads you can give me! > > > > (* To forestall knee-jerk responses: Randomly generated data does not > > look or perform the same as real data in my professional opinion, and > > I'm the one writing the test scripts.) > > > > -- > > -Josh Berkus > > Aglio Database Solutions > > San Francisco > > > > > > ---------------------------(end of > > broadcast)--------------------------- TIP 1: subscribe and unsubscribe > > commands go 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 Thu Apr 3 23:29:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ADB0E475ED4 for ; Thu, 3 Apr 2003 23:29:20 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id EC850475E82 for ; Thu, 3 Apr 2003 23:29:19 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2941683; Thu, 03 Apr 2003 20:29:17 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Jeffrey D. Brower" , Subject: Re: [HACKERS] OSS database needed for testing Date: Thu, 3 Apr 2003 20:29:12 -0800 User-Agent: KMail/1.4.3 Cc: References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> In-Reply-To: <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> MIME-Version: 1.0 Message-Id: <200304032029.12450.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/48 X-Sequence-Number: 1554 Jeff, > Let me vote on the Tiger data. I used to use this database. It is publi= c, > updated by the government, VERY useful in own right, it works well with t= he > earthdistance contribution, a real world database a lot of us use and I > think you can put together some killer scripts on it. We'd have to use a subset of it. 30G is a little larger than anything we= =20 want people to download as a test package. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 3 23:54:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0246C475A45 for ; Thu, 3 Apr 2003 23:54:22 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 3FC0F475458 for ; Thu, 3 Apr 2003 23:54:21 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h344s62L002995; Thu, 3 Apr 2003 23:54:06 -0500 (EST) To: Josh Berkus Cc: "Jeffrey D. Brower" , pgsql@mohawksoft.com, pgsql-performance@postgresql.org Subject: Re: [HACKERS] OSS database needed for testing In-reply-to: <200304032029.12450.josh@agliodbs.com> References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> <200304032029.12450.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Thu, 03 Apr 2003 20:29:12 -0800" Date: Thu, 03 Apr 2003 23:54:06 -0500 Message-ID: <2994.1049432046@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.1 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/49 X-Sequence-Number: 1555 Josh Berkus writes: > We'd have to use a subset of it. 30G is a little larger than anything we > want people to download as a test package. Yeah, it seems a bit over the top ... The FCC database sounded like an interesting alternative to me. regards, tom lane From pgsql-bugs-owner@postgresql.org Fri Apr 4 05:49:27 2003 X-Original-To: pgsql-bugs@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ECC59475458 for ; Fri, 4 Apr 2003 05:49:25 -0500 (EST) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id B8B1F474E42 for ; Fri, 4 Apr 2003 05:49:24 -0500 (EST) Received: (qmail 8315 invoked from network); 4 Apr 2003 10:49:25 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 4 Apr 2003 10:49:25 -0000 From: "Robert John Shepherd" To: Subject: Rapid deteriation of performance (might be caused by tsearch?) in 7.3.2 Date: Fri, 4 Apr 2003 11:49:25 +0100 Message-ID: <000201c2fa97$dc2197f0$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-1.6 required=5.0 tests=BAYES_30 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/25 X-Sequence-Number: 5798 Up until a few days ago I have been running Postgresl 7.2.3 with Tsearch from the contrib dir, but at various times the performance of the database would suddenly and rapidly deteriate so that queries which previously took 500ms then took 8 or 9 seconds. The only cure is a backup and restore of the database, vacuuming and analysing does nothing. I even tried rebuilding all indexes once which didn't seem to help. This was an annoying but intermittent thing, which happened the last time this Wednesday. Since I was doing a backup and restore anyway, I decided to upgrade to 7.3.2 in the hope this might fix the annoying problem, however it has made it WAY worse. Rather than going a few weeks (and sometimes months) in between having to use this fix, I am now having to do it almost every single day. I'm now lucky if it lasts 24 hours before it brings my website to a total crawl. There is nothing special about my database other than the fact that I use the Tsearch addon. Now if I go and do a bit update to the Tsearch indexes on a table, with for example: UPDATE tblmessages SET strmessageidx=txt2txtidx(strheading || ' ' || strmessage); Then that instantly brings the whole database to a crawl, which no amount of index rebuilding, vacuuming and analysing helps. Help! (And sorry if this is the wrong list) Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-performance-owner@postgresql.org Fri Apr 4 06:01:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8667F475B47 for ; Fri, 4 Apr 2003 06:01:17 -0500 (EST) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 47F32475A45 for ; Fri, 4 Apr 2003 06:01:15 -0500 (EST) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h34B1Dg20186 for ; Fri, 4 Apr 2003 16:31:13 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h34B1D720181 for ; Fri, 4 Apr 2003 16:31:13 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: [OT][ANNOUNCEMENT]Announcing first public release of Open Application Server Date: Fri, 4 Apr 2003 16:31:49 +0530 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304041631.49328.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-6.6 required=5.0 tests=BAYES_01,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/50 X-Sequence-Number: 1556 Hello all, I am very glad to announce first public release of Open Application Server. This is an application framework built in C++, to make use of existing APIs in internet application. It provides * A thread based request delivery architecture * support of request handlers loaded from external libraries * Support of additional application API such as http, SMTP etc. The features: * Written in C++ * mutlithreaded application * High performance and scalable * Provides object-packing technology * Native interface with apache to act as web application server The project is available from http://oasserver.sourceforge.net. The mailing list is not active as yet but it should be up in short time(by tomorrow hopefully). A complete web application built with OAS+postgresql+apache is also available from CVS. This is a issue tracking and resource booking system. There are no packages/tarballs available right now. Please use anonymous cvs. I plan to relase packages in short time. The CVS modules are oasserver and phd respectively. This is done so that I can update install documentation to cater for variety of build platforms. Right now, I can test the build only on slackware/mandrake/freeBSD. Shridhar From pgsql-performance-owner@postgresql.org Fri Apr 4 06:28:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AAEBC475B47 for ; Fri, 4 Apr 2003 06:28:54 -0500 (EST) Received: from smtp.inode.at (smtp-05.inode.at [62.99.194.7]) by postgresql.org (Postfix) with ESMTP id BBDD3474E42 for ; Fri, 4 Apr 2003 06:28:49 -0500 (EST) Received: from line-f-148.adsl-dynamic.inode.at ([62.99.193.148]:54276 helo=andi-lap) by smtp.inode.at with smtp (Exim 4.10) id 191PME-0001Ug-00; Fri, 04 Apr 2003 13:27:42 +0200 Received: by andi-lap (sSMTP sendmail emulation); Fri, 4 Apr 2003 13:28:50 +0200 Subject: Re: ext3 filesystem / linux 7.3 From: Andreas Kostyrka To: Andrew Sullivan Cc: pgsql-performance@postgresql.org In-Reply-To: <20030402155649.GC15624@libertyrms.info> References: <20030331205544.19785.qmail@web21104.mail.yahoo.com> <08f801c2f874$c6aac3d0$0b02a8c0@pointhere.net> <20030401175519.GA9553@mail> <1049296706.20242.331.camel@andi-lap> <20030402155649.GC15624@libertyrms.info> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-MqqAAqY4FbPK4UXZ4Hjx" Organization: Message-Id: <1049455729.17931.82.camel@andi-lap> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 04 Apr 2003 13:28:50 +0200 X-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/51 X-Sequence-Number: 1557 --=-MqqAAqY4FbPK4UXZ4Hjx Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2003-04-02 at 17:56, Andrew Sullivan wrote: > On Wed, Apr 02, 2003 at 05:18:26PM +0200, Andreas Kostyrka wrote: >=20 > > Well, I've been using ReiserFS now for years, and never had any problems > > with it.=20 >=20 > Me too. But the "known failure modes" that people keep reporting > about have to do with completely trashing, say, a whole page of data.=20 > Your directories are fine, but the data is all hosed. >=20 > I've never had it happen. I've never seen anyone who can > consistently reproduce it. But I've certainly read about it often > enough to have pretty serious reservations about relying on the > filesystem for data I can't afford to lose. Well, than backups and statistics are your only solution. Only way to know if something works is to test it for some time. (You never know if something in your use doesn't trigger some border case of malfunction in the kernel.) Andreas --=20 Andreas Kostyrka Josef-Mayer-Strasse 5 83043 Bad Aibling --=-MqqAAqY4FbPK4UXZ4Hjx Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA+jWxxHJdudm4KnO0RAoMIAKDh03FEBclLrTj/umBmHWJUvjFypwCgtxFF +f4h264OkvFJU56ZVY4eqJk= =Swu8 -----END PGP SIGNATURE----- --=-MqqAAqY4FbPK4UXZ4Hjx-- From pgsql-performance-owner@postgresql.org Fri Apr 4 07:11:06 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 41861474E42 for ; Fri, 4 Apr 2003 07:11:04 -0500 (EST) Received: from snoopy.mohawksoft.com (h0030f1382639.ne.client2.attbi.com [24.60.194.163]) by postgresql.org (Postfix) with ESMTP id EA3D7474E42 for ; Fri, 4 Apr 2003 07:10:32 -0500 (EST) Received: from mohawksoft.com (snoopy.mohawksoft.com [127.0.0.1]) by snoopy.mohawksoft.com (8.11.6/8.11.6) with ESMTP id h34CLoZ30121; Fri, 4 Apr 2003 07:21:54 -0500 Message-ID: <3E8D78DD.1060202@mohawksoft.com> Date: Fri, 04 Apr 2003 07:21:49 -0500 From: mlw User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: "Jeffrey D. Brower" , pgsql-performance@postgresql.org Subject: Re: [HACKERS] OSS database needed for testing References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> <200304032029.12450.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-25.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,REFERENCES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/52 X-Sequence-Number: 1558 Josh Berkus wrote: >Jeff, > > > >>Let me vote on the Tiger data. I used to use this database. It is public, >>updated by the government, VERY useful in own right, it works well with the >>earthdistance contribution, a real world database a lot of us use and I >>think you can put together some killer scripts on it. >> >> > >We'd have to use a subset of it. 30G is a little larger than anything we >want people to download as a test package. > > > Actually, come to think of it, the TigerUA DB is in chunks. You can use as much or as little as you want. I'll put the loader scripts on my download page tonight. Here is the home page for the data: http://www.census.gov/geo/www/tiger/tigerua/ua_tgr2k.html From pgsql-performance-owner@postgresql.org Fri Apr 4 07:38:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 815C7475F53 for ; Fri, 4 Apr 2003 07:38:03 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id 67AE9475F16 for ; Fri, 4 Apr 2003 07:38:02 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h34CRi928804; Fri, 4 Apr 2003 07:27:44 -0500 Message-ID: <0c2201c2faa8$136c9c90$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: "Josh Berkus" , Cc: References: <200304030955.16543.josh@agliodbs.com> <2598.141.154.39.187.1049394361.squirrel@mail.mohawksoft.com> <0c0f01c2fa53$f8eb8790$0b02a8c0@pointhere.net> <200304032029.12450.josh@agliodbs.com> Subject: Re: [HACKERS] OSS database needed for testing Date: Fri, 4 Apr 2003 07:45:29 -0500 Organization: Green Visor, Inc. 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-Spam-Status: No, hits=-17.5 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL, REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/53 X-Sequence-Number: 1559 Absolutely. We could just use one large state or several small ones and let folks download the whole thing if they wanted. Using that technique you could control the size of the test quite closely and still make something potentially quite valuable as a contribution beyond the bench. ----- Original Message ----- From: "Josh Berkus" To: "Jeffrey D. Brower" ; Cc: Sent: Thursday, April 03, 2003 11:29 PM Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing > Jeff, > > > Let me vote on the Tiger data. I used to use this database. It is public, > > updated by the government, VERY useful in own right, it works well with the > > earthdistance contribution, a real world database a lot of us use and I > > think you can put together some killer scripts on it. > > We'd have to use a subset of it. 30G is a little larger than anything we > want people to download as a test package. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 4 09:50:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A289C4762A2 for ; Fri, 4 Apr 2003 09:50:41 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 953F8476237 for ; Fri, 4 Apr 2003 09:50:37 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A32E1D62D; Fri, 4 Apr 2003 06:50:41 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 98B3A5C0A; Fri, 4 Apr 2003 06:50:41 -0800 (PST) Date: Fri, 4 Apr 2003 06:50:41 -0800 (PST) From: Stephan Szabo To: Robert John Shepherd Cc: Subject: Re: [BUGS] Rapid deteriation of performance (might be caused by In-Reply-To: <000201c2fa97$dc2197f0$f3b0313e@LAIKA> Message-ID: <20030404064515.Q92769-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,HTML_TAG_BALANCE_TABLE, IN_REP_TO,QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/54 X-Sequence-Number: 1560 On Fri, 4 Apr 2003, Robert John Shepherd wrote: > Up until a few days ago I have been running Postgresl 7.2.3 with Tsearch > from the contrib dir, but at various times the performance of the > database would suddenly and rapidly deteriate so that queries which > previously took 500ms then took 8 or 9 seconds. Hmm, what are the before and after explain analyze results? Also, what are your conf settings for shared buffers, sort memory and the fsm parameters? > The only cure is a backup and restore of the database, vacuuming and > analysing does nothing. I even tried rebuilding all indexes once which > didn't seem to help. Did you do a regular vacuum or vacuum full? If only the former, it's possible that you need to either vacuum more frequently and/or raise the free space map settings in your configuration file. What does vacuum full verbose ; give you for the tables involved? > Help! (And sorry if this is the wrong list) pgsql-performance is a better list, so I've replied to there. You'll probably need to join in order to reply to list. From pgsql-bugs-owner@postgresql.org Fri Apr 4 09:53:26 2003 X-Original-To: pgsql-bugs@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80D7247637E for ; Fri, 4 Apr 2003 09:53:25 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B910947637A for ; Fri, 4 Apr 2003 09:53:24 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h34ErS2L005590; Fri, 4 Apr 2003 09:53:28 -0500 (EST) To: "Robert John Shepherd" Cc: pgsql-bugs@postgresql.org Subject: Re: Rapid deteriation of performance (might be caused by tsearch?) in 7.3.2 In-reply-to: <000201c2fa97$dc2197f0$f3b0313e@LAIKA> References: <000201c2fa97$dc2197f0$f3b0313e@LAIKA> Comments: In-reply-to "Robert John Shepherd" message dated "Fri, 04 Apr 2003 11:49:25 +0100" Date: Fri, 04 Apr 2003 09:53:28 -0500 Message-ID: <5589.1049468008@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.1 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/27 X-Sequence-Number: 5800 "Robert John Shepherd" writes: > Help! (And sorry if this is the wrong list) Yes, it's the wrong list. pgsql-performance would be the place to discuss this. We can't help you anyway without more details: show us the EXPLAIN ANALYZE results for some of the slow queries. (Ideally I'd like to see EXPLAIN ANALYZE for the same queries in both fast and slow states ...) regards, tom lane From pgsql-performance-owner@postgresql.org Fri Apr 4 10:19:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D2D6A47633A for ; Fri, 4 Apr 2003 10:19:42 -0500 (EST) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id A0819476334 for ; Fri, 4 Apr 2003 10:19:41 -0500 (EST) Received: (qmail 11466 invoked from network); 4 Apr 2003 15:19:39 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 4 Apr 2003 15:19:39 -0000 From: "Robert John Shepherd" To: Subject: Re: [BUGS] Rapid deteriation of performance (might be caused by tsearch?) in 7.3.2 Date: Fri, 4 Apr 2003 16:19:34 +0100 Message-ID: <001e01c2fabd$9edfb860$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030404064515.Q92769-100000@megazone23.bigpanda.com> Importance: Normal X-Spam-Status: No, hits=-10.1 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,QUOTE_TWICE_1 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/55 X-Sequence-Number: 1561 > > Up until a few days ago I have been running Postgresl 7.2.3 with Tsearch > > from the contrib dir, but at various times the performance of the > > database would suddenly and rapidly deteriate so that queries which > > previously took 500ms then took 8 or 9 seconds. > Hmm, what are the before and after explain analyze results? Also, what > are your conf settings for shared buffers, sort memory and the fsm > parameters? shared_buffers = 40960 sort_mem = 20480 #max_fsm_relations = 1000 #max_fsm_pages = 10000 As you can see I've not uncommented or touched the fsm parameters, I have no idea what they do. Optimisation wise I have only played with shared_buffers, sort_mem and max_connections. > > The only cure is a backup and restore of the database > Did you do a regular vacuum or vacuum full? If only the former, it's > possible that you need to either vacuum more frequently and/or raise the > free space map settings in your configuration file. I've been running this daily: vacuumdb -h localhost -a -z Should I be using the full switch then? I'll get back to you on the other questions if you think they are still needed. > pgsql-performance is a better list, so I've replied to there. You'll > probably need to join in order to reply to list. Thanks, especially for not shouting at me heh, this is stressful enough as it is. Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-performance-owner@postgresql.org Fri Apr 4 10:29:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C882E476237 for ; Fri, 4 Apr 2003 10:29:43 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id AB454476036 for ; Fri, 4 Apr 2003 10:29:39 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 0939ED62D; Fri, 4 Apr 2003 07:29:44 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id F2DFB5C0A; Fri, 4 Apr 2003 07:29:43 -0800 (PST) Date: Fri, 4 Apr 2003 07:29:43 -0800 (PST) From: Stephan Szabo To: Robert John Shepherd Cc: Subject: Re: [BUGS] Rapid deteriation of performance (might be In-Reply-To: <001e01c2fabd$9edfb860$f3b0313e@LAIKA> Message-ID: <20030404072355.Q93368-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/56 X-Sequence-Number: 1562 On Fri, 4 Apr 2003, Robert John Shepherd wrote: > > > Up until a few days ago I have been running Postgresl 7.2.3 with > Tsearch > > > from the contrib dir, but at various times the performance of the > > > database would suddenly and rapidly deteriate so that queries which > > > previously took 500ms then took 8 or 9 seconds. > > > Hmm, what are the before and after explain analyze results? Also, > what > > are your conf settings for shared buffers, sort memory and the fsm > > parameters? > > shared_buffers = 40960 > sort_mem = 20480 > #max_fsm_relations = 1000 > #max_fsm_pages = 10000 > > As you can see I've not uncommented or touched the fsm parameters, I > have no idea what they do. Optimisation wise I have only played with > shared_buffers, sort_mem and max_connections. > > > > > The only cure is a backup and restore of the database > > > Did you do a regular vacuum or vacuum full? If only the former, it's > > possible that you need to either vacuum more frequently and/or raise > the > > free space map settings in your configuration file. > > I've been running this daily: > > vacuumdb -h localhost -a -z > > Should I be using the full switch then? Well, you generally shouldn't need to if the fsm settings are high enough. If you're doing really big updates like update each row of a 1 billion row table, you may end up having to do one immediately following that. Of course, if you're doing that, performance is probably not your biggest concern. ;) Explain analyze'll tell us if the system is changing plans (presumably to a worse one) - for example, deciding to move to a sequence scan because it thinks that the index scan is now to expensive, or conversely moving to an index scan because it thinks that there'll be too many reads, while those page reads actually are fairly localized. The vacuum full verbose should get some idea of how much empty space is there. > > pgsql-performance is a better list, so I've replied to there. You'll > > probably need to join in order to reply to list. > > Thanks, especially for not shouting at me heh, this is stressful enough > as it is. :) From pgsql-hackers-owner@postgresql.org Fri Apr 4 11:09:36 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3ADAD475A45; Fri, 4 Apr 2003 11:09:35 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 439C6474E42; Fri, 4 Apr 2003 11:09:34 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942335; Fri, 04 Apr 2003 08:09:31 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Jeffrey D. Brower" , Subject: Re: [PERFORM] OSS database needed for testing Date: Fri, 4 Apr 2003 08:09:22 -0800 User-Agent: KMail/1.4.3 Cc: , pgsql-hackers@postgresql.org References: <200304030955.16543.josh@agliodbs.com> <200304032029.12450.josh@agliodbs.com> <0c2201c2faa8$136c9c90$0b02a8c0@pointhere.net> In-Reply-To: <0c2201c2faa8$136c9c90$0b02a8c0@pointhere.net> MIME-Version: 1.0 Message-Id: <200304040809.22065.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-28.9 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/148 X-Sequence-Number: 37638 Jeff, Mlw,=20 > Absolutely. We could just use one large state or several small ones and > let folks download the whole thing if they wanted. Using that technique > you could control the size of the test quite closely and still make > something potentially quite valuable as a contribution beyond the bench. Hold on a second. The FCC database is still a better choice because it is= =20 more complex with a carefully defined schema. The Tiger database would be= =20 good for doing tests of type 1 and 3, but not for tests of types 2 and 4. It would certainly be interesting to use the Tiger database as the basis fo= r=20 an additional type of test: 6) Very Large Data Set: querying, then updating, 300+ selected rows from a= =20 2,000,000 + row table. ... but I still see the FCC database as our best candidate for the battery = of=20 tests 1-5. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-sql-owner@postgresql.org Fri Apr 4 11:16:22 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 369AC47631F for ; Fri, 4 Apr 2003 11:16:20 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 7A3B147631B for ; Fri, 4 Apr 2003 11:16:19 -0500 (EST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942345; Fri, 04 Apr 2003 08:16:16 -0800 Content-Type: text/plain; charset="iso-8859-2" From: Josh Berkus Organization: Aglio Database Solutions To: "Tomasz Myrta" , Robert Treat , pgsql-sql@postgresql.org Subject: Re: can i make this sql query more efficiant? Date: Fri, 4 Apr 2003 08:16:01 -0800 User-Agent: KMail/1.4.3 References: <1049403724.13799.5473.camel@camel> <20030404080209.M3259@klaster.net> In-Reply-To: <20030404080209.M3259@klaster.net> MIME-Version: 1.0 Message-Id: <200304040816.01369.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/67 X-Sequence-Number: 12768 Tomasz, > What about this: > select > event, > sum(case when level=3D1 then 1 else 0 end) as ones, > sum(case when level=3D2 then 1 else 0 end) as twos, > sum(case when level=3D3 then 1 else 0 end) as threes > from baz > group by event; That version is only more efficient for small data sets. I've generally= =20 found that case statements are slower than subselects for large data sets.= =20 YMMV. BTW, while it won't be faster, Joe Conway's crosstab function in /tablefunc= =20 does this kind of transformation. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 4 11:35:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4C0B84762A2 for ; Fri, 4 Apr 2003 11:35:07 -0500 (EST) Received: from localhost.localdomain (208-41-234-242.client.dsl.net [208.41.234.242]) by postgresql.org (Postfix) with ESMTP id AFDC5476036 for ; Fri, 4 Apr 2003 11:35:05 -0500 (EST) Received: from endeavour (endeavour.pointhere.net [192.168.2.11]) by localhost.localdomain (8.11.6/8.11.6) with SMTP id h34GOm932538; Fri, 4 Apr 2003 11:24:48 -0500 Message-ID: <0c8101c2fac9$316ad290$0b02a8c0@pointhere.net> Reply-To: "Jeffrey D. Brower" From: "Jeffrey D. Brower" To: , "Josh Berkus" Cc: References: <200304030955.16543.josh@agliodbs.com> <200304032029.12450.josh@agliodbs.com> <0c2201c2faa8$136c9c90$0b02a8c0@pointhere.net> <200304040809.22065.josh@agliodbs.com> Subject: Re: OSS database needed for testing Date: Fri, 4 Apr 2003 11:42:33 -0500 Organization: A Basic Marketing Company 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-Spam-Status: No, hits=-17.5 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,RCVD_IN_NJABL, REFERENCES,X_NJABL_OPEN_PROXY autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/58 X-Sequence-Number: 1564 I think you got me there. I have to agree with both points. (Besides, you are the one coding this thing and I think you understand it better than I do.) Let me know if I can help. Jeff ----- Original Message ----- From: "Josh Berkus" To: "Jeffrey D. Brower" ; Cc: ; Sent: Friday, April 04, 2003 11:09 AM Subject: Re: [PERFORM] [HACKERS] OSS database needed for testing > Jeff, Mlw, > > > Absolutely. We could just use one large state or several small ones and > > let folks download the whole thing if they wanted. Using that technique > > you could control the size of the test quite closely and still make > > something potentially quite valuable as a contribution beyond the bench. > > Hold on a second. The FCC database is still a better choice because it is > more complex with a carefully defined schema. The Tiger database would be > good for doing tests of type 1 and 3, but not for tests of types 2 and 4. > > It would certainly be interesting to use the Tiger database as the basis for > an additional type of test: > > 6) Very Large Data Set: querying, then updating, 300+ selected rows from a > 2,000,000 + row table. > > ... but I still see the FCC database as our best candidate for the battery of > tests 1-5. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster From pgsql-hackers-owner@postgresql.org Fri Apr 4 11:45:09 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A26BB474E42 for ; Fri, 4 Apr 2003 11:45:07 -0500 (EST) Received: from cuthbert.rcsinc.local (unknown [205.217.85.84]) by postgresql.org (Postfix) with ESMTP id 7ED964758E6 for ; Fri, 4 Apr 2003 11:44:36 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: Re: [PERFORM] OSS database needed for testing X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Date: Fri, 4 Apr 2003 11:47:56 -0500 Message-ID: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] [HACKERS] OSS database needed for testing Thread-Index: AcL6xZe0O5NuxSpzRnKHnOiFQ3MiwgAAoIgg From: "Merlin Moncure" To: "Josh Berkus" Cc: X-Spam-Status: No, hits=-6.6 required=5.0 tests=BAYES_01 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/152 X-Sequence-Number: 37642 The fcc FTP site is ftp.fcc.gov The location of the data of interest is at /pub/Bureaus/Wireless/Databases/uls/. There are zip files (pipe delimited) in complete and the daily changed files in daily. Theres lots of info in documentation which includes excel spreadsheets of the schema. These will have to be converted to sql statemtents. The ULS is the database system that holds the data for Fixed and Mobile wireless services. This includes most two way systems and point to multipoint (microwave) but not broadcast (AM, FM, TV) and not advanced radio. The database is really a database of applications. It contains application data submitted by wireless applicants.=20=20 There are two families of tables, prefixed with 'a' and 'l'. The 'a' tables stand for application records that are pending being granted by the fcc. The 'l' tables have received licenses and may or may not be operating. Combined, the 'a' and 'l' zipfiles represent a specific service. For example, 'a_micro' and 'l_micro' contain the applications and licensed data for microwave systems. The different services have slightly different layouts because they have different requirements. I strongly suggest looking at LMcomm and LMpriv first. These are the fixed land mobile systems, and 90% of the entire database. They also have identical layouts. There are a great deal of files in each zipfile, but here are the most interesting: hd: header data ad: application detail an: antenna data lo: location data fr: frequency data em: emission data There are others. I can help you write meaningful queries that are quite complex and will require optimization techniques. Merlin From pgsql-hackers-owner@postgresql.org Fri Apr 4 12:37:46 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3493B4763A4; Fri, 4 Apr 2003 12:37:44 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 4D00A476381; Fri, 4 Apr 2003 12:37:39 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942483; Fri, 04 Apr 2003 09:37:31 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Merlin Moncure" Subject: Re: [PERFORM] OSS database needed for testing Date: Fri, 4 Apr 2003 09:37:34 -0800 User-Agent: KMail/1.4.3 Cc: , pgsql-performance@postgresql.org References: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> In-Reply-To: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304040937.34362.josh@agliodbs.com> X-Spam-Status: No, hits=-21.9 required=5.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/160 X-Sequence-Number: 37650 Merlin, > The fcc FTP site is ftp.fcc.gov >=20 > The location of the data of interest is at > /pub/Bureaus/Wireless/Databases/uls/. Cool. I'll tackle this in a week or two. Right now, I'm being paid to=20 convert a client's data and that'll keep me busy through the weekend ... --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-hackers-owner@postgresql.org Fri Apr 4 12:57:07 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF95E4758E6; Fri, 4 Apr 2003 12:57:05 -0500 (EST) Received: from cuthbert.rcsinc.local (unknown [205.217.85.84]) by postgresql.org (Postfix) with ESMTP id 23263474E42; Fri, 4 Apr 2003 12:57:05 -0500 (EST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: Re: [PERFORM] OSS database needed for testing X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Date: Fri, 4 Apr 2003 13:00:26 -0500 Message-ID: <303E00EBDD07B943924382E153890E5434A93C@cuthbert.rcsinc.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] [HACKERS] OSS database needed for testing Thread-Index: AcL60VjZUYt9eVUZS3KRTUnNYPq3/QAAItEQ From: "Merlin Moncure" To: Cc: , X-Spam-Status: No, hits=-15.5 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/161 X-Sequence-Number: 37651 Josh Berkus wrote: > Cool. I'll tackle this in a week or two. Right now, I'm being paid to > convert a client's data and that'll keep me busy through the weekend ... I would suggest downloading the data now. I can help get you started with the create table statements and the import scripts. There are not very many ways to get the data in a reasonable timeframe: the spi functions or the copy command are a good place to start. Do not bother with running stuff through insert queries: take my word for it, it just won't work. Of course, if you use copy, you have to pre-format. Be aware that you will have many gigabytes (like more than 20) of data before you are done. Whatever you decide to do, document the process: the difficulty of getting large amounts of data into postgres quickly and easily has been a historical complaint of mine. Using mysql, it was a snap to get the data in but using *that* database I really felt it couldn't handle this much data. =20=20 I can also get you started with some example queries that should be quite a challenge to set up to run quickly. After that, it's your ballgame. Merlin From pgsql-performance-owner@postgresql.org Fri Apr 4 13:08:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 92E684758E6 for ; Fri, 4 Apr 2003 13:07:59 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D08D5474E42 for ; Fri, 4 Apr 2003 13:07:58 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942527; Fri, 04 Apr 2003 10:07:50 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Merlin Moncure" Subject: Re: OSS database needed for testing Date: Fri, 4 Apr 2003 10:07:49 -0800 User-Agent: KMail/1.4.3 Cc: References: <303E00EBDD07B943924382E153890E5434A93C@cuthbert.rcsinc.local> In-Reply-To: <303E00EBDD07B943924382E153890E5434A93C@cuthbert.rcsinc.local> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304041007.49417.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/61 X-Sequence-Number: 1567 Merlin,=20 > I would suggest downloading the data now. I can help get you started OK, downloading now. > with the create table statements and the import scripts. There are not > very many ways to get the data in a reasonable timeframe: the spi > functions or the copy command are a good place to start. Do not bother > with running stuff through insert queries: take my word for it, it just > won't work. Of course, if you use copy, you have to pre-format. Be > aware that you will have many gigabytes (like more than 20) of data > before you are done. From my perspective, the easiest and fastest way to do this is to create th= e=20 table definitions in PostgreSQL, and then to use Perl to convert the data= =20 format to something COPY will recognize. If you can do the create table= =20 statements for the LM* data, I can do the Perl scripts. Given that the *total* data is 20G, we'll want to use a subset of it. Per= =20 your suggestion, I am downloading the *LM* tables. I may truncate them=20 further if the resulting database is too large. If some of the other table= s=20 are reference lists or child tables, please tell me and I will download the= m=20 as well. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 4 14:03:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 629E3475F53 for ; Fri, 4 Apr 2003 14:03:14 -0500 (EST) Received: from email02.aon.at (WARSL401PIP7.highway.telekom.at [195.3.96.94]) by postgresql.org (Postfix) with SMTP id 443BF475C3D for ; Fri, 4 Apr 2003 14:03:13 -0500 (EST) Received: (qmail 384036 invoked from network); 4 Apr 2003 19:03:11 -0000 Received: from m154p001.dipool.highway.telekom.at (HELO cantor) ([62.46.9.33]) (envelope-sender ) by qmail2rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 4 Apr 2003 19:03:11 -0000 From: Manfred Koizar To: Josh Berkus Cc: "Tomasz Myrta" , Robert Treat , pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [SQL] can i make this sql query more efficiant? Date: Fri, 04 Apr 2003 21:03:08 +0200 Message-ID: References: <1049403724.13799.5473.camel@camel> <20030404080209.M3259@klaster.net> <200304040816.01369.josh@agliodbs.com> In-Reply-To: <200304040816.01369.josh@agliodbs.com> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-27.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_DSBL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_FORTE version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/62 X-Sequence-Number: 1568 On Fri, 4 Apr 2003 08:16:01 -0800, Josh Berkus wrote: >That version is only more efficient for small data sets. I've generally >found that case statements are slower than subselects for large data sets. I'd be honestly interested in the circumstances where you made that observation. >YMMV. Yes, it does :-) Out of curiosity I did a few tests with PG 7.2 on my old notebook: CREATE TABLE baz (event int, level int); INSERT INTO baz SELECT (100*random()+0.5), (3*random()+0.5); INSERT INTO baz SELECT (100*random()+0.5), (3*random()+0.5) FROM baz; ... INSERT INTO baz SELECT (100*random()+0.5), (3*random()+0.5) FROM baz; CREATE INDEX baz_event ON baz(event); ANALYSE baz; SELECT event, SUM (CASE level WHEN 1 THEN 1 ELSE 0 END) AS ones, SUM (CASE level WHEN 2 THEN 1 ELSE 0 END) AS twos, SUM (CASE level WHEN 3 THEN 1 ELSE 0 END) AS threes FROM baz GROUP BY event; SELECT event, (SELECT count(*) FROM baz a WHERE level = 1 AND a.event=baz.event) AS ones, (SELECT count(*) FROM baz a WHERE level = 2 and a.event=baz.event) AS twos, (SELECT count(*) FROM baz a WHERE level = 3 and a.event=baz.event) AS threes FROM baz GROUP BY event; tuples case subselect 8K 718.48 msec 16199.88 msec 32K 6168.18 msec 74742.85 msec 128K 25072.34 msec 304585.61 msec CLUSTER baz_event ON baz; ANALYSE baz; This changes the subselect plan from seq scan to index scan. 128K 12116.07 msec 17530.85 msec Add 128K more tuples, so that only the first half of the relation is clustered. 256K 45663.35 msec 117748.23 msec CLUSTER baz_event ON baz; ANALYSE baz; 256K 23691.81 msec 35138.26 msec Maybe it is just the data distribution (100 events, 3 levels, thousands of tuples) that makes CASE look faster than subselects ... Servus Manfred From pgsql-hackers-owner@postgresql.org Fri Apr 4 14:08:47 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F219A475F53 for ; Fri, 4 Apr 2003 14:08:45 -0500 (EST) Received: from utility.wgcr.org (unknown [206.74.232.205]) by postgresql.org (Postfix) with ESMTP id 429DD475D3B for ; Fri, 4 Apr 2003 14:08:45 -0500 (EST) Received: from utility.wgcr.org ([10.1.0.2]) by utility.wgcr.org (8.12.8/8.12.5) with ESMTP id h34J8YFJ013368; Fri, 4 Apr 2003 14:08:34 -0500 Received: from ([10.1.2.233]) by utility.wgcr.org (MailMonitor for SMTP v1.2.2 ) ; Fri, 4 Apr 2003 14:08:34 -0500 (EST) From: Lamar Owen To: "Merlin Moncure" , "Josh Berkus" Subject: Re: [PERFORM] OSS database needed for testing Date: Fri, 4 Apr 2003 14:08:31 -0500 User-Agent: KMail/1.5 Cc: References: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> In-Reply-To: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304041408.31175.lamar.owen@wgcr.org> X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/166 X-Sequence-Number: 37656 On Friday 04 April 2003 11:47, Merlin Moncure wrote: > The location of the data of interest is at > /pub/Bureaus/Wireless/Databases/uls/. > wireless services. This includes most two way systems and point to > multipoint (microwave) but not broadcast (AM, FM, TV) and not advanced > radio. Also check out the cdbs files (which contain the broadcast stuff as well as more) at /pub/Bureaus/Mass_Media/Databases/cdbs/ (which I would be more interested in doing, since I am a broadcast engineer by profession....) -- Lamar Owen WGCR Internet Radio 1 Peter 4:11 From pgsql-performance-owner@postgresql.org Fri Apr 4 14:26:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2EB1B4758E6; Fri, 4 Apr 2003 14:26:20 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 6BBB2474E42; Fri, 4 Apr 2003 14:26:19 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942665; Fri, 04 Apr 2003 11:26:11 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Manfred Koizar Subject: Re: [SQL] can i make this sql query more efficiant? Date: Fri, 4 Apr 2003 11:26:14 -0800 User-Agent: KMail/1.4.3 Cc: "Tomasz Myrta" , Robert Treat , pgsql-sql@postgresql.org, pgsql-performance@postgresql.org References: <1049403724.13799.5473.camel@camel> <200304040816.01369.josh@agliodbs.com> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304041126.14530.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/63 X-Sequence-Number: 1569 Manfred, > I'd be honestly interested in the circumstances where you made that > observation. Hmmmm ... one of my database involves a "crosstab" converstion where there= =20 were 13 possible values, and the converted table is heavily indexed. For= =20 that case, I found using CASE statements to be slower. For your example, how do the statistics change if you increase the number o= f=20 levels to 15 and put an index on them? --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-hackers-owner@postgresql.org Fri Apr 4 14:27:30 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6F9DD4758E6 for ; Fri, 4 Apr 2003 14:27:28 -0500 (EST) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id BBEAB474E42 for ; Fri, 4 Apr 2003 14:27:20 -0500 (EST) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2942672; Fri, 04 Apr 2003 11:27:13 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Lamar Owen , "Merlin Moncure" Subject: Re: [PERFORM] OSS database needed for testing Date: Fri, 4 Apr 2003 11:27:16 -0800 User-Agent: KMail/1.4.3 Cc: References: <303E00EBDD07B943924382E153890E5434A93B@cuthbert.rcsinc.local> <200304041408.31175.lamar.owen@wgcr.org> In-Reply-To: <200304041408.31175.lamar.owen@wgcr.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304041127.16441.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/170 X-Sequence-Number: 37660 Lamar, > Also check out the cdbs files (which contain the broadcast stuff as well = as=20 > more) at /pub/Bureaus/Mass_Media/Databases/cdbs/ (which I would be more= =20 > interested in doing, since I am a broadcast engineer by profession....) Hey, if you're willing to do the text --> postgres conversions, I'll use=20 whichever tables you want ... --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 4 17:57:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EECB24758E6 for ; Fri, 4 Apr 2003 17:57:23 -0500 (EST) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by postgresql.org (Postfix) with ESMTP id 342E1474E42 for ; Fri, 4 Apr 2003 17:57:19 -0500 (EST) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Fri, 4 Apr 2003 16:57:28 -0600 Subject: Re: ext3 filesystem / linux 7.3 From: Will LaShell To: josh@agliodbs.com Cc: "scott.marlowe" , Shankar K , Chris Sutton , pgsql-performance@postgresql.org In-Reply-To: <200304031512.45007.josh@agliodbs.com> References: <1049407460.22236.93.camel@lyric.ofsloans.com> <200304031512.45007.josh@agliodbs.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-YbMpuQfdPeI2TgdsjqPj" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 04 Apr 2003 15:57:19 -0700 Message-Id: <1049497040.1713.6.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Spam-Status: No, hits=-44.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/64 X-Sequence-Number: 1570 --=-YbMpuQfdPeI2TgdsjqPj Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Yes, I think we'd be willing to do that. ( 480 967 7530 ) is the phone contact for the company, IT manager is Trevor Mantle and you can ask for me as well. wlashell@outsourcefinancial.com is my work email you can feel free to use. Sincerely, Will LaShell On Thu, 2003-04-03 at 16:12, Josh Berkus wrote: > Will, >=20 >=20 > > At any rate we use ext3 on the filesystems and we've had no problems at > > all with the systems. Everything is stable and runs. We keep the > > machines running and available 24/7 with scheduled downtime transitions > > to the redundant servers as we need to for whatever kind of > > enhancements. >=20 > Hey, can we use you as a case study for advocacy.openoffice.org? >=20 > --=20 > -Josh Berkus >=20 > ______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 >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster --=-YbMpuQfdPeI2TgdsjqPj 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) iD4DBQA+jg3PZr3R5kgOZd0RAg5+AJ4nRWNHokJvxDTYFWYv5y9C6XfL9wCWIHQt L6Bcnc1bMQojTEsuthBFPg== =w1Ha -----END PGP SIGNATURE----- --=-YbMpuQfdPeI2TgdsjqPj-- From pgsql-performance-owner@postgresql.org Fri Apr 4 21:08:23 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5682C475A45 for ; Fri, 4 Apr 2003 21:08:22 -0500 (EST) Received: from email01.aon.at (WARSL401PIP8.highway.telekom.at [195.3.96.97]) by postgresql.org (Postfix) with SMTP id 5B0A04758E6 for ; Fri, 4 Apr 2003 21:08:21 -0500 (EST) Received: (qmail 636396 invoked from network); 5 Apr 2003 02:08:23 -0000 Received: from m160p014.dipool.highway.telekom.at (HELO cantor) ([62.46.9.238]) (envelope-sender ) by qmail1rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 5 Apr 2003 02:08:23 -0000 From: Manfred Koizar To: josh@agliodbs.com Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] can i make this sql query more efficiant? Date: Sat, 05 Apr 2003 04:08:22 +0200 Message-ID: References: <1049403724.13799.5473.camel@camel> <200304040816.01369.josh@agliodbs.com> <200304041126.14530.josh@agliodbs.com> In-Reply-To: <200304041126.14530.josh@agliodbs.com> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-32.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_FORTE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/65 X-Sequence-Number: 1571 On Fri, 4 Apr 2003 11:26:14 -0800, Josh Berkus wrote: >For your example, how do the statistics change if you increase the number of >levels to 15 and put an index on them? CREATE TABLE baz (event int, level int); INSERT INTO baz SELECT (100*random()+0.5), (15*random()+0.5); INSERT INTO baz SELECT (100*random()+0.5), (15*random()+0.5) FROM baz; ... INSERT INTO baz SELECT (100*random()+0.5), (15*random()+0.5) FROM baz; ANALYSE baz; CREATE INDEX baz_e ON baz(event); CREATE INDEX baz_l ON baz(level); CREATE INDEX baz_el ON baz(event, level); CREATE INDEX baz_le ON baz(level, event); tup cluster case subsel 8K - 1219.90 msec 70605.93 msec (seq scan) 8K - 3087.30 msec (seq scan off) 16K - 3861.87 msec 161902.36 msec (seq scan) 16K - 31498.76 msec (seq scan off) 16K event 2407.72 msec 5773.12 msec 16K level 2298.08 msec 32752.43 msec 16K l, e 2318.60 msec 3184.84 msec 32K - 6571.57 msec 7381.22 msec 32K e, l 4584.97 msec 3429.94 msec 32K l, e 4552.00 msec 64782.59 msec 32K l, e 4552.98 msec 3544.32 msec (baz_l dropped) 64K - 17275.73 msec 26525.24 msec 64K - 17150.16 msec 26195.87 msec (baz_le dropped) 64K - 17286.29 msec 656046.24 msec (baz_el dropped) 64K e, l 9137.88 msec 21809.52 msec 64K e, l 9183.25 msec 6412.97 msec (baz_e dropped) 64K e, l 11690.28 msec 10022.44 msec (baz_el dropped) 64K e, l 11740.54 msec 643046.39 msec (baz_le dropped) 64K l, e 9437.65 msec 133368.20 msec 64K l, e 9119.48 msec 6722.00 msec (baz_l dropped) 64K l, e 9294.68 msec 6663.15 msec (baz_le dropped) 64K l, e 9259.35 msec 639754.27 msec (baz_el dropped) 256K - 59809.69 msec 120755.78 msec 256K - 59809.69 msec 114133.34 msec (baz_le dropped) 256K e, l 38506.41 msec 88531.54 msec 256K e, l 49427.43 msec 43544.03 msec (baz_e dropped) 256K l, e 56821.23 msec 575850.14 msec 256K l, e 57462.78 msec 67911.41 msec (baz_l dropped) So yes, there are cases where subselect is faster than case, but case is much more robust regarding correlation and indices. Servus Manfred From pgsql-performance-owner@postgresql.org Mon Apr 7 10:28:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 436AB474E42 for ; Mon, 7 Apr 2003 10:28:42 -0400 (EDT) Received: from lewexch.lewis-stores.com (mail.lewis-stores.com [196.31.249.242]) by postgresql.org (Postfix) with ESMTP id 51398475F39 for ; Mon, 7 Apr 2003 10:28:29 -0400 (EDT) Received: by LEWEXCH with Internet Mail Service (5.5.2650.21) id ; Mon, 7 Apr 2003 16:24:50 +0200 Message-ID: From: Howard Oblowitz To: pgsql-performance@postgresql.org Subject: Load times on RAID0 compared to RAID5 Date: Mon, 7 Apr 2003 16:23:03 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain X-Spam-Status: No, hits=-6.6 required=5.0 tests=BAYES_01 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/67 X-Sequence-Number: 1573 We have a perl program that loads data into Postgres version 7.3.1 using deletes and inserts. We find that the load times are about 50% slower when we use a RAID5 disk system as compared to when we use RAID0 Are there any postgres configuration parameters that we can set to improve the performance on RAID5? From pgsql-performance-owner@postgresql.org Mon Apr 7 10:25:40 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 692E6475B85 for ; Mon, 7 Apr 2003 10:25:39 -0400 (EDT) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id 0A5E6474E42 for ; Mon, 7 Apr 2003 10:25:38 -0400 (EDT) Received: (qmail 15483 invoked from network); 7 Apr 2003 14:25:38 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 7 Apr 2003 14:25:38 -0000 From: "Robert John Shepherd" To: "'Stephan Szabo'" Cc: Subject: Re: [BUGS] Rapid deteriation of performance (might be caused by tsearch?) in 7.3.2 Date: Mon, 7 Apr 2003 15:25:38 +0100 Message-ID: <002801c2fd11$8f893340$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030404072355.Q93368-100000@megazone23.bigpanda.com> X-Spam-Status: No, hits=-10.1 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,QUOTE_TWICE_1 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/66 X-Sequence-Number: 1572 > > I've been running this daily: > > vacuumdb -h localhost -a -z > > Should I be using the full switch then? > > Well, you generally shouldn't need to if the fsm settings are high enough. > If you're doing really big updates like update each row of a 1 billion > row table, you may end up having to do one immediately following that. > Of course, if you're doing that, performance is probably not your biggest > concern. ;) Not doing that, no. ;) > Explain analyze'll tell us if the system is changing plans (presumably to > a worse one) It wasn't, oddly enough. I've added a new table that cuts down 85% of the work this query has to do, and it seems to have helped an awful lot at the moment. Of course only time will tell. :) Thanks for the suggestions. Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-performance-owner@postgresql.org Mon Apr 7 10:36:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7EA50475E9D for ; Mon, 7 Apr 2003 10:36:14 -0400 (EDT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id A3F31475C15 for ; Mon, 7 Apr 2003 10:36:12 -0400 (EDT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 192XjN-00041G-00 for ; Mon, 07 Apr 2003 10:36:17 -0400 Received: by dba2 (Postfix, from userid 1019) id 480D5CCF3; Mon, 7 Apr 2003 10:36:17 -0400 (EDT) Date: Mon, 7 Apr 2003 10:36:17 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Load times on RAID0 compared to RAID5 Message-ID: <20030407143617.GC28340@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.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/68 X-Sequence-Number: 1574 On Mon, Apr 07, 2003 at 04:23:03PM +0200, Howard Oblowitz wrote: > We find that the load times are about 50% slower when we use a > RAID5 disk system as compared to when we use RAID0 Well, given that RAID 5 has to do some calculation and RAID 0 doesn't, I shouldn't think this is very surprising. You should let us know what disk subsystem you have, &c. It's impossible to give any advice on the basis of the little that's here. RAID performance is linked to its configuration and the hardware and software in use. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Mon Apr 7 11:35:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1ABD2475EF0 for ; Mon, 7 Apr 2003 11:35:21 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 6E13F474E42 for ; Mon, 7 Apr 2003 11:35:18 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h37FXSYQ001487; Mon, 7 Apr 2003 09:33:28 -0600 (MDT) Date: Mon, 7 Apr 2003 09:29:48 -0600 (MDT) From: "scott.marlowe" To: Howard Oblowitz Cc: Subject: Re: Load times on RAID0 compared to RAID5 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/70 X-Sequence-Number: 1576 On Mon, 7 Apr 2003, Howard Oblowitz wrote: > We have a perl program that loads data into Postgres version 7.3.1 > using deletes and inserts. > > We find that the load times are about 50% slower when we use a > RAID5 disk system as compared to when we use RAID0 > > Are there any postgres configuration parameters that we can set to improve > the performance on RAID5? Well, RAID0 SHOULD be about twice as fast as RAID5 for most applications, maybe even faster for others. Of course, RAID0 offers no redundancy, so if any single drive fails your data disappears in a large puff of smoke. RAID5 can survive a single drive failure, and that doesn't come for free. RAID1 may offer a better compromise of performance and reliability for many apps than RAID5. Generally RAID0 is fastest, RAID1 is fast but can't grow to be as big as RAID5, RAID5 handles large parallel access better than RAID1, RAID1 handles batch processing better than RAID5. Mixing them together sometimes helps, sometimes not. RAID1 on top of RAID0 works pretty well but costs the most per meg stored than most plain RAID5 or RAID1 setups. From pgsql-performance-owner@postgresql.org Mon Apr 7 11:31:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3D7E7475B85 for ; Mon, 7 Apr 2003 11:31:26 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0C238474E42 for ; Mon, 7 Apr 2003 11:31:23 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2948765; Mon, 07 Apr 2003 08:31:20 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Howard Oblowitz , pgsql-performance@postgresql.org Subject: Re: Load times on RAID0 compared to RAID5 Date: Mon, 7 Apr 2003 08:31:09 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200304070831.09813.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/69 X-Sequence-Number: 1575 Howard, > We have a perl program that loads data into Postgres version 7.3.1 > using deletes and inserts. Might I suggest COPY instead? --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Mon Apr 7 13:17:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B464F476178 for ; Mon, 7 Apr 2003 13:17:53 -0400 (EDT) Received: from localhost.localdomain (unknown [65.217.53.66]) by postgresql.org (Postfix) with ESMTP id C60CD475FBA for ; Mon, 7 Apr 2003 13:17:44 -0400 (EDT) Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) by localhost.localdomain (8.12.8/8.12.5) with ESMTP id h37Htakj000670; Mon, 7 Apr 2003 13:55:36 -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 h37HHZx29153; Mon, 7 Apr 2003 13:17:35 -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 F3HTM18W; Mon, 7 Apr 2003 13:17:35 -0400 Subject: Re: ext3 filesystem / linux 7.3 From: Robert Treat To: Shankar K Cc: "scott.marlowe" , Chris Sutton , pgsql-performance@postgresql.org In-Reply-To: <20030403194552.914.qmail@web21103.mail.yahoo.com> References: <20030403194552.914.qmail@web21103.mail.yahoo.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 07 Apr 2003 13:17:35 -0400 Message-Id: <1049735855.8344.8807.camel@camel> Mime-Version: 1.0 X-Spam-Status: No, hits=-35.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/71 X-Sequence-Number: 1577 We've had 2 crashes on red hat 7.3 in about 9 months of running. Both instances required manual power off/on of the server, but everything came up nice and ready to go. The problems seemed to stem from i/o load with the kernel (not postgresql specific), but should be resolved with the latest Red Hat kernel. If you search on buffer_jdirty in bugzilla you'll see a couple of reports. Robert Treat On Thu, 2003-04-03 at 14:45, Shankar K wrote: > Hi Scott, > > Could you please share with us the problems you had > with linux 7.3 > > would be really interested to know the kernel configs > and ext3 filesystem modes > > Shankar > > --- "scott.marlowe" wrote: > > On Thu, 3 Apr 2003, Chris Sutton wrote: > > > > > On Wed, 2 Apr 2003, Josh Berkus wrote: > > > > > > > > I had previously understood that ext3 was a > > bad thing with PostgreSQL and I > > > > > went way above and beyond to create it on an > > Ext2 filesystem (the only one > > > > > on the server) and mount that. > > > > > > We recently started using Postgres on a new > > database server running RH 7.3 > > > and ext3. Due to some kernel problems the machine > > would crash at random > > > times. Each time it crashed it came back up > > extremly easily with no data > > > loss. If we were on ext2 coming back up after a > > crash probably wouldn't > > > have been quite as easy. > > > > > > We have since given up on RH 7.3 and gone with RH > > Enterprise ES. Just an > > > FIY for any of you out there thinking about moving > > to RH 7.3 or those that > > > are having problems with 7.3 and ext3. > > > > We're still running RH 7.2 due to issues we had with > > 7.3 as well. > > From pgsql-sql-owner@postgresql.org Tue Apr 8 10:58:56 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 39D31474E42 for ; Tue, 8 Apr 2003 10:58:55 -0400 (EDT) Received: from smtp-out.net.ipl.pt (31.220.137.193.in-addr.arpa [193.137.220.31]) by postgresql.org (Postfix) with ESMTP id E8CFD4763B6 for ; Tue, 8 Apr 2003 10:58:52 -0400 (EDT) Received: (qmail 15518 invoked by uid 508); 8 Apr 2003 15:58:56 +0100 Received: from rutes@eselx.ipl.pt by smtp-int.net.ipl.pt by uid 505 with qmail-scanner (sophie: 2.10/3.64. Clear:. Processed in 0.04692 secs); 08 Apr 2003 14:58:56 -0000 X-IPLNet-RcptTo: pgsql-sql@postgresql.org Received: from matrix.eselx.ipl.pt (193.137.237.148) by 0 with SMTP; 8 Apr 2003 15:58:55 +0100 Received: from [172.21.3.60] (helo=eselx.ipl.pt) by matrix.eselx.ipl.pt with esmtp (Exim 3.35 #1 (Debian)) id 192uYi-0007Yt-00 for ; Tue, 08 Apr 2003 15:58:48 +0100 Message-ID: <3E92E3B1.7070405@eselx.ipl.pt> Date: Tue, 08 Apr 2003 15:58:57 +0100 From: rute solipa User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: help need it Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-11.7 required=5.0 tests=BAYES_10,TO_ADDRESS_EQ_REAL,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/115 X-Sequence-Number: 12816 i've an oracle query: Select tb_users.ds_description, tb_users.cd_role, tb_users.cd_user, tb_users.ds_login, tb_monitores.cod_equipa from tb_users, tb_monitores where ds_login like 'varLogin' and ds_password like 'varPassword' and tb_users.cd_user = tb_monitores.cd_user(+) how can i transform it to an postgresql query? best regards etur From pgsql-sql-owner@postgresql.org Tue Apr 8 11:16:32 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E623D476380 for ; Tue, 8 Apr 2003 11:16:31 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D0E2D4763A2 for ; Tue, 8 Apr 2003 11:16:30 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 5E0BCD609; Tue, 8 Apr 2003 08:16:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 4D8515C0A; Tue, 8 Apr 2003 08:16:34 -0700 (PDT) Date: Tue, 8 Apr 2003 08:16:34 -0700 (PDT) From: Stephan Szabo To: rute solipa Cc: "pgsql-sql@postgresql.org" Subject: Re: help need it In-Reply-To: <3E92E3B1.7070405@eselx.ipl.pt> Message-ID: <20030408081439.P50886-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/116 X-Sequence-Number: 12817 On Tue, 8 Apr 2003, rute solipa wrote: > i've an oracle query: > > Select tb_users.ds_description, tb_users.cd_role, tb_users.cd_user, > tb_users.ds_login, tb_monitores.cod_equipa from tb_users, tb_monitores > where ds_login like 'varLogin' and ds_password like 'varPassword' and > tb_users.cd_user = tb_monitores.cd_user(+) > > how can i transform it to an postgresql query? Should be something like: Select tb_users.ds_description, tb_users.cd_role, tb_users.cd_user, tb_users.ds_login, tb_monitores.cod_equipa from tb_users left outer join tb_monitores using (cd_user) where ds_login like 'varLogin' and ds_password like 'varPassword'; From pgsql-sql-owner@postgresql.org Tue Apr 8 11:23:41 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 733994762F1 for ; Tue, 8 Apr 2003 11:23:40 -0400 (EDT) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 53C774762E1 for ; Tue, 8 Apr 2003 11:23:39 -0400 (EDT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50] (may be forged)) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h38JeeIs009771; Tue, 8 Apr 2003 17:40:40 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h38JeeRb009767; Tue, 8 Apr 2003 17:40:40 -0200 Date: Tue, 8 Apr 2003 17:40:39 -0200 (GMT+2) From: Achilleus Mantzios To: rute solipa Cc: "pgsql-sql@postgresql.org" Subject: Re: help need it In-Reply-To: <3E92E3B1.7070405@eselx.ipl.pt> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES,SIGNATURE_LONG_DENSE, USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/117 X-Sequence-Number: 12818 On Tue, 8 Apr 2003, rute solipa wrote: > i've an oracle query: > > Select tb_users.ds_description, tb_users.cd_role, tb_users.cd_user, > tb_users.ds_login, tb_monitores.cod_equipa from tb_users, tb_monitores > where ds_login like 'varLogin' and ds_password like 'varPassword' and > tb_users.cd_user = tb_monitores.cd_user(+) > > how can i transform it to an postgresql query? Can you check the postgresql manual if the (+) operator means something related to OUTER joins? If yes then use [LEFT|RIGHT] OUTER JOIN of postgresql. > > > best regards > > etur > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-210-8981112 fax: +30-210-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-general-owner@postgresql.org Tue Apr 8 15:59:29 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7199D4762D7; Tue, 8 Apr 2003 15:59:28 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id E817E4762CF; Tue, 8 Apr 2003 15:59:27 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id D7B1943A89E; Tue, 8 Apr 2003 15:59:27 -0400 (EDT) From: "Denis" X-Newsgroups: comp.databases.postgresql.general, comp.databases.postgresql.performance, comp.databases.postgresql.sql Subject: Yet Another (Simple) Case of Index not used Date: Tue, 8 Apr 2003 12:57:16 -0700 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 68 Message-ID: X-Complaints-To: usenet@news.hub.org X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/526 X-Sequence-Number: 40591 Hi there, I'm running into a quite puzzling simple example where the index I've created on a fairly big table (465K entries) is not used, against all common sense expectations: The query I am trying to do (fast) is: select count(*) from addresses; This takes more than a second to complete, because, as the 'explain' command shows me, the index created on 'addresses' is not used, and a seq scan is being used. One would assume that the creation of an index would allow the counting of the number of entries in a table to be instantanous? Here are the details: * Using the latest postgresql 7.3.2 release, built and installed from sources on a Linux box, under Red Hat 8.0 * I have an 'addresses' table defined as: Columm | Type ------------------------------- address | text city | char var (20) zip | char var (5) state | char var (2) Unique keys: addresses_idx * I have created a unique index 'addresses_idx' on (address, city, zip, state): \d addresses_idx; Index "addresses_idx" Columm | Type ------------------------------- address | text city | char var (20) zip | char var (5) state | char var (2) unique btree * I did (re)create the index several times * I did run the vacuum analyse command several times * I forced enable_indexscan to true * I forced enable_seqscan to false Despite of all of this, each time I try: ===> explain select count(*) from addresses; I get the following: ===> NOTICE: QUERY PLAN: ===> ===> Aggregate (cost=100012799.89..100012799.89 rows=1 width=0) ===> -> Seq Scan on addresses (cost=100000000.00..100011635.11 rows=465911 width=0) Quite puzzling, isn't it? I've searched a bunch of mailing lists and websites, and found many reports of special cases where it could be argued that the planner may have had a case for choosing seq scanning over idx scanning, but unless I am missing some fundamental concept, there's something wrong here. Any suggestion anyone? Thanks, Denis denis@next2me.com From pgsql-general-owner@postgresql.org Tue Apr 8 16:23:21 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B28F94758E6; Tue, 8 Apr 2003 16:23:20 -0400 (EDT) Received: from snoopy.oit.edu (snoopy.OIT.EDU [140.211.135.12]) by postgresql.org (Postfix) with ESMTP id B61B9474E42; Tue, 8 Apr 2003 16:23:19 -0400 (EDT) Received: from cvc.net (purvine-141-62.oit.edu [140.211.141.62]) by snoopy.oit.edu (8.12.9/8.12.9/OIT-4.0) with ESMTP id h38KNJGM007905; Tue, 8 Apr 2003 13:23:19 -0700 Message-ID: <3E933048.4000805@cvc.net> Date: Tue, 08 Apr 2003 13:25:44 -0700 From: Dennis Gearon Reply-To: gearond@cvc.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, ru MIME-Version: 1.0 To: Denis Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Yet Another (Simple) Case of Index not used References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/527 X-Sequence-Number: 40592 as I remember, mysql keeps the record count in a variable and is instantaneaous with that kind of query. Recent posts suggest the Postgres does not keep that variable and has to do the seq scan. Denis wrote: > Hi there, > I'm running into a quite puzzling simple example where the index I've > created on a fairly big table (465K entries) is not used, against all common > sense expectations: > The query I am trying to do (fast) is: > > select count(*) from addresses; > > This takes more than a second to complete, because, as the 'explain' command > shows me, > the index created on 'addresses' is not used, and a seq scan is being used. > One would assume that the creation of an index would allow the counting of > the number of entries in a table to be instantanous? > > Here are the details: > > * Using the latest postgresql 7.3.2 release, built and installed from > sources on a Linux box, under Red Hat 8.0 > > * I have an 'addresses' table defined as: > Columm | Type > ------------------------------- > address | text > city | char var (20) > zip | char var (5) > state | char var (2) > Unique keys: addresses_idx > > * I have created a unique index 'addresses_idx' on (address, city, zip, > state): > \d addresses_idx; > Index "addresses_idx" > Columm | Type > ------------------------------- > address | text > city | char var (20) > zip | char var (5) > state | char var (2) > unique btree > > * I did (re)create the index several times > * I did run the vacuum analyse command several times > * I forced enable_indexscan to true > * I forced enable_seqscan to false > > Despite of all of this, each time I try: > ===> explain select count(*) from addresses; > I get the following: > ===> NOTICE: QUERY PLAN: > ===> > ===> Aggregate (cost=100012799.89..100012799.89 rows=1 width=0) > ===> -> Seq Scan on addresses (cost=100000000.00..100011635.11 rows=465911 > width=0) > > Quite puzzling, isn't it? > I've searched a bunch of mailing lists and websites, and found many reports > of special cases where it could be argued that the planner may have had a > case for choosing seq scanning over idx scanning, but unless I am missing > some fundamental concept, there's something wrong here. > Any suggestion anyone? > Thanks, > > Denis > denis@next2me.com > > > ---------------------------(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-general-owner@postgresql.org Tue Apr 8 16:26:25 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 795FE4758E6; Tue, 8 Apr 2003 16:26:24 -0400 (EDT) Received: from voyager.corporate.connx.com (unknown [66.228.214.131]) by postgresql.org (Postfix) with ESMTP id B65EE474E42; Tue, 8 Apr 2003 16:26:23 -0400 (EDT) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Yet Another (Simple) Case of Index not used X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Tue, 8 Apr 2003 13:26:21 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [GENERAL] Yet Another (Simple) Case of Index not used Thread-Index: AcL+CppcOx7rQQ2DRIG4S7Ej0yTW3AAAd95g From: "Dann Corbit" To: "Denis" , , , X-Spam-Status: No, hits=-8.6 required=5.0 tests=BAYES_01,QUOTED_EMAIL_TEXT,RCVD_IN_RFCI version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/528 X-Sequence-Number: 40593 > -----Original Message----- > From: Denis [mailto:denis@next2me.com]=20 > Sent: Tuesday, April 08, 2003 12:57 PM > To: pgsql-performance@postgresql.org;=20 > pgsql-general@postgresql.org; pgsql-sql@postgresql.org > Subject: [GENERAL] Yet Another (Simple) Case of Index not used >=20 >=20 > Hi there, > I'm running into a quite puzzling simple example where the=20 > index I've created on a fairly big table (465K entries) is=20 > not used, against all common sense expectations: The query I=20 > am trying to do (fast) is: >=20 > select count(*) from addresses; >=20 > This takes more than a second to complete, because, as the=20 > 'explain' command shows me, the index created on 'addresses'=20 > is not used, and a seq scan is being used.=20 As well it should be. > One would assume=20 > that the creation of an index would allow the counting of the=20 > number of entries in a table to be instantanous? Traversing the index to perform the count will definitely make the query many times slower. A general rule of thumb (not sure if it is true with PostgreSQL) is that if you have to traverse more than 10% of the data with an index then a full table scan will be faster. This is especially true when there is highly redundant data in the index fields. If there were an index on bit data type, and you have half and half 1 and 0, an index scan of the table will be disastrous. To simply scan the table, we will just sequentially read pages until the data is exhausted. If we follow the index, we will randomly jump from page to page, defeating the read buffering. [snip] From pgsql-general-owner@postgresql.org Tue Apr 8 16:42:22 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B4C0A476315; Tue, 8 Apr 2003 16:42:20 -0400 (EDT) Received: from snoopy.oit.edu (snoopy.OIT.EDU [140.211.135.12]) by postgresql.org (Postfix) with ESMTP id 8FADD476302; Tue, 8 Apr 2003 16:42:19 -0400 (EDT) Received: from cvc.net (purvine-141-62.oit.edu [140.211.141.62]) by snoopy.oit.edu (8.12.9/8.12.9/OIT-4.0) with ESMTP id h38KgEGM010079; Tue, 8 Apr 2003 13:42:14 -0700 Message-ID: <3E93348C.20208@cvc.net> Date: Tue, 08 Apr 2003 13:43:56 -0700 From: Dennis Gearon Reply-To: gearond@cvc.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030210 X-Accept-Language: en-us, ru MIME-Version: 1.0 To: Dann Corbit Cc: Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Yet Another (Simple) Case of Index not used References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/530 X-Sequence-Number: 40595 from mysql manual: ------------------------------------------------------------- "COUNT(*) is optimized to return very quickly if the SELECT retrieves from one table, no other columns are retrieved, and there is no WHERE clause. For example: mysql> select COUNT(*) from student;" ------------------------------------------------------------- A nice little optimization, maybe not possible in a MVCC system. Dann Corbit wrote: >>-----Original Message----- >>From: Denis [mailto:denis@next2me.com] >>Sent: Tuesday, April 08, 2003 12:57 PM >>To: pgsql-performance@postgresql.org; >>pgsql-general@postgresql.org; pgsql-sql@postgresql.org >>Subject: [GENERAL] Yet Another (Simple) Case of Index not used >> >> >>Hi there, >>I'm running into a quite puzzling simple example where the >>index I've created on a fairly big table (465K entries) is >>not used, against all common sense expectations: The query I >>am trying to do (fast) is: >> >>select count(*) from addresses; >> >>This takes more than a second to complete, because, as the >>'explain' command shows me, the index created on 'addresses' >>is not used, and a seq scan is being used. > > > As well it should be. > > >>One would assume >>that the creation of an index would allow the counting of the >>number of entries in a table to be instantanous? > > > Traversing the index to perform the count will definitely make the query > many times slower. > > A general rule of thumb (not sure if it is true with PostgreSQL) is that > if you have to traverse more than 10% of the data with an index then a > full table scan will be faster. This is especially true when there is > highly redundant data in the index fields. If there were an index on > bit data type, and you have half and half 1 and 0, an index scan of the > table will be disastrous. > > To simply scan the table, we will just sequentially read pages until the > data is exhausted. If we follow the index, we will randomly jump from > page to page, defeating the read buffering. > [snip] > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > From pgsql-performance-owner@postgresql.org Tue Apr 8 17:52:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3145F475E14 for ; Tue, 8 Apr 2003 17:52:51 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id AFB1A4758E6 for ; Tue, 8 Apr 2003 17:52:49 -0400 (EDT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2951738; Tue, 08 Apr 2003 14:52:44 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Denis" , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Tue, 8 Apr 2003 14:52:40 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304081452.40424.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/75 X-Sequence-Number: 1581 Dennis, > I'm running into a quite puzzling simple example where the index I've > created on a fairly big table (465K entries) is not used, against all com= mon > sense expectations: > The query I am trying to do (fast) is: >=20 > select count(*) from addresses; PostgreSQL is currently unable to use indexes on aggregate queries. This = is=20 because of two factors: 1) MVCC means that the number of rows must be recalculated for each=20 connection's current transaction, and cannot be "cached" anywhere by the=20 database system; 2) Our extensible model of user-defined aggregates means that each aggregat= e=20 is a "black box" whose internal operations are invisible to the planner. This is a known performance issue for Postgres, and I believe that a couple= of=20 people on Hackers are looking at modifying aggregate implementation for 8.0= =20 to use appropriate available indexes, at least for MIN, MAX and COUNT. Unt= il=20 then, you will need to either put up with the delay, or create a=20 trigger-driven aggregates caching table. If you are trying to do a correlated count, like "SELECT type, count(*) fro= m=20 aggregates GROUP BY type", Tom Lane has already added a hash-aggregates=20 structure in the 7.4 source that will speed this type of query up=20 considerably for systems with lots of RAM. (PS: in the future, please stick to posting questions to one list at a time= ,=20 thanks) --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Apr 8 19:22:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5D2D24758E6 for ; Tue, 8 Apr 2003 19:22:45 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id A29CE474E42 for ; Tue, 8 Apr 2003 19:22:44 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 08 Apr 2003 16:22:47 -0700 Date: Tue, 8 Apr 2003 16:22:47 -0700 From: Kevin Brown To: pgsql-performance@postgresql.org Cc: Josh Berkus Subject: Re: ext3 filesystem / linux 7.3 Message-ID: <20030408232247.GH1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org, Josh Berkus References: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> <200304030852.34194.josh@agliodbs.com> <0b7a01c2fa04$2d299bf0$0b02a8c0@pointhere.net> <200304030943.06406.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200304030943.06406.josh@agliodbs.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/76 X-Sequence-Number: 1582 Josh Berkus wrote: > Jeffery, > > > Can't we generate data? Random data stored in random formats at random > > sizes would stress the file system wouldn't it? > > In my experience, randomly generated data tends to resemble real data very > little in distribution patterns and data types. This is one of the > limitations of PGBench. Okay, from this it sounds like what we need is information on the data types typically used for real world applications and information on the the distribution patterns for each type (the latter could get quite complex and varied, I'm sure, but since we're after something that's typical, we only need a few examples). So perhaps the first step in this is to write something that will show what the distribution pattern for data in a table is? With that information, we *could* randomly generate data that would conform to the statistical patterns seen in the real world. In fact, even though the databases you have access to are all proprietary, I'm pretty sure their owners would agree to let you run a program that would gather statistical distribution about it. Then (as long as they agree) you could copy the schema itself, recreate it on the test system, and randomly generate the data. -- Kevin Brown kevin@sysexperts.com From pgsql-general-owner@postgresql.org Tue Apr 8 19:46:35 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3C2CE475E14; Tue, 8 Apr 2003 19:46:34 -0400 (EDT) Received: from svana.org (svana.org [203.20.62.76]) by postgresql.org (Postfix) with ESMTP id 52926474E42; Tue, 8 Apr 2003 19:46:33 -0400 (EDT) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 1932nH-0006P3-00; Wed, 09 Apr 2003 09:46:23 +1000 Date: Wed, 9 Apr 2003 09:46:23 +1000 From: Martijn van Oosterhout To: Denis Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Yet Another (Simple) Case of Index not used Message-ID: <20030408234623.GD15928@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IMjqdzrDRly81ofr" Content-Disposition: inline In-Reply-To: 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-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/544 X-Sequence-Number: 40609 --IMjqdzrDRly81ofr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 08, 2003 at 12:57:16PM -0700, Denis wrote: > The query I am trying to do (fast) is: >=20 > select count(*) from addresses; >=20 > This takes more than a second to complete, because, as the 'explain' comm= and > shows me, > the index created on 'addresses' is not used, and a seq scan is being use= d. > One would assume that the creation of an index would allow the counting of > the number of entries in a table to be instantanous? Incorrect assumption. select count(*) can produce different results in different backends depending on the current state of the active transactions. --=20 Martijn van Oosterhout http://svana.org/kleptog/ > "the West won the world not by the superiority of its ideas or values or > religion but rather by its superiority in applying organized violence. > Westerners often forget this fact, non-Westerners never do." > - Samuel P. Huntington --IMjqdzrDRly81ofr 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+k19PY5Twig3Ge+YRAs7pAJ4kxoQQnRu1zQeCzfB+8lRA4XgTtQCeMb1T m2DuiE8HICjO5qVCcVKdgUI= =LkBi -----END PGP SIGNATURE----- --IMjqdzrDRly81ofr-- From pgsql-performance-owner@postgresql.org Tue Apr 8 20:12:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66B6F4758F1 for ; Tue, 8 Apr 2003 20:12:26 -0400 (EDT) Received: from localhost.localdomain (adsl-216-103-208-155.dsl.snfc21.pacbell.net [216.103.208.155]) by postgresql.org (Postfix) with ESMTP id 0DB50474E42 for ; Tue, 8 Apr 2003 20:12:12 -0400 (EDT) Received: from flipper5 (flipper5.next2me.com [192.168.0.3]) by localhost.localdomain (8.12.8/8.12.8) with SMTP id h390DYgL032299; Tue, 8 Apr 2003 17:13:34 -0700 Reply-To: From: "Denis @ Next2Me" To: "Martijn van Oosterhout" , "Denis" Cc: Subject: Re: [GENERAL] Yet Another (Simple) Case of Index not used Date: Tue, 8 Apr 2003 17:10:01 -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) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030408234623.GD15928@svana.org> X-Spam-Status: No, hits=-14.7 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/78 X-Sequence-Number: 1584 Interesting generic response. In other words, "it all depends". Well, a de facto observation is: "In my case, it's always much slower with, say, mysql". Understand me, I don't mean to be starting a performance comparaison mysql vs postgresql, which is probably an old subject, I am just looking for a solution to solve this type of performance issues, ie the generic cases: select count(*) from addresses where address is like 'pattern%'; Which are very fast on mysql, and very slow on postgresql. Understood, it will always depend on some parameters, but the real question is: how much control does one have over those parameters, and how does one tweak them to reach optimal performance? D. > -----Original Message----- > From: pgsql-performance-owner@postgresql.org > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Martijn van > Oosterhout > Sent: Tuesday, April 08, 2003 4:46 PM > To: Denis > Cc: pgsql-performance@postgresql.org; pgsql-general@postgresql.org; > pgsql-sql@postgresql.org > Subject: Re: [PERFORM] [GENERAL] Yet Another (Simple) Case of Index not > used > > > On Tue, Apr 08, 2003 at 12:57:16PM -0700, Denis wrote: > > The query I am trying to do (fast) is: > > > > select count(*) from addresses; > > > > This takes more than a second to complete, because, as the 'explain' command > > shows me, > > the index created on 'addresses' is not used, and a seq scan is being used. > > One would assume that the creation of an index would allow the counting of > > the number of entries in a table to be instantanous? > > Incorrect assumption. select count(*) can produce different results in > different backends depending on the current state of the active > transactions. > -- > Martijn van Oosterhout http://svana.org/kleptog/ > > "the West won the world not by the superiority of its ideas or values or > > religion but rather by its superiority in applying organized violence. > > Westerners often forget this fact, non-Westerners never do." > > - Samuel P. Huntington > From pgsql-performance-owner@postgresql.org Tue Apr 8 20:23:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B18D14758E6 for ; Tue, 8 Apr 2003 20:23:27 -0400 (EDT) Received: from localhost.localdomain (adsl-216-103-208-155.dsl.snfc21.pacbell.net [216.103.208.155]) by postgresql.org (Postfix) with ESMTP id 82369474E42 for ; Tue, 8 Apr 2003 20:23:26 -0400 (EDT) Received: from flipper5 (flipper5.next2me.com [192.168.0.3]) by localhost.localdomain (8.12.8/8.12.8) with SMTP id h390OmgL032444; Tue, 8 Apr 2003 17:24:48 -0700 Reply-To: From: "Denis @ Next2Me" To: , "Denis" , Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Tue, 8 Apr 2003 17:21:16 -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) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <200304081452.40424.josh@agliodbs.com> X-Spam-Status: No, hits=-14.7 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/79 X-Sequence-Number: 1585 Josh, I am no database expert, and even less knowledgeable about the internals of postgresql, so I'll trust you on the 2 points you make below. Are you saying the 7.4 'group by' trick would be faster than the simple select count(*)? That seems hard to believe, being that the request now has to fetch / sort the data. I must be missing something. The kind of requests that I am really interested in are: select count(*) from table where table.column like 'pattern%' These seems to go much master on mysql (which I guess it not a MVCC database? or wasn't the Innobase supposed to make it so?), than on postgresql. So, in the meantime, I've decided to split up my data into two sets, the static big tables which are handled by mysql, and the rest of it handled by postgresql.... ps: apologies for the cross-posting. > -----Original Message----- > From: Josh Berkus [mailto:josh@agliodbs.com] > Sent: Tuesday, April 08, 2003 2:53 PM > To: Denis; pgsql-performance@postgresql.org > Subject: Re: [SQL] Yet Another (Simple) Case of Index not used > > > Dennis, > > > I'm running into a quite puzzling simple example where the index I've > > created on a fairly big table (465K entries) is not used, against all common > > sense expectations: > > The query I am trying to do (fast) is: > > > > select count(*) from addresses; > > PostgreSQL is currently unable to use indexes on aggregate queries. This is > because of two factors: > 1) MVCC means that the number of rows must be recalculated for each > connection's current transaction, and cannot be "cached" anywhere by the > database system; > 2) Our extensible model of user-defined aggregates means that each aggregate > is a "black box" whose internal operations are invisible to the planner. > > This is a known performance issue for Postgres, and I believe that a couple of > people on Hackers are looking at modifying aggregate implementation for 8.0 > to use appropriate available indexes, at least for MIN, MAX and COUNT. Until > then, you will need to either put up with the delay, or create a > trigger-driven aggregates caching table. > > If you are trying to do a correlated count, like "SELECT type, count(*) from > aggregates GROUP BY type", Tom Lane has already added a hash-aggregates > structure in the 7.4 source that will speed this type of query up > considerably for systems with lots of RAM. > > (PS: in the future, please stick to posting questions to one list at a time, > thanks) > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > From pgsql-general-owner@postgresql.org Wed Apr 9 12:13:43 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ED4514758E6 for ; Tue, 8 Apr 2003 20:44:51 -0400 (EDT) Received: from clam.niwa.co.nz (clam.niwa.cri.nz [202.36.29.1]) by postgresql.org (Postfix) with ESMTP id 8E84A474E42 for ; Tue, 8 Apr 2003 20:44:50 -0400 (EDT) Received: from storm.niwa.co.nz (storm.niwa.co.nz [192.168.59.10]) by clam.niwa.co.nz (8.12.6p2/8.12.3) with ESMTP id h390imuX064083; Wed, 9 Apr 2003 12:44:49 +1200 (NZST) (envelope-from b.wood@niwa.co.nz) Received: from localhost (wood@localhost) by storm.niwa.co.nz (8.11.6/8.11.6) with ESMTP id h390im634386; Wed, 9 Apr 2003 12:44:48 +1200 (NZST) (envelope-from wood@storm.niwa.co.nz) Date: Wed, 9 Apr 2003 12:44:48 +1200 (NZST) From: Brent Wood To: pgsql-general@postgresql.org Cc: Denis Subject: Re: Yet Another (Simple) Case of Index not used In-Reply-To: <20030408234623.GD15928@svana.org> Message-ID: <20030409123856.Q34167-100000@storm.niwa.co.nz> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/591 X-Sequence-Number: 40656 On Wed, 9 Apr 2003, Martijn van Oosterhout wrote: > On Tue, Apr 08, 2003 at 12:57:16PM -0700, Denis wrote: > > The query I am trying to do (fast) is: > > > > select count(*) from addresses; > > > > This takes more than a second to complete, because, as the 'explain' command > > shows me, > > the index created on 'addresses' is not used, and a seq scan is being used. > > One would assume that the creation of an index would allow the counting of > > the number of entries in a table to be instantanous? > > Incorrect assumption. select count(*) can produce different results in > different backends depending on the current state of the active > transactions. Some thoughts: Select count(*) is often applied to views, and may take some time depending on the underlying query. However, for a single table, I would have thought that if there are no write locks or open transactions for the table, the index would return a faster result than a scan? Is there room for some optimisation here? Does count() work faster, poss using the unique index on the key (for non-composite keys)? Cheers Brent Wood From pgsql-performance-owner@postgresql.org Tue Apr 8 22:00:10 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9CC41475F3D for ; Tue, 8 Apr 2003 22:00:06 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 0B50B474E42 for ; Tue, 8 Apr 2003 21:59:34 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id ED552D60B; Tue, 8 Apr 2003 18:59:37 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id E30EE5C0B; Tue, 8 Apr 2003 18:59:37 -0700 (PDT) Date: Tue, 8 Apr 2003 18:59:37 -0700 (PDT) From: Stephan Szabo To: "Denis @ Next2Me" Cc: , Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-Reply-To: Message-ID: <20030408185412.C57783-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/80 X-Sequence-Number: 1586 On Tue, 8 Apr 2003, Denis @ Next2Me wrote: > The kind of requests that I am really interested in are: > select count(*) from table where table.column like 'pattern%' If you think an index scan should be faster, you can try set enable_seqscan=off; and see if that changes the plan generated by explain and with analyze you can compare the time used. Without information on the estimated selectivity it's hard to say what's right. If it doesn't use the index (ie, it's still using a sequential scan) after the enable_seqscan=off it's likely that you didn't initdb in "C" locale in which case like won't use indexes currently (you can see the archives for long description, but the short one is that some of the locale rules can cause problems with using the index). From pgsql-performance-owner@postgresql.org Tue Apr 8 22:35:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 727F84760CC for ; Tue, 8 Apr 2003 22:35:31 -0400 (EDT) Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 8671B475E77 for ; Tue, 8 Apr 2003 22:35:27 -0400 (EDT) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6p2/8.11.6) id h392ZVK50833 for pgsql-performance@postgresql.org; Wed, 9 Apr 2003 10:35:31 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6p2/8.9.3) with SMTP id h392ZCx50663; Wed, 9 Apr 2003 10:35:12 +0800 (WST) Message-ID: <077201c2fe40$ab420d70$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: , , References: Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Wed, 9 Apr 2003 10:35:22 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: base64 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-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Spam-Status: No, hits=-11.1 required=5.0 tests=BASE64_ENC_TEXT,BAYES_20,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/81 X-Sequence-Number: 1587 SGkgRGVuaXMsDQoNCj4gVGhlIGtpbmQgb2YgcmVxdWVzdHMgdGhhdCBJIGFt IHJlYWxseSBpbnRlcmVzdGVkIGluIGFyZToNCj4gc2VsZWN0IGNvdW50KCop IGZyb20gdGFibGUgd2hlcmUgdGFibGUuY29sdW1uIGxpa2UgJ3BhdHRlcm4l Jw0KPiBUaGVzZSBzZWVtcyB0byBnbyBtdWNoIG1hc3RlciBvbiBteXNxbCAo d2hpY2ggSSBndWVzcyBpdCBub3QgYSBNVkNDIGRhdGFiYXNlPyBvciB3YXNu J3QgDQo+IHRoZSBJbm5vYmFzZSBzdXBwb3NlZCB0byBtYWtlIGl0IHNvPyks IHRoYW4gb24gcG9zdGdyZXNxbC4NCg0KQSBmZXcgdGhpbmdzLg0KDQoqIE1W Q0MgaW4gUG9zdGdyZVNRTCBhbGxvd3MgdXMgdG8gYmUgd2F5IGZhc3RlciB0 aGFuIE15U1FMIHdoZW4geW91IGhhdmUgaGVhcHMgb2YgY29uY3VycmVudCBy ZWFkZXJzIGFuZCB3cml0ZXJzLiAgVGhlIHRyYWRlb2ZmIGlzIHRoYXQgY291 bnQoKikgaXMgc2xvdyBzaW5jZSBQb3N0Z3JlU1FMIG5lZWRzIHRvIGNoZWNr IHRoYXQgZWFjaCB0dXBsZSBpcyBhY3R1YWxseSB2aXNpYmxlIHRvIHlvdXIg cXVlcnkgKGVnLiB5b3Ugc3RhcnQgYSB0cmFuc2FjdGlvbiwgc29tb25lIGVs c2UgaW5zZXJ0cyBhIHJvdywgeW91IGRvIGEgY291bnQoKikgLSBzaG91bGQg dGhlIHJlc3VsdCBpbmNsdWRlIHRoYXQgbmV3IHJvdyBvciBub3Q/ICBBbnN3 ZXI6IG5vLikNCg0KKiBKdXN0IGF2b2lkIGRvaW5nIGNvdW50KCopIG92ZXIg dGhlIGVudGlyZSB0YWJsZSB3aXRoIG5vIHdoZXJlIGNsYXVzZSEhISBJdCdz IGFzIGVhc3kgYXMgdGhhdA0KDQoqIFRoZSBMSUtFICdwYXR0ZXJuJScgaXMg aW5kZXhhYmxlIGluIFBvc3RncmVzcWwuICBZb3Ugd2lsbCBuZWVkIHRvIGNy ZWF0ZSBhIG5vcm1hbCBidHJlZSBpbmRleCBvdmVyIHRhYmxlLmNvbHVtbi4g IFNvIGxvbmcgYXMgdGhlIGluZGV4IGlzIHJldHVybmluZyBhIHNtYWxsIHBv cnRpb24gb2YgdGhlIHRhYmxlIChlZy4gc2F5IG9ubHkgNS0xMCUgb2YgdGhl IGZpZWxkcyBiZWdpbiB3aXRoIHBhdHRlcm4pLCB0aGVuIHRoZSBpbmRleCB3 aWxsIGJlIHVzZWQgYW5kIGl0IHdpbGwgYmUgZmFzdC4NCg0KKiBJZiB5b3Ug d2FudCByZWFsbHkgZmFzdCBmdWxsIHRleHQgaW5kZXhpbmcsIGNoZWNrIG91 dCBjb250cmliL3RzZWFyY2ggLSBpdCdzIHJlYWxseSwgcmVhbGx5LCByZWFs bHkgZmFzdC4NCg0KQ2hyaXMNCg== From pgsql-performance-owner@postgresql.org Tue Apr 8 23:18:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2702C4758E6 for ; Tue, 8 Apr 2003 23:18:47 -0400 (EDT) Received: from svana.org (svana.org [203.20.62.76]) by postgresql.org (Postfix) with ESMTP id 05C06474E42 for ; Tue, 8 Apr 2003 23:18:46 -0400 (EDT) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 19366h-0006mT-00; Wed, 09 Apr 2003 13:18:39 +1000 Date: Wed, 9 Apr 2003 13:18:39 +1000 From: Martijn van Oosterhout To: "Denis @ Next2Me" Cc: pgsql-performance@postgresql.org Subject: Re: [GENERAL] Yet Another (Simple) Case of Index not used Message-ID: <20030409031839.GE15928@svana.org> Reply-To: Martijn van Oosterhout References: <20030408234623.GD15928@svana.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3XA6nns4nE4KvaS/" Content-Disposition: inline In-Reply-To: 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-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/82 X-Sequence-Number: 1588 --3XA6nns4nE4KvaS/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 08, 2003 at 05:10:01PM -0700, Denis @ Next2Me wrote: > Interesting generic response. In other words, "it all depends". > Well, a de facto observation is: "In my case, it's always much slower wit= h, say, mysql". Curious, is mysql still so fast when you have transactions enabled? How does it deal with the following: begin; delete from bigtable; select count(*) from bigtable; -- Should return 0 abort; select count(*) from bigtable; -- Should give original size > Understand me, I don't mean to be starting a performance comparaison mysql > vs postgresql, which is probably an old subject, I am just looking for a > solution to solve this type of performance issues, ie the generic cases: > select count(*) from addresses where address is like 'pattern%'; > Which are very fast on mysql, and very slow on postgresql. Ah, but that may be caused by something else altogether. LIKE is only indexable in the C locale so if you have en_US as your locale, your LIKE won't be indexable. See the discussion threads on this mailing list in the = past. > Understood, it will always depend on some parameters, but the real > question is: how much control does one have over those parameters, and how > does one tweak them to reach optimal performance? Hmm, it depends. One person put it that mysql goes for performance first, then correctness, whereas postgresql goes for correctness first, then performance. Maybe fti (full text indexing) would work better? --=20 Martijn van Oosterhout http://svana.org/kleptog/ > "the West won the world not by the superiority of its ideas or values or > religion but rather by its superiority in applying organized violence. > Westerners often forget this fact, non-Westerners never do." > - Samuel P. Huntington --3XA6nns4nE4KvaS/ 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+k5EPY5Twig3Ge+YRAiovAKCHfX0JXOzbUVfEIrnixz+XwZ1wYQCfWW39 OTdtMALGGZa5+0KFOpRhFjA= =s8Ph -----END PGP SIGNATURE----- --3XA6nns4nE4KvaS/-- From pgsql-performance-owner@postgresql.org Tue Apr 8 23:38:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 614254758E6 for ; Tue, 8 Apr 2003 23:38:56 -0400 (EDT) Received: from ms-smtp-01.tampabay.rr.com (ms-smtp-01.tampabay.rr.com [65.32.1.43]) by postgresql.org (Postfix) with ESMTP id 9447E474E42 for ; Tue, 8 Apr 2003 23:38:55 -0400 (EDT) Received: from mattspc (169-52.34-65.tampabay.rr.com [65.34.52.169]) by ms-smtp-01.tampabay.rr.com (8.12.5/8.12.5) with ESMTP id h393coVn028692 for ; Tue, 8 Apr 2003 23:38:50 -0400 (EDT) From: "Matthew Nuzum" To: "Pgsql-Performance" Subject: choosing the right platform Date: Tue, 8 Apr 2003 23:38:44 -0400 Organization: Bearfruit.org Message-ID: <003101c2fe49$86a9fc30$6900a8c0@mattspc> 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 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-1.6 required=5.0 tests=BAYES_30 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/83 X-Sequence-Number: 1589 Hello all, I've been the lead developer of a successful (so-far) web application. Currently we run the database and the web application on the same server, but it will soon be necessary to split them and add some more web servers. I'm not counting on using replication any time soon, so I want to choose the hardware platform that will meet my needs for some time. Maybe you can give some suggestions... My application is written in PHP and relies on the apache web server. We use persistent db connections, so it appears (correct me if I'm wrong) that every apache child process gets one connection to the database. If my MaxClients is 150, each web server will be able to make up to 150 db connections. I'd like to play with that number a little bit once I get the webserver off of the db server. I feel that I could handle a greater number of Clients, so let us say that I have up to 200 connections per server. I'd like to have room to grow, so let's also say that I go to 20 web servers for a total of 4000 connections. (I'd probably like to go even higher, so consider this our starting point) With a couple dozen active accounts and a lot of test data, my current database is equiv to about 100 active accounts. Its current disk space consumption is: data # du --max-depth=3D2 3656 ./base/1 3656 ./base/16975 4292 ./base/95378 177824 ./base/200371 189432 ./base 144 ./global 82024 ./pg_xlog 2192 ./pg_clog 273836 . This is not optimized and there is a lot of old data, but to be safe, maybe we should assume that each account uses 4 MB of disk space in the db, counting indexes, tables and etc. I'd like to scale to 15,000 - 25,000 accounts, but I doubt that will be feasible at my budget level. (Also, there is a lot of optimizing to do, so it won't surprise me if this 4MB number is more like 2MB or even less) I'm not as concerned with disk subsystem or layout at the moment. I've seen a lot of good documentation (especially from Bruce Momjian, thanks!) on this subject. I'm mostly concerned with choosing the platform that's going to allow the scalability I need. Currently I'm most experienced in Linux, especially RedHat. I'm "certified" on SCO Openserver (5.x) and I've played with Irix, OSF/1 (I don't think it's called that anymore), Free BSD (3.x) and Solaris (2.x). I'm most comfortable with Linux, but I'm willing to use a different platform if it will be beneficial. I've heard that Solaris on the Sparc platform is capable of addressing larger amounts of RAM than Linux on Intel does. I don't know if that's true or if that has bearing, but I'd like to hear your opinions. My budget is going to be between (US) $5,000 and $10,000 and I'd like to stay under $7,000. I'm a major bargain hunter, so I shop e-bay a lot and here are some samplings that I think may be relevant for discussion: SUN (I'm not an expert in this, advice is requested) ---------------------------------------------------- SUN ENTERPRISE 4500 8x400 Mhz 4MB Cache CPUs 8GB RAM no hard drives ~$6,000 Sun E3500 - 8 x 336MHz 4MB Cache CPUs 4GB RAM 8 x 9.1GB FC disks ~$600.00 Any other suggestions? INTEL (I'm much more familiar with this area) ---------------------------------------------------- Compaq DL580 4x700 MHz 2MB Cache CPUs 4GB RAM (16GB Max) HW Raid w/ 64MB Cache ~$6000 IBM Netfinity 7100 4x500 MHz 1MB Cache CPUs up to (16GB Max) HW Raid Dell PowerEdge 8450 8x550 2M Cache CPUS 4GB (32GB Max) HS RAID w/ 16MB Cache ~$4,500 Any other suggestions? Any other hardware platforms I should consider? Finally, and I know this sounds silly, but I don't have my own data center, so size is something I need to take into consideration. I pay for data center space by the physical size of my servers. My priorities are Performance, Reasonable amount of scalability (as outlined above) and finally physical size. Thanks for taking the time to read this and for any assistance you can give, Matthew Nuzum www.bearfruit.org From pgsql-performance-owner@postgresql.org Wed Apr 9 01:57:02 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2EE074758E6 for ; Wed, 9 Apr 2003 01:57:01 -0400 (EDT) Received: from localhost.localdomain (adsl-216-103-208-155.dsl.snfc21.pacbell.net [216.103.208.155]) by postgresql.org (Postfix) with ESMTP id 569A4474E42 for ; Wed, 9 Apr 2003 01:57:00 -0400 (EDT) Received: from flipper5 (flipper5.next2me.com [192.168.0.3]) by localhost.localdomain (8.12.8/8.12.8) with SMTP id h395wMgL002290; Tue, 8 Apr 2003 22:58:22 -0700 Reply-To: From: "Denis @ Next2Me" To: "Martijn van Oosterhout" , "Stephan Szabo" , "Denis @ Next2Me" Cc: Subject: Re: [GENERAL] Yet Another (Simple) Case of Index not used Date: Tue, 8 Apr 2003 22:54:46 -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) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <20030409031839.GE15928@svana.org> X-Spam-Status: No, hits=-14.7 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/84 X-Sequence-Number: 1590 Stephan, Martijn, good call, that was it: the C locale. I had used all the default settings when installing/creating the database, and apparently it used my default locale (en_US). I recreated (initdb) the database with --no-locale, and recreated the database, and sure enough, the query: select count(*) from table where table.column like 'fol%' was a zillion (well almost) time faster than it used to be, and on pair with mysql's performance. And as expected, the EXPLAIN on that query does show indeed the use of the index I had created on the table. Sweet, I can now nuke mysql out of my system. Folks, thank you all for the help and other suggestions. Denis Amselem Next2Me Inc. Stephan said: > If it doesn't use the index (ie, it's still using a sequential scan) > after the enable_seqscan=off it's likely that you didn't initdb in "C" > locale in which case like won't use indexes currently (you can see the > archives for long description, but the short one is that some of the > locale rules can cause problems with using the index). Martijn said: > Ah, but that may be caused by something else altogether. LIKE is only > indexable in the C locale so if you have en_US as your locale, your LIKE > won't be indexable. See the discussion threads on this mailing list in the past. > > From pgsql-performance-owner@postgresql.org Wed Apr 9 11:43:17 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BE4384762F6 for ; Wed, 9 Apr 2003 11:43:13 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 93D904762D7 for ; Wed, 9 Apr 2003 11:43:09 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h39Fga208429 for ; Wed, 9 Apr 2003 21:12:36 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h39Fgaa08424 for ; Wed, 9 Apr 2003 21:12:36 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: [OT][Announce] Availability of OAS Server pakcages Date: Wed, 9 Apr 2003 21:12:56 +0530 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304092112.56916.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/85 X-Sequence-Number: 1591 Hello all, This is to announce couple of things regarding OAS Server. 1. Mailing list for OAS Server is up now. It is available at https://lists.sourceforge.net/lists/listinfo/oasserver-general. So I wouldn't be bothering you guys next time like this..:-) 2. First packaging release of OAS Server is made available. So in case, you do not want to use CVS, try the source tarballs. The project website is http://oasserver.sourceforge.net Regards Shridhar From pgsql-performance-owner@postgresql.org Wed Apr 9 12:11:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 908BE475FEE for ; Wed, 9 Apr 2003 12:11:07 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 9CA29475ECE for ; Wed, 9 Apr 2003 12:10:57 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2952996; Wed, 09 Apr 2003 09:10:56 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: ext3 filesystem / linux 7.3 Date: Wed, 9 Apr 2003 09:10:29 -0700 User-Agent: KMail/1.4.3 References: <231C6A82-65C3-11D7-8D88-0003939CC61E@trilug.org> <200304030943.06406.josh@agliodbs.com> <20030408232247.GH1847@filer> In-Reply-To: <20030408232247.GH1847@filer> MIME-Version: 1.0 Message-Id: <200304090910.29057.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/86 X-Sequence-Number: 1592 Kevin, > So perhaps the first step in this is to write something that will show > what the distribution pattern for data in a table is? With that > information, we *could* randomly generate data that would conform to > the statistical patterns seen in the real world. Sure. But I think it'll be *much* easier just to use portions of the FCC= =20 database. You want to start working on converting it to PostgreSQL? --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 12:19:17 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34D7B475A8D for ; Wed, 9 Apr 2003 12:19:14 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 6C186475458 for ; Wed, 9 Apr 2003 12:19:13 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2953011; Wed, 09 Apr 2003 09:19:13 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: , Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Wed, 9 Apr 2003 09:18:45 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200304090918.45275.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/87 X-Sequence-Number: 1593 Denis, > Are you saying the 7.4 'group by' trick would be faster than the simple > select count(*)? That seems hard to believe, being that the request now h= as > to fetch / sort the data. I must be missing something. No, I'm saying that the 7.4 hash-aggregate is faster than the same query wa= s=20 under 7.2 or 7.3. Much faster. But it does little to speed up a raw=20 count(*). > The kind of requests that I am really interested in are: > select count(*) from table where table.column like 'pattern%' Hash-aggregates may, in fact, help with this. Care to try downloading the= =20 the source from CVS? > These seems to go much master on mysql (which I guess it not a MVCC > database? or wasn't the Innobase supposed to make it so?), They did incorporate a lot of MVCC logic into InnoDB tables, yes. Which me= ans=20 that if SELECT count(*) on an InnoDB table is just as fast as a MyISAM tabl= e,=20 then it is not accurate. This would be in keeping with MySQL's design=20 philosophy, which values performance and simplicity over accuracy and=20 precision -- the opposite of our philosophy. > So, in the meantime, I've decided to split up my data into two sets, > the static big tables which are handled by mysql, and the rest of it > handled by postgresql.... Hey, if it works for you, it's probably easier than dealing with the=20 PostgreSQL workarounds to this performance issue. I'll ask you to give=20 PostgreSQL a try for those tables again when 7.4 comes out. > ps: apologies for the cross-posting. De nada. The Performance list is the right place for this sort of questio= n=20 in the future. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 12:28:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF124476353 for ; Wed, 9 Apr 2003 12:28:30 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2119F47634E for ; Wed, 9 Apr 2003 12:28:30 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2953027; Wed, 09 Apr 2003 09:28:29 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Matthew Nuzum" , "Pgsql-Performance" Subject: Re: choosing the right platform Date: Wed, 9 Apr 2003 09:28:01 -0700 User-Agent: KMail/1.4.3 References: <003101c2fe49$86a9fc30$6900a8c0@mattspc> In-Reply-To: <003101c2fe49$86a9fc30$6900a8c0@mattspc> MIME-Version: 1.0 Message-Id: <200304090928.01767.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/88 X-Sequence-Number: 1594 Matthew, > Currently I'm most experienced in Linux, especially RedHat. I'm > "certified" on SCO Openserver (5.x) and I've played with Irix, OSF/1 (I > don't think it's called that anymore), Free BSD (3.x) and Solaris (2.x).= =20 > I'm most > comfortable with Linux, but I'm willing to use a different platform if it > will be beneficial. I've heard that Solaris on the Sparc platform is > capable of addressing larger amounts of RAM than Linux on Intel does. I > don't know if that's true or if that has bearing, but I'd like to hear yo= ur > opinions. Please browse through the list archives. We have numerous posts on the=20 platform subject. In fact, several of us are trying to put together a=20 PostgreSQL performance test package to answer this question difinitively=20 rather than anecdotally. Anecdotal responses are: Solaris is *bad* for PostgreSQL, due to a high per-process overhead.=20=20 Universal opinion on this list has been that Solaris is optimized for=20 multi-threaded applications, not multi-process applications, and postgres i= s=20 the latter. *BSD has a *lot* of fans on the PGSQL lists, many of whom claim significant= ly=20 better performance than Linux, mostly due to better filesystem I/O. Linux is used heavily by a lot of PostgreSQL users. I have yet to see anyo= ne=20 provide actual Linux vs. BSD statistics, though ... something we hope to do. Nobody has come forward and reported on PostgreSQL on SCO Unix. Irix is widely regarded as a "dead" platform, though PostgreSQL does run on= it=20 ... Good luck, and keep watching this space! --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 12:57:11 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D3E26476302 for ; Wed, 9 Apr 2003 12:57:08 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id A6628476262 for ; Wed, 9 Apr 2003 12:57:07 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h39GtVYQ025856; Wed, 9 Apr 2003 10:55:31 -0600 (MDT) Date: Wed, 9 Apr 2003 10:51:34 -0600 (MDT) From: "scott.marlowe" To: Matthew Nuzum Cc: Pgsql-Performance Subject: Re: choosing the right platform In-Reply-To: <003101c2fe49$86a9fc30$6900a8c0@mattspc> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-28.2 required=5.0 tests=BAYES_20,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/89 X-Sequence-Number: 1595 I would say up front that both Linux and BSD are probably your two best choices. If you're familiar with one more than the other, that familiarity may be more important than the underlying differences in the two OSes, as they are both good platforms to run postgresql on top of. Secondly, look carefully at using persistant connections in large numbers. While persistant connections DO represent a big savings in connect time, the savings are lost in the noise of many PHP applications. i.e. my dual PIII swiss army knife server can initiate single persistant connections at 1,000,000 a second (reusing the old ones of course). non-persistant connects happen at 1,000 times a second. Most of my scripts run in 1/10th of a second or so, so the 1/1000th used to connect is noise to me. If you are going to use persistant connections, it might work better to let apache have only 20 or 40 children, which will force the apache children to "round robin" serve the requests coming in. This will usually work fine, since keeping the number of apache children down keeps the number of postgresql backends down, which keeps the system faster in terms of response time. Turn keep alive down to something short like 10 seconds, or just turn it off, as keep alive doesn't really save all that much time in apache. Note that machine testing with 100 simo connections doesn't translate directly to 100 users. Generally, x simos usually represents about 10 to 20 x users, since users don't click buttons all that fast. so an apache configured by 40 max children should handle 100 to 200 users with no problem. On Tue, 8 Apr 2003, Matthew Nuzum wrote: > Hello all, > > I've been the lead developer of a successful (so-far) web application. > Currently we run the database and the web application on the same server, > but it will soon be necessary to split them and add some more web servers. > > I'm not counting on using replication any time soon, so I want to choose the > hardware platform that will meet my needs for some time. Maybe you can give > some suggestions... > > My application is written in PHP and relies on the apache web server. We > use persistent db connections, so it appears (correct me if I'm wrong) that > every apache child process gets one connection to the database. If my > MaxClients is 150, each web server will be able to make up to 150 db > connections. I'd like to play with that number a little bit once I get the > webserver off of the db server. I feel that I could handle a greater number > of Clients, so let us say that I have up to 200 connections per server. > > I'd like to have room to grow, so let's also say that I go to 20 web servers > for a total of 4000 connections. (I'd probably like to go even higher, so > consider this our starting point) > > With a couple dozen active accounts and a lot of test data, my current > database is equiv to about 100 active accounts. Its current disk space > consumption is: > data # du --max-depth=2 > 3656 ./base/1 > 3656 ./base/16975 > 4292 ./base/95378 > 177824 ./base/200371 > 189432 ./base > 144 ./global > 82024 ./pg_xlog > 2192 ./pg_clog > 273836 . > > This is not optimized and there is a lot of old data, but to be safe, maybe > we should assume that each account uses 4 MB of disk space in the db, > counting indexes, tables and etc. I'd like to scale to 15,000 - 25,000 > accounts, but I doubt that will be feasible at my budget level. (Also, > there is a lot of optimizing to do, so it won't surprise me if this 4MB > number is more like 2MB or even less) > > I'm not as concerned with disk subsystem or layout at the moment. I've seen > a lot of good documentation (especially from Bruce Momjian, thanks!) on this > subject. I'm mostly concerned with choosing the platform that's going to > allow the scalability I need. > > Currently I'm most experienced in Linux, especially RedHat. I'm "certified" > on SCO Openserver (5.x) and I've played with Irix, OSF/1 (I don't think it's > called that anymore), Free BSD (3.x) and Solaris (2.x). I'm most > comfortable with Linux, but I'm willing to use a different platform if it > will be beneficial. I've heard that Solaris on the Sparc platform is > capable of addressing larger amounts of RAM than Linux on Intel does. I > don't know if that's true or if that has bearing, but I'd like to hear your > opinions. > > My budget is going to be between (US) $5,000 and $10,000 and I'd like to > stay under $7,000. I'm a major bargain hunter, so I shop e-bay a lot and > here are some samplings that I think may be relevant for discussion: > > SUN (I'm not an expert in this, advice is requested) > ---------------------------------------------------- > SUN ENTERPRISE 4500 8x400 Mhz 4MB Cache CPUs 8GB RAM no hard drives ~$6,000 > Sun E3500 - 8 x 336MHz 4MB Cache CPUs 4GB RAM 8 x 9.1GB FC disks ~$600.00 > Any other suggestions? > > INTEL (I'm much more familiar with this area) > ---------------------------------------------------- > Compaq DL580 4x700 MHz 2MB Cache CPUs 4GB RAM (16GB Max) HW Raid w/ 64MB > Cache ~$6000 > IBM Netfinity 7100 4x500 MHz 1MB Cache CPUs up to (16GB Max) HW Raid > Dell PowerEdge 8450 8x550 2M Cache CPUS 4GB (32GB Max) HS RAID w/ 16MB Cache > ~$4,500 > Any other suggestions? > > Any other hardware platforms I should consider? > > Finally, and I know this sounds silly, but I don't have my own data center, > so size is something I need to take into consideration. I pay for data > center space by the physical size of my servers. My priorities are > Performance, Reasonable amount of scalability (as outlined above) and > finally physical size. > > Thanks for taking the time to read this and for any assistance you can give, > > Matthew Nuzum > www.bearfruit.org > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > From pgsql-performance-owner@postgresql.org Wed Apr 9 13:14:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 69E43476342 for ; Wed, 9 Apr 2003 13:13:57 -0400 (EDT) Received: from ms-smtp-03.tampabay.rr.com (ms-smtp-03.tampabay.rr.com [65.32.1.41]) by postgresql.org (Postfix) with ESMTP id 90C3C476340 for ; Wed, 9 Apr 2003 13:13:56 -0400 (EDT) Received: from mattspc (169-52.34-65.tampabay.rr.com [65.34.52.169]) by ms-smtp-03.tampabay.rr.com (8.12.5/8.12.5) with ESMTP id h39HDpbm010125; Wed, 9 Apr 2003 13:13:54 -0400 (EDT) From: "Matthew Nuzum" To: "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: choosing the right platform Date: Wed, 9 Apr 2003 13:13:46 -0400 Organization: Bearfruit.org Message-ID: <00a001c2febb$631141d0$6900a8c0@mattspc> 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 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 In-Reply-To: <200304090928.01767.josh@agliodbs.com> X-Spam-Status: No, hits=-9.5 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/90 X-Sequence-Number: 1596 > Anecdotal responses are: >=20 > Solaris is *bad* for PostgreSQL, due to a high per-process overhead. > Universal opinion on this list has been that Solaris is optimized for > multi-threaded applications, not multi-process applications, and postgres > is > the latter. >=20 > *BSD has a *lot* of fans on the PGSQL lists, many of whom claim > significantly > better performance than Linux, mostly due to better filesystem I/O. >=20 > Linux is used heavily by a lot of PostgreSQL users. I have yet to see > anyone > provide actual Linux vs. BSD statistics, though ... something we hope to > do. ... > -- > Josh Berkus > Aglio Database Solutions > San Francisco Thanks for the reply. Three things come to mind: About the list archives... I read through the entire archive at http://archives.postgresql.org/pgsql-performance/ and didn't see much talk on the subject. It only goes back 8 months though, so I don't know if there is another archive that is more comprehensive... Also, I'm glad to hear your comments about Solaris, I'm really most comfortable with Linux and I think I can pick up BSD pretty easily. About the Intel platform though, It's only been pretty recently (relatively speaking) that servers based on IA32 architecture have had support for greater than 2GB of RAM. I've heard talk about problems with applications that require more than 2GB. I do believe that my tables will become larger than this, and the way I understand it, sort mem works best when the tables can be loaded completely in RAM. I don't suspect that individual tables will be 2GB, but that the size of all tables combined will be. If there is a limitation on the largest chunk of RAM allocated to a program, will I have problems? Finally, can someone suggest a *BSD to evaluate? FreeBSD 4.8? 5.0? Is Apple a good choice? (I've heard it's based on BSD Unix) Thanks, -- Matthew Nuzum www.bearfruit.org cobalt@bearfruit.org =20 From pgsql-performance-owner@postgresql.org Wed Apr 9 13:20:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17ED9476340 for ; Wed, 9 Apr 2003 13:20:30 -0400 (EDT) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id DA03547633A for ; Wed, 9 Apr 2003 13:20:27 -0400 (EDT) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id 074D2581998; Wed, 9 Apr 2003 10:20:25 -0700 (PDT) X-Mailer: UserLand Frontier 9.1b2 (Macintosh OS) (mailServer v1.1..144) Mime-Version: 1.0 Message-Id: <67638702.1162238874@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <00a001c2febb$631141d0$6900a8c0@mattspc> Date: Wed, 09 Apr 2003 10:20:22 -0700 To: Matthew Nuzum , 'Josh Berkus' , 'Pgsql-Performance' From: eric soroos Subject: Re: choosing the right platform Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-6.3 required=5.0 tests=BAYES_20,IN_REP_TO autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/91 X-Sequence-Number: 1597 > Finally, can someone suggest a *BSD to evaluate? FreeBSD 4.8? 5.0? Is Apple > a good choice? (I've heard it's based on BSD Unix) I wouldn't recommend OSX for deployment if you're worried about performance. The hardware availiable and the settings to take advantage of it just aren't there yet, compared to the more established FreeBSD and Linux offerings. Development on a tibook is another matter, I'd recommend it to anyone with an attraction to shiny things that do real work. eric From pgsql-performance-owner@postgresql.org Wed Apr 9 14:01:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AC240474E44 for ; Wed, 9 Apr 2003 14:01:13 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 09D4A474E42 for ; Wed, 9 Apr 2003 14:01:11 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h39HxrYQ001563; Wed, 9 Apr 2003 11:59:53 -0600 (MDT) Date: Wed, 9 Apr 2003 11:55:56 -0600 (MDT) From: "scott.marlowe" To: Matthew Nuzum Cc: "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: choosing the right platform In-Reply-To: <00a001c2febb$631141d0$6900a8c0@mattspc> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/92 X-Sequence-Number: 1598 On Wed, 9 Apr 2003, Matthew Nuzum wrote: > I'm glad to hear your comments about Solaris, I'm really most comfortable > with Linux and I think I can pick up BSD pretty easily. > > About the Intel platform though, > > It's only been pretty recently (relatively speaking) that servers based on > IA32 architecture have had support for greater than 2GB of RAM. I've heard > talk about problems with applications that require more than 2GB. I do > believe that my tables will become larger than this, and the way I > understand it, sort mem works best when the tables can be loaded completely > in RAM. > > I don't suspect that individual tables will be 2GB, but that the size of all > tables combined will be. If there is a limitation on the largest chunk of > RAM allocated to a program, will I have problems? A couple more suggestions. One is to never allocate more than 50% of your memory to a database's shared buffers, i.e. let the OS buffer the disks en masse, while the database should have a smaller buffer for the most recent accesses. This is because kernel caching is usually faster and more efficient than the database doing it, and this becomes more an issue with large chunks of memory, which both Linux and BSD are quite good at caching, and postgresql, not so good. The other is to look at Linux or BSD on 64 bit hardware (Sparc, IBM Zseries mainframes, SGI Altix, etc...) where the one thing that's worth being on the bleeding edge for is databases and their memory hungry ways. :-) From pgsql-performance-owner@postgresql.org Wed Apr 9 14:04:00 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0B818474E44 for ; Wed, 9 Apr 2003 14:04:00 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 655DB474E42 for ; Wed, 9 Apr 2003 14:03:59 -0400 (EDT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2953260; Wed, 09 Apr 2003 11:03:53 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Matthew Nuzum" , "'Pgsql-Performance'" Subject: Re: choosing the right platform Date: Wed, 9 Apr 2003 11:03:48 -0700 User-Agent: KMail/1.4.3 References: <00a001c2febb$631141d0$6900a8c0@mattspc> In-Reply-To: <00a001c2febb$631141d0$6900a8c0@mattspc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304091103.48151.josh@agliodbs.com> X-Spam-Status: No, hits=-21.9 required=5.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/93 X-Sequence-Number: 1599 Matthew, > I read through the entire archive at > http://archives.postgresql.org/pgsql-performance/ and didn't see much talk > on the subject. It only goes back 8 months though, so I don't know if th= ere > is another archive that is more comprehensive... Really? There was a long-running Mac OS X vs. Solaris thread that touched = on=20 most major platforms, about 2-3 months ago. > I don't suspect that individual tables will be 2GB, but that the size of = all > tables combined will be. If there is a limitation on the largest chunk of > RAM allocated to a program, will I have problems? No. Since PostgreSQL is a multi-process architecture, not a multi-threaded= ,=20 you only need enough RAM per process to load the current largest query. Plus, in my experience, Disk I/O issues are vastly more important than RAM = in=20 database performance. You're better off spending money on really fast dis= ks=20 in Linux RAID or really good hardware RAID 1+0 .... --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 19:45:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 034F5475458 for ; Wed, 9 Apr 2003 19:45:00 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 9D6DC474E42 for ; Wed, 9 Apr 2003 19:44:58 -0400 (EDT) Received: (qmail 57171 invoked by uid 1001); 9 Apr 2003 23:45:01 -0000 Date: Wed, 9 Apr 2003 18:45:01 -0500 From: "Jim C. Nasby" To: Matthew Nuzum Cc: 'Josh Berkus' , 'Pgsql-Performance' Subject: Re: choosing the right platform Message-ID: <20030409184501.V31861@flake.decibel.org> Reply-To: jim@nasby.net References: <200304090928.01767.josh@agliodbs.com> <00a001c2febb$631141d0$6900a8c0@mattspc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <00a001c2febb$631141d0$6900a8c0@mattspc>; from cobalt@bearfruit.org on Wed, Apr 09, 2003 at 01:13:46PM -0400 X-Operating-System: FreeBSD 4.7-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-35.4 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/94 X-Sequence-Number: 1600 On Wed, Apr 09, 2003 at 01:13:46PM -0400, Matthew Nuzum wrote: > Finally, can someone suggest a *BSD to evaluate? FreeBSD 4.8? 5.0? Is Apple > a good choice? (I've heard it's based on BSD Unix) FreeBSD has 3 different branches: -current: This is bleeding edge. Definitely need to be careful with this one, and it's not recommended for production. -stable: This is still a 'live' branch that any FBSD coder can (generally) commit to, but they are far more careful about breaking this branch. Not as stable as a release branch, but it's probably suitable for production so long as you're careful to test things. release branches: Every time an official release is done (ie: 4.8), a branch is created. The only code committed to these branches are security patches and fixes for very serious bugs. These branches are extremely stable. 5.0 is the first release after several years of development in -current. It incorporates some major changes designed to allow the kernel to run multi-threaded. However, unlike what usually happens, 5.0 is not considered to be -stable yet. First, this is still very new code; second, I believe there's some performance issues that are still being addressed. The intention is that 5.1 will be the first -stable release of the 5.x code. Because you're looking for something that's production ready, you probably want 4.8 (cvs tag RELENG_4_8). However, if you don't plan to hit production until late this year (when 5.1 should be out), you might want to try 5.0. Far more info is available at http://www.freebsd.org/releng/index.html BTW, I've heard of many, many companies moving their Oracle installs from Sun to RS/6000 because RS/6000's typically need 1/2 the processors that Sun does for a given load. If you're going to look at big-iron, RS/6000 is definitely worth a look if you see anything. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Apr 9 19:47:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B6C07475458 for ; Wed, 9 Apr 2003 19:47:46 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 83F9F474E42 for ; Wed, 9 Apr 2003 19:47:41 -0400 (EDT) Received: (qmail 57261 invoked by uid 1001); 9 Apr 2003 23:47:44 -0000 Date: Wed, 9 Apr 2003 18:47:44 -0500 From: "Jim C. Nasby" To: "scott.marlowe" Cc: Matthew Nuzum , 'Josh Berkus' , 'Pgsql-Performance' Subject: Re: choosing the right platform Message-ID: <20030409184744.W31861@flake.decibel.org> Reply-To: jim@nasby.net References: <00a001c2febb$631141d0$6900a8c0@mattspc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from scott.marlowe@ihs.com on Wed, Apr 09, 2003 at 11:55:56AM -0600 X-Operating-System: FreeBSD 4.7-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-39.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/95 X-Sequence-Number: 1601 On Wed, Apr 09, 2003 at 11:55:56AM -0600, scott.marlowe wrote: > A couple more suggestions. One is to never allocate more than 50% of your > memory to a database's shared buffers, i.e. let the OS buffer the disks en > masse, while the database should have a smaller buffer for the most recent > accesses. This is because kernel caching is usually faster and more > efficient than the database doing it, and this becomes more an issue with > large chunks of memory, which both Linux and BSD are quite good at > caching, and postgresql, not so good. That seems odd... shouldn't pgsql be able to cache information better since it would be cached in whatever format is best for it, rather than the raw page format (or maybe that is the best format). There's also the issue of having to go through more layers of software if you're relying on the OS caching. All the tuning info I've seen for every other database I've worked with specifically recommends giving the database as much memory as you possibly can, the theory being that it will do a much better job of caching than the OS will. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Apr 9 19:58:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9268C475458 for ; Wed, 9 Apr 2003 19:58:42 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 6D13D474E42 for ; Wed, 9 Apr 2003 19:58:40 -0400 (EDT) Received: (qmail 57465 invoked by uid 1001); 9 Apr 2003 23:58:43 -0000 Date: Wed, 9 Apr 2003 18:58:43 -0500 From: "Jim C. Nasby" To: "scott.marlowe" Cc: Matthew Nuzum , Pgsql-Performance Subject: Re: choosing the right platform Message-ID: <20030409185843.X31861@flake.decibel.org> Reply-To: jim@nasby.net References: <003101c2fe49$86a9fc30$6900a8c0@mattspc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from scott.marlowe@ihs.com on Wed, Apr 09, 2003 at 10:51:34AM -0600 X-Operating-System: FreeBSD 4.7-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/96 X-Sequence-Number: 1602 On Wed, Apr 09, 2003 at 10:51:34AM -0600, scott.marlowe wrote: > Secondly, look carefully at using persistant connections in large numbers. > > While persistant connections DO represent a big savings in connect time, > the savings are lost in the noise of many PHP applications. > > i.e. my dual PIII swiss army knife server can initiate single persistant > connections at 1,000,000 a second (reusing the old ones of course). > non-persistant connects happen at 1,000 times a second. Most of my > scripts run in 1/10th of a second or so, so the 1/1000th used to connect > is noise to me. My $0.02 from my experience with Sybase and DB2: It's not the connection *time* that's an issue, it's the amount of resources (mostly memory) used by each database connection. Each db2 connection to a database uses 4-8 meg of memory; on my pgsql system, each connection appears to be using about 4M. This is the resident set, which I believe indicates memory that basically can't be shared. All this memory is memory that can't be used for buffering/caching; on a system with a hundred connections, it can really start to add up. If your PHP is written in such a way that it does all the database work in one section of code, and only holds a connection to the database in that one section, then you can potentially have a lot of apache processes for each database connection. Of course, all this holds true wether you're using pooling or not. How much pooling will help depends on how expensive it is for the *database* to handle each new connection request, and how your code is written. Since it's often not possible to put all you database code in one place like I mentioned above, an alternative is to connect right before you do an operation, and disconnect as soon as you're done. This doesn't add much (if any) expense if you're using pooling, but it's a very different story if you're not using pooling. > If you are going to use persistant connections, it might work better to > let apache have only 20 or 40 children, which will force the apache > children to "round robin" serve the requests coming in. > > This will usually work fine, since keeping the number of apache children > down keeps the number of postgresql backends down, which keeps the system > faster in terms of response time. Turn keep alive down to something short > like 10 seconds, or just turn it off, as keep alive doesn't really save > all that much time in apache. Very important advice. Generally, once you push a database past a certain point, your performance degrades severely as the database thrashes about trying to answer all the pending queries. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Apr 9 20:15:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 98A8F475458 for ; Wed, 9 Apr 2003 20:15:42 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 2D6A7474E42 for ; Wed, 9 Apr 2003 20:15:41 -0400 (EDT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2954009 for pgsql-performance@postgresql.org; Wed, 09 Apr 2003 17:15:24 -0700 Content-Type: text/plain; charset="us-ascii" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Pgsql-Performance Subject: Help analyzing 7.2.4 EXPLAIN Date: Wed, 9 Apr 2003 17:15:19 -0700 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304091715.19565.josh@agliodbs.com> X-Spam-Status: No, hits=-12.2 required=5.0 tests=BAYES_10,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/97 X-Sequence-Number: 1603 Folks, What follows is a 7.2.4 EXPLAIN ANALYZE statement for the shown query. Thi= s=20 query is currently taking 570 msec, an OK amount of time until you realize= =20 that the system only has test data currently, and the tables in full=20 production will have 100-1000 times as much data. Becuase it's 7.2.4, it's a little hard to tell exactly which part of the= =20 query is taking up 90% of the processing time. The line which claims to = be=20 taking that time is: -> Seq Scan on users (cost=3D0.00..3595.33 rows=3D12 width=3D87) (actua= l=20 time=3D13.50..547.59 rows=3D41 loops=3D1) However, since users has only 200 records, I suspect that what's actually= =20 being represented here is the processing time for the PL/pgSQL procedure in= =20 the correlated subselect, if_addendee_conflict(). Questions:=20=20 1. Can anyone confirm my analysis in the paragraph above? 2. Can anyone point out any obvious ways to speed up the query below? 3. In the query below, if_attendee_conflict needs to be run once for each= =20 (attorney times events) on the same day. Further, if_attendee_conflict=20 involves a database lookup in 10-25% of cases. Given that=20 if_attendee_conflict needs to apply complex criteria to determine whether o= r=20 not there is a conflict, can anyone suggest possible ways to cut down on th= e=20 number of required loops? Thanks everyone! Query and analyze follows. j_test=3D> explain analyze SELECT users.user_id, (users.fname || COALESCE(' ' || users.minit, '') || '= '=20 || users.lname) as atty_name, users.lname, (SELECT if_addendee_conflict(users.user_id, 3272, '2003-04-15 10:00', '1= =20 days'::INTERVAL, events.event_id, events.event_date, events.duration, event_cats.status, = '30=20 minutes') as cflt FROM events, event_types, event_cats, event_days WHERE events.event_id =3D event_days.event_id and events.etype_id =3D event_types.etype_id AND event_types.ecat_id =3D event_cats.ecat_id AND event_days.event_day BETWEEN '2003-04-15' AND '2003-04-16 10:00'=20 ORDER BY cflt LIMIT 1) AS conflict FROM users=20 WHERE EXISTS (SELECT teams_users.user_id FROM teams_users JOIN teams_tree ON teams_users.team_id =3D teams_tree.team_id WHERE teams_tree.treeno BETWEEN 3 and 4 AND teams_users.user_id =3D users.user_id) AND users.status > 0 AND NOT EXISTS (SELECT staff_id FROM event_staff WHERE event_id =3D 3272 AND staff_id =3D users.user_id)=20 ORDER BY conflict, users.lname, atty_name; NOTICE: QUERY PLAN: Sort (cost=3D3595.55..3595.55 rows=3D12 width=3D87) (actual time=3D547.89.= .547.91=20 rows=3D41 loops=3D1) -> Seq Scan on users (cost=3D0.00..3595.33 rows=3D12 width=3D87) (actua= l=20 time=3D13.50..547.59 rows=3D41 loops=3D1) SubPlan -> Limit (cost=3D54.03..54.03 rows=3D1 width=3D46) (actual=20 time=3D13.14..13.14 rows=3D1 loops=3D41) -> Sort (cost=3D54.03..54.03 rows=3D1 width=3D46) (actual= =20 time=3D13.13..13.13 rows=3D2 loops=3D41) -> Hash Join (cost=3D52.77..54.02 rows=3D1 width=3D= 46)=20 (actual time=3D5.09..12.94 rows=3D95 loops=3D41) -> Seq Scan on event_cats (cost=3D0.00..1.16= =20 rows=3D16 width=3D6) (actual time=3D0.01..0.05 rows=3D16 loops=3D41) -> Hash (cost=3D52.77..52.77 rows=3D1 width= =3D40)=20 (actual time=3D4.72..4.72 rows=3D0 loops=3D41) -> Hash Join (cost=3D49.94..52.77 rows= =3D1=20 width=3D40) (actual time=3D4.19..4.59 rows=3D95 loops=3D41) -> Seq Scan on event_types=20=20 (cost=3D0.00..2.54 rows=3D54 width=3D8) (actual time=3D0.01..0.12 rows=3D54= loops=3D41) -> Hash (cost=3D49.93..49.93 rows= =3D5=20 width=3D32) (actual time=3D4.10..4.10 rows=3D0 loops=3D41) -> Nested Loop=20=20 (cost=3D0.00..49.93 rows=3D5 width=3D32) (actual time=3D0.16..3.95 rows=3D9= 5 loops=3D41) -> Seq Scan on event_d= ays=20=20 (cost=3D0.00..25.00 rows=3D5 width=3D4) (actual time=3D0.12..2.31 rows=3D95= loops=3D41) -> Index Scan using=20 events_pkey on events (cost=3D0.00..4.97 rows=3D1 width=3D28) (actual=20 time=3D0.01..0.01 rows=3D1 loops=3D3895) -> Nested Loop (cost=3D0.00..19.47 rows=3D1 width=3D12) (actual= =20 time=3D0.04..0.04 rows=3D0 loops=3D147) -> Index Scan using idx_teams_tree_node on teams_tree=20= =20 (cost=3D0.00..8.58 rows=3D2 width=3D4) (actual time=3D0.01..0.02 rows=3D2 l= oops=3D147) -> Index Scan using teams_users_pk on teams_users=20=20 (cost=3D0.00..4.83 rows=3D1 width=3D8) (actual time=3D0.01..0.01 rows=3D0 l= oops=3D252) -> Index Scan using event_staff_table_pk on event_staff=20=20 (cost=3D0.00..4.95 rows=3D1 width=3D4) (actual time=3D0.01..0.01 rows=3D0 l= oops=3D41) Total runtime: 548.20 msec --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 20:21:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7D0A9475458 for ; Wed, 9 Apr 2003 20:21:14 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6EF32474E42 for ; Wed, 9 Apr 2003 20:21:13 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3A0Kb2L011733; Wed, 9 Apr 2003 20:20:38 -0400 (EDT) To: jim@nasby.net Cc: "scott.marlowe" , Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Caching (was Re: choosing the right platform) In-reply-to: <20030409184744.W31861@flake.decibel.org> References: <00a001c2febb$631141d0$6900a8c0@mattspc> <20030409184744.W31861@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Wed, 09 Apr 2003 18:47:44 -0500" Date: Wed, 09 Apr 2003 20:20:37 -0400 Message-ID: <11732.1049934037@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/98 X-Sequence-Number: 1604 "Jim C. Nasby" writes: > That seems odd... shouldn't pgsql be able to cache information better > since it would be cached in whatever format is best for it, rather than > the raw page format (or maybe that is the best format). There's also the > issue of having to go through more layers of software if you're relying > on the OS caching. All the tuning info I've seen for every other > database I've worked with specifically recommends giving the database as > much memory as you possibly can, the theory being that it will do a much > better job of caching than the OS will. There are a number of reasons why that's a dubious policy for PG (I won't take a position on whether these apply to other databases...) One is that because we sit on top of the OS' filesystem, we can't (portably) prevent the OS from caching blocks. So it's quite easy to get into a situation where the same data is cached twice, once in PG buffers and once in kernel disk cache. That's clearly a waste of RAM however you slice it, and it's worst when you set the PG shared buffer size to be about half of available RAM. You can minimize the duplication by skewing the allocation one way or the other: either set PG's allocation relatively small, relying heavily on the OS to do the caching; or make PG's allocation most of RAM and hope to squeeze out the OS' cache. There are partisans for both approaches on this list. I lean towards the first policy because I think that starving the kernel for RAM is a bad idea. (Especially if you run on Linux, where this policy tempts the kernel to start kill -9'ing random processes ...) Another reason is that PG uses a simplistic fixed-number-of-buffers internal cache, and therefore it can't adapt on-the-fly to varying memory pressure, whereas the kernel can and will give up disk cache space to make room when it's needed for processes. Since PG isn't even aware of the total memory pressure on the system as a whole, it couldn't do as good a job of trading off cache vs process workspace as the kernel can do, even if we had a variable-size cache scheme. A third reason is that on many (most?) Unixen, SysV shared memory is subject to swapping, and the bigger you make the shared_buffer arena, the more likely it gets that some of the arena will be touched seldom enough to make it a candidate for swapping. A disk buffer that gets swapped to disk is worse than useless (if it's dirty, the swapping is downright counterproductive, since an extra read and write cycle will be needed before the data can make it to its rightful place). PG is *not* any smarter about the usage patterns of its disk buffers than the kernel is; it uses a simple LRU algorithm that is surely no brighter than what the kernel uses. (We have looked at smarter buffer recycling rules, but failed to see any performance improvement.) So the notion that PG can do a better job of cache management than the kernel is really illusory. About the only advantage you gain from having data directly in PG buffers rather than kernel buffers is saving the CPU effort needed to move data across the userspace boundary --- which is not zero, but it's sure a lot less than the time spent for actual I/O. So my take on it is that you want shared_buffers fairly small, and let the kernel do the bulk of the heavy lifting for disk cache. That's what it does for a living, so let it do what it does best. You only want shared_buffers big enough so you don't spend too many CPU cycles shoving data back and forth between PG buffers and kernel disk cache. The default shared_buffers setting of 64 is surely too small :-(, but my feeling is that values in the low thousands are enough to get past the knee of that curve in most cases. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 9 20:51:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C195475AE5 for ; Wed, 9 Apr 2003 20:51:27 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6DCB4475A8D for ; Wed, 9 Apr 2003 20:51:21 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3A0pN2L011861; Wed, 9 Apr 2003 20:51:23 -0400 (EDT) To: josh@agliodbs.com Cc: Pgsql-Performance Subject: Re: Help analyzing 7.2.4 EXPLAIN In-reply-to: <200304091715.19565.josh@agliodbs.com> References: <200304091715.19565.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Wed, 09 Apr 2003 17:15:19 -0700" Date: Wed, 09 Apr 2003 20:51:23 -0400 Message-ID: <11860.1049935883@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/99 X-Sequence-Number: 1605 Josh Berkus writes: > Becuase it's 7.2.4, it's a little hard to tell exactly which part of the > query is taking up 90% of the processing time. Keep in mind that in the subqueries, the "actual time" shown is the time per iteration --- you should multiply by the "loops" value to get an accurate idea of where the time is going. With that in mind, it's real clear that the first subplan is eating the bulk of the time. I think you are probably right that execution of the if_addendee_conflict() function is the main cost. But given this subquery that's not too surprising: > (SELECT if_addendee_conflict(users.user_id, 3272, '2003-04-15 10:00', '1 days'::INTERVAL, > events.event_id, events.event_date, events.duration, event_cats.status, '30 minutes') as cflt > FROM events, event_types, event_cats, event_days > WHERE events.event_id = event_days.event_id > and events.etype_id = event_types.etype_id > AND event_types.ecat_id = event_cats.ecat_id > AND event_days.event_day > BETWEEN '2003-04-15' AND '2003-04-16 10:00' > ORDER BY cflt LIMIT 1) AS conflict What you have here is a subquery that will execute if_addendee_conflict() for *each* row of the events table; then throw away all but one of the results. And then do that over again for each user row. It looks to me like if_addendee_conflict() is being called nearly 4000 times in this query. No wonder it's slow. The first thing that pops to mind is whether you really need the *first* conflict, or would it be enough to find any old conflict? If you could dispense with the ORDER BY then at least some evaluations of if_addendee_conflict() could be saved. Realistically, though, I think you're going to have to refactor the work to make this perform reasonably. How much of what if_addendee_conflict() does is actually dependent on the user_id? Could you separate out tests that depend only on the event, and do that in a separate pass that is done only once per event, instead once per event*user? If you could reduce the number of events that need to be examined for any given user, you could get somewhere. Also, I don't see where this query checks to see if the user is actually interested in attending the event. Is that one of the things if_addendee_conflict checks? If so, you should pull it out and make it a join condition. You're essentially forcing the stupidest possible join algorithm by burying that condition inside a user-defined function. It would win to check that sooner instead of later, since presumably the set of interesting events for any one user is a lot smaller than the set of all events. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 9 21:15:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 01C25476305 for ; Wed, 9 Apr 2003 21:15:36 -0400 (EDT) Received: from ms-smtp-03.tampabay.rr.com (ms-smtp-03.tampabay.rr.com [65.32.1.41]) by postgresql.org (Postfix) with ESMTP id 7FE97476302 for ; Wed, 9 Apr 2003 21:15:34 -0400 (EDT) Received: from mattspc (169-52.34-65.tampabay.rr.com [65.34.52.169]) by ms-smtp-03.tampabay.rr.com (8.12.5/8.12.5) with ESMTP id h3A1FBbm021581; Wed, 9 Apr 2003 21:15:11 -0400 (EDT) From: "Matthew Nuzum" To: "'Pgsql-Performance'" Cc: "'scott.marlowe'" , "'Matthew Nuzum'" , "'Josh Berkus'" , , "'Tom Lane'" Subject: Re: Caching (was Re: choosing the right platform) Date: Wed, 9 Apr 2003 21:15:05 -0400 Message-ID: <000501c2fefe$9f82c150$6900a8c0@mattspc> 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.1106 Importance: Normal In-Reply-To: <11732.1049934037@sss.pgh.pa.us> X-Spam-Status: No, hits=-13.0 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/100 X-Sequence-Number: 1606 Thanks for all the feedback, this is very informative. My current issues that I'm still not clear on, are: * Is the ia32 architecture going to impose uncomfortable limits on my application? I'm seeing lots of confirmation that this platform, regardless of the OS is going to limit me to less the 4GB of memory allocated to a single application (i.e. http://www.spack.org/index.cgi/LinuxRamLimits). This may or may not be an issue because: (note that these are questions, not statements) ** Postgres is multi-process, not multi-threaded (?) ** It's better to not use huge amount of sort-mem but instead let the OS do the caching (?) ** My needs are really not going to be as big as I think they are if I manage the application/environment correctly (?) Here are some of the performance suggestions I've heard, please, if I mis-understood, could you help me get clarity? * It's better to run fewer apache children and turn off persistent connections (I had suggested 200 children per server, someone else suggested 40) * FreeBSD is going to provide a better file system than Linux (because Linux only supports large files on journaling filesystems which impose extra over head) (this gleaned from this conversation and previous threads in archives) * Running Linux or *BSD on a 64 bit platform can alleviate some potential RAM limitations (if there are truly going to be limitations). If this is so, I've heard suggestions for Itanium, Sparc and RS/6000. Maybe someone can give some more info on these, here are my immediate thoughts: I've heard that the industry as a whole has not yet warmed up to Itanium. I can't afford the newest Sparc Servers, so I'd need to settle with a previous generation if I went that route, any problems with that? I know nothing about the RS/6000 servers (I did see one once though :-), does linux|*BSD run well on them and any suggestions for series/models I should look at? Finally, some specific questions, What's the max number of connections someone has seen on a database server? What type of hardware was it? How much RAM did postgres use? Thanks again, -- Matthew Nuzum www.bearfruit.org cobalt@bearfruit.org =20 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- > owner@postgresql.org] On Behalf Of Tom Lane > Sent: Wednesday, April 09, 2003 8:21 PM > To: jim@nasby.net > Cc: scott.marlowe; Matthew Nuzum; 'Josh Berkus'; 'Pgsql-Performance' > Subject: Caching (was Re: [PERFORM] choosing the right platform) >=20 > "Jim C. Nasby" writes: > > That seems odd... shouldn't pgsql be able to cache information better > > since it would be cached in whatever format is best for it, rather than > > the raw page format (or maybe that is the best format). There's also the > > issue of having to go through more layers of software if you're relying > > on the OS caching. All the tuning info I've seen for every other > > database I've worked with specifically recommends giving the database as > > much memory as you possibly can, the theory being that it will do a much > > better job of caching than the OS will. >=20 > There are a number of reasons why that's a dubious policy for PG (I > won't take a position on whether these apply to other databases...) >=20 > One is that because we sit on top of the OS' filesystem, we can't > (portably) prevent the OS from caching blocks. So it's quite easy to > get into a situation where the same data is cached twice, once in PG > buffers and once in kernel disk cache. That's clearly a waste of RAM > however you slice it, and it's worst when you set the PG shared buffer > size to be about half of available RAM. You can minimize the > duplication by skewing the allocation one way or the other: either set > PG's allocation relatively small, relying heavily on the OS to do the > caching; or make PG's allocation most of RAM and hope to squeeze out > the OS' cache. There are partisans for both approaches on this list. > I lean towards the first policy because I think that starving the kernel > for RAM is a bad idea. (Especially if you run on Linux, where this > policy tempts the kernel to start kill -9'ing random processes ...) >=20 > Another reason is that PG uses a simplistic fixed-number-of-buffers > internal cache, and therefore it can't adapt on-the-fly to varying > memory pressure, whereas the kernel can and will give up disk cache > space to make room when it's needed for processes. Since PG isn't > even aware of the total memory pressure on the system as a whole, > it couldn't do as good a job of trading off cache vs process workspace > as the kernel can do, even if we had a variable-size cache scheme. >=20 > A third reason is that on many (most?) Unixen, SysV shared memory is > subject to swapping, and the bigger you make the shared_buffer arena, > the more likely it gets that some of the arena will be touched seldom > enough to make it a candidate for swapping. A disk buffer that gets > swapped to disk is worse than useless (if it's dirty, the swapping > is downright counterproductive, since an extra read and write cycle > will be needed before the data can make it to its rightful place). >=20 > PG is *not* any smarter about the usage patterns of its disk buffers > than the kernel is; it uses a simple LRU algorithm that is surely no > brighter than what the kernel uses. (We have looked at smarter buffer > recycling rules, but failed to see any performance improvement.) So the > notion that PG can do a better job of cache management than the kernel > is really illusory. About the only advantage you gain from having data > directly in PG buffers rather than kernel buffers is saving the CPU > effort needed to move data across the userspace boundary --- which is > not zero, but it's sure a lot less than the time spent for actual I/O. >=20 > So my take on it is that you want shared_buffers fairly small, and let > the kernel do the bulk of the heavy lifting for disk cache. That's what > it does for a living, so let it do what it does best. You only want > shared_buffers big enough so you don't spend too many CPU cycles shoving > data back and forth between PG buffers and kernel disk cache. The > default shared_buffers setting of 64 is surely too small :-(, but my > feeling is that values in the low thousands are enough to get past the > knee of that curve in most cases. >=20 > regards, tom lane >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? >=20 > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Wed Apr 9 21:16:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B43AD474E42 for ; Wed, 9 Apr 2003 21:16:42 -0400 (EDT) Received: from ms-smtp-01.tampabay.rr.com (ms-smtp-01.tampabay.rr.com [65.32.1.43]) by postgresql.org (Postfix) with ESMTP id 15763475ECE for ; Wed, 9 Apr 2003 21:16:38 -0400 (EDT) Received: from mattspc (169-52.34-65.tampabay.rr.com [65.34.52.169]) by ms-smtp-01.tampabay.rr.com (8.12.5/8.12.5) with ESMTP id h3A1Gfn6021298 for ; Wed, 9 Apr 2003 21:16:41 -0400 (EDT) From: "Matthew Nuzum" To: "'Pgsql-Performance'" Subject: Caching (was Re: choosing the right platform) Date: Wed, 9 Apr 2003 21:16:36 -0400 Organization: Bearfruit.org Message-ID: <000601c2fefe$d4b07e80$6900a8c0@mattspc> 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.1106 Importance: Normal X-Spam-Status: No, hits=-9.8 required=5.0 tests=BAYES_01,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/101 X-Sequence-Number: 1607 Thanks for all the feedback, this is very informative. My current issues that I'm still not clear on, are: * Is the ia32 architecture going to impose uncomfortable limits on my application? I'm seeing lots of confirmation that this platform, regardless of the OS is going to limit me to less the 4GB of memory allocated to a single application (i.e. http://www.spack.org/index.cgi/LinuxRamLimits). This may or may not be an issue because: (note that these are questions, not statements) ** Postgres is multi-process, not multi-threaded (?) ** It's better to not use huge amount of sort-mem but instead let the OS do the caching (?) ** My needs are really not going to be as big as I think they are if I manage the application/environment correctly (?) Here are some of the performance suggestions I've heard, please, if I mis-understood, could you help me get clarity? * It's better to run fewer apache children and turn off persistent connections (I had suggested 200 children per server, someone else suggested 40) * FreeBSD is going to provide a better file system than Linux (because Linux only supports large files on journaling filesystems which impose extra over head) (this gleaned from this conversation and previous threads in archives) * Running Linux or *BSD on a 64 bit platform can alleviate some potential RAM limitations (if there are truly going to be limitations). If this is so, I've heard suggestions for Itanium, Sparc and RS/6000. Maybe someone can give some more info on these, here are my immediate thoughts: I've heard that the industry as a whole has not yet warmed up to Itanium. I can't afford the newest Sparc Servers, so I'd need to settle with a previous generation if I went that route, any problems with that? I know nothing about the RS/6000 servers (I did see one once though :-), does linux|*BSD run well on them and any suggestions for series/models I should look at? Finally, some specific questions, What's the max number of connections someone has seen on a database server? What type of hardware was it? How much RAM did postgres use? Thanks again, -- Matthew Nuzum www.bearfruit.org cobalt@bearfruit.org =20 > -----Original Message----- > From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance- > owner@postgresql.org] On Behalf Of Tom Lane > Sent: Wednesday, April 09, 2003 8:21 PM > To: jim@nasby.net > Cc: scott.marlowe; Matthew Nuzum; 'Josh Berkus'; 'Pgsql-Performance' > Subject: Caching (was Re: [PERFORM] choosing the right platform) >=20 > "Jim C. Nasby" writes: > > That seems odd... shouldn't pgsql be able to cache information better > > since it would be cached in whatever format is best for it, rather than > > the raw page format (or maybe that is the best format). There's also the > > issue of having to go through more layers of software if you're relying > > on the OS caching. All the tuning info I've seen for every other > > database I've worked with specifically recommends giving the database as > > much memory as you possibly can, the theory being that it will do a much > > better job of caching than the OS will. >=20 > There are a number of reasons why that's a dubious policy for PG (I > won't take a position on whether these apply to other databases...) >=20 > One is that because we sit on top of the OS' filesystem, we can't > (portably) prevent the OS from caching blocks. So it's quite easy to > get into a situation where the same data is cached twice, once in PG > buffers and once in kernel disk cache. That's clearly a waste of RAM > however you slice it, and it's worst when you set the PG shared buffer > size to be about half of available RAM. You can minimize the > duplication by skewing the allocation one way or the other: either set > PG's allocation relatively small, relying heavily on the OS to do the > caching; or make PG's allocation most of RAM and hope to squeeze out > the OS' cache. There are partisans for both approaches on this list. > I lean towards the first policy because I think that starving the kernel > for RAM is a bad idea. (Especially if you run on Linux, where this > policy tempts the kernel to start kill -9'ing random processes ...) >=20 > Another reason is that PG uses a simplistic fixed-number-of-buffers > internal cache, and therefore it can't adapt on-the-fly to varying > memory pressure, whereas the kernel can and will give up disk cache > space to make room when it's needed for processes. Since PG isn't > even aware of the total memory pressure on the system as a whole, > it couldn't do as good a job of trading off cache vs process workspace > as the kernel can do, even if we had a variable-size cache scheme. >=20 > A third reason is that on many (most?) Unixen, SysV shared memory is > subject to swapping, and the bigger you make the shared_buffer arena, > the more likely it gets that some of the arena will be touched seldom > enough to make it a candidate for swapping. A disk buffer that gets > swapped to disk is worse than useless (if it's dirty, the swapping > is downright counterproductive, since an extra read and write cycle > will be needed before the data can make it to its rightful place). >=20 > PG is *not* any smarter about the usage patterns of its disk buffers > than the kernel is; it uses a simple LRU algorithm that is surely no > brighter than what the kernel uses. (We have looked at smarter buffer > recycling rules, but failed to see any performance improvement.) So the > notion that PG can do a better job of cache management than the kernel > is really illusory. About the only advantage you gain from having data > directly in PG buffers rather than kernel buffers is saving the CPU > effort needed to move data across the userspace boundary --- which is > not zero, but it's sure a lot less than the time spent for actual I/O. >=20 > So my take on it is that you want shared_buffers fairly small, and let > the kernel do the bulk of the heavy lifting for disk cache. That's what > it does for a living, so let it do what it does best. You only want > shared_buffers big enough so you don't spend too many CPU cycles shoving > data back and forth between PG buffers and kernel disk cache. The > default shared_buffers setting of 64 is surely too small :-(, but my > feeling is that values in the low thousands are enough to get past the > knee of that curve in most cases. >=20 > regards, tom lane >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? >=20 > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Wed Apr 9 23:39:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D4E33475AE5 for ; Wed, 9 Apr 2003 23:39:33 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 01C73474E42 for ; Wed, 9 Apr 2003 23:39:32 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2954218; Wed, 09 Apr 2003 20:39:31 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Help analyzing 7.2.4 EXPLAIN Date: Wed, 9 Apr 2003 20:39:00 -0700 User-Agent: KMail/1.4.3 Cc: Pgsql-Performance References: <200304091715.19565.josh@agliodbs.com> <11860.1049935883@sss.pgh.pa.us> In-Reply-To: <11860.1049935883@sss.pgh.pa.us> MIME-Version: 1.0 Message-Id: <200304092039.00376.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.2 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,QUOTE_TWICE_1, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/102 X-Sequence-Number: 1608 Tom, > Keep in mind that in the subqueries, the "actual time" shown is the time > per iteration --- you should multiply by the "loops" value to get an > accurate idea of where the time is going. With that in mind, it's real > clear that the first subplan is eating the bulk of the time. Thanks, that's what I thought, but I wanted confirmation. > The first thing that pops to mind is whether you really need the *first* > conflict, or would it be enough to find any old conflict? If you could > dispense with the ORDER BY then at least some evaluations of > if_addendee_conflict() could be saved. The problem is that I need the lowest-sorted non-NULL conflict. The major= ity=20 (95%) of the runs of if_attendee_conflict will return NULL. But we can't= =20 know that until we run the test, which is a bit too complex for a case=20 statement. Now, if I could figure out a way to stop testing for a particular user the= =20 first time if_attendee_conflict returned a particular result, that could cu= t=20 the number of subquery loops by 1/3. Any ideas? > Realistically, though, I think you're going to have to refactor the work > to make this perform reasonably. How much of what > if_addendee_conflict() does is actually dependent on the user_id?=20=20 Almost all of it. The question being answered by the query is "Please give= me=20 the list of all users, plus which of them have a conflict for that particul= ar=20 date and time and what kind of conflict it is". >Could > you separate out tests that depend only on the event, and do that in a > separate pass that is done only once per event, instead once per > event*user? If you could reduce the number of events that need to be > examined for any given user, you could get somewhere. Regrettably, no. We have to run it for each user. I was acutally hoping = to=20 come up with a way of running for less events, acutally .... > > Also, I don't see where this query checks to see if the user is actually > interested in attending the event. Is that one of the things > if_addendee_conflict checks?=20 No. the users aren't given a choice about what they want to attend = --=20 the purpose of the query is to supply the calendar staff with a list of who= 's=20 available so the users can be assigned -- whether they want to or not. Well, we'll see if the current incarnation bogs down in a couple of months,= =20 and I'll rework the query if so. Thanks for the advice! --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 9 23:46:12 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7A8B0475CEE for ; Wed, 9 Apr 2003 23:46:06 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 0716D474E42 for ; Wed, 9 Apr 2003 23:46:02 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2954227; Wed, 09 Apr 2003 20:46:00 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Matthew Nuzum" , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) Date: Wed, 9 Apr 2003 20:45:29 -0700 User-Agent: KMail/1.4.3 References: <000601c2fefe$d4b07e80$6900a8c0@mattspc> In-Reply-To: <000601c2fefe$d4b07e80$6900a8c0@mattspc> MIME-Version: 1.0 Message-Id: <200304092045.29503.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/103 X-Sequence-Number: 1609 Matthew, > ** Postgres is multi-process, not multi-threaded (?) Correct. > ** It's better to not use huge amount of sort-mem but instead let the OS = do > the caching (?) That's "don't use a huge amount of *shared_buffers*". Sort_mem is a differ= ent=20 setting. However, I have never seen a database use more than 32mb sort mem= =20 in a single process, so I don't think the 2GB limit will hurt you much ... > ** My needs are really not going to be as big as I think they are if I > manage the application/environment correctly (?) Your needs *per process*. Also, PostgreSQL is not as much of a consumer o= f=20 RAM as it is a consumer of disk I/O. > * FreeBSD is going to provide a better file system than Linux (because > Linux only supports large files on journaling filesystems which impose > extra over head) (this gleaned from this conversation and previous threads > in archives)=20 No, the jury is still out on this one. ReiserFS is optimized for small=20 files, and I've done well with it although some posters report stability=20 problems, though all second-hand. We hope to test this sometime in the=20 upcoming months. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 10 04:18:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3BE3F47634D for ; Thu, 10 Apr 2003 04:18:12 -0400 (EDT) Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) by postgresql.org (Postfix) with ESMTP id 3ED5A47632D for ; Thu, 10 Apr 2003 04:18:07 -0400 (EDT) Received: from haggis ([68.11.66.83]) by lakemtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20030410081808.VXUN23518.lakemtao03.cox.net@haggis> for ; Thu, 10 Apr 2003 04:18:08 -0400 Subject: Re: Caching (was Re: choosing the right platform) From: Ron Johnson To: 'Pgsql-Performance' In-Reply-To: <000601c2fefe$d4b07e80$6900a8c0@mattspc> References: <000601c2fefe$d4b07e80$6900a8c0@mattspc> Content-Type: text/plain Organization: Message-Id: <1049962679.13873.107.camel@haggis> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.3 Date: 10 Apr 2003 03:17:59 -0500 Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-44.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_LONG_DENSE, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/104 X-Sequence-Number: 1610 On Wed, 2003-04-09 at 20:16, Matthew Nuzum wrote: > Thanks for all the feedback, this is very informative. [snip] > * Running Linux or *BSD on a 64 bit platform can alleviate some potential > RAM limitations (if there are truly going to be limitations). If this is > so, I've heard suggestions for Itanium, Sparc and RS/6000. Maybe someone > can give some more info on these, here are my immediate thoughts: I've heard > that the industry as a whole has not yet warmed up to Itanium. I can't > afford the newest Sparc Servers, so I'd need to settle with a previous > generation if I went that route, any problems with that? I know nothing > about the RS/6000 servers (I did see one once though :-), does linux|*BSD > run well on them and any suggestions for series/models I should look at? If you want 64-bit, maybe wait for Operon, or look at Alphas. You could probably get a used DS20 or ES40 for a pretty good price, and Linux is *well* supported on Alpha. If you want something that really smokes, and have some buck lying around, try an ES47. -- +----------------------------------------------------------------+ | Ron Johnson, Jr. mailto:ron.l.johnson@cox.net | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | "A C program is like a fast dance on a newly waxed dance floor | | by people carrying razors." | | Waldi Ravens | +----------------------------------------------------------------+ From pgsql-performance-owner@postgresql.org Thu Apr 10 05:34:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5B78E4763CE for ; Thu, 10 Apr 2003 05:34:40 -0400 (EDT) Received: from envy.ph.ed.ac.uk (envy.ph.ed.ac.uk [129.215.72.168]) by postgresql.org (Postfix) with ESMTP id 2E35B4763C3 for ; Thu, 10 Apr 2003 05:34:35 -0400 (EDT) Received: from jensen.ph.ed.ac.uk (jensen.ph.ed.ac.uk [129.215.73.47]) by envy.ph.ed.ac.uk (8.9.3p2/8.9.3) with ESMTP id KAA18948; Thu, 10 Apr 2003 10:34:36 +0100 (BST) Received: (from dmckain1@localhost) by jensen.ph.ed.ac.uk (8.11.6/8.11.6) id h3A9YZp15671; Thu, 10 Apr 2003 10:34:35 +0100 Date: Thu, 10 Apr 2003 10:34:35 +0100 From: David McKain To: Matthew Nuzum Cc: "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) Message-ID: <20030410103435.B16757@ph.ed.ac.uk> References: <000601c2fefe$d4b07e80$6900a8c0@mattspc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <000601c2fefe$d4b07e80$6900a8c0@mattspc>; from cobalt@bearfruit.org on Wed, Apr 09, 2003 at 09:16:36PM -0400 X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/105 X-Sequence-Number: 1611 On Wed, Apr 09, 2003 at 09:16:36PM -0400, Matthew Nuzum wrote: > Thanks for all the feedback, this is very informative. > > Here are some of the performance suggestions I've heard, please, if I > mis-understood, could you help me get clarity? > * It's better to run fewer apache children and turn off persistent > connections (I had suggested 200 children per server, someone else suggested > 40) Hi Matthew, I'm coming in a bit late and slightly OT here, but one common Apache solution you might want to look at is a "reverse proxy" configuration. This works very well if there's a good proportion of static vs dynamic content on your site - if your pages contain a lot of graphics then this may well be the case. To do this, you compile 2 Apache servers listening on different ports on the same machine (or you can have them on different machines too). Server 1 (we'll call the "front server") is just a vanilla Apache listening on Port 80, compiled with mod_rewrite and mod_proxy but nothing else. Server 2 ("back server" or "heavy server") has mod_php and anything else you need which is quite bulky (e.g. XML processing stuff, mod_perl ...) It can listen on Port 8080 or something. Your persistent DB connections come from Server 2. All web requests come in to Server 1 in the normal way and Server 1 deals with static content as before. By setting up Apache rewrite rules on Server 1, requests for *.php and other dynamic stuff can be forwarded to Server 2 for processing. Server 2 returns its response back through Server 1 and the end-user is oblivious to what's going on. (Server 2 and/or your firewall can be configured to allow connections only from Server 1 too.) It's a bit of effort to set up and does require a wee bit more maintenance than a single server but it comes with a few nice advantages: * You can have a lower MaxClients setting on server 2 and hence less persistent DB connections and less memory used by heavy Apache modules and PostgreSQL instances. * Server 1 is nice and light - no DB, low memory use (much of which is probably shared) - so you can set its MaxClients much higher. * The overall impact of each dynamic page is lower as all of the images and stylesheets it references can be quickly dealt with by Server 1, rather than wasting an unnecessary wodge of memory and persistent DB connection. I used this recently for transforming XML web pages into HTML using XSLT and mod_perl on a slightly old and underpowered Solaris server and it worked really well. Of course, YMMV! There are lots of tutorials on setting this up on the web - the mod_perl guide has some very handy stuff in it which ought to apply reasonably well to PHP too: http://perl.apache.org/docs/1.0/guide/scenario.html Hope that might help, David. From pgsql-performance-owner@postgresql.org Thu Apr 10 05:58:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 27DBE476398 for ; Thu, 10 Apr 2003 05:58:48 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 13B83476393 for ; Thu, 10 Apr 2003 05:58:46 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h3A9wlF06691 for ; Thu, 10 Apr 2003 15:28:47 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h3A9wla06685 for ; Thu, 10 Apr 2003 15:28:47 +0530 From: Shridhar Daithankar To: "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) Date: Thu, 10 Apr 2003 15:29:05 +0530 User-Agent: KMail/1.5 References: <000601c2fefe$d4b07e80$6900a8c0@mattspc> <20030410103435.B16757@ph.ed.ac.uk> In-Reply-To: <20030410103435.B16757@ph.ed.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304101529.05217.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/106 X-Sequence-Number: 1612 On Thursday 10 April 2003 15:04, you wrote: > On Wed, Apr 09, 2003 at 09:16:36PM -0400, Matthew Nuzum wrote: > > Thanks for all the feedback, this is very informative. > > > > Here are some of the performance suggestions I've heard, please, if I > > mis-understood, could you help me get clarity? > > * It's better to run fewer apache children and turn off persistent > > connections (I had suggested 200 children per server, someone else > > suggested 40) > > Hi Matthew, > > I'm coming in a bit late and slightly OT here, but one common Apache > solution you might want to look at is a "reverse proxy" configuration. > This works very well if there's a good proportion of static vs dynamic > content on your site - if your pages contain a lot of graphics then this > may well be the case. > > To do this, you compile 2 Apache servers listening on different ports on Umm.. AFAIK, if you use fastCGI, persistence of connection should be a lot better and or OAS Server, which gives you explicit control on how much resources to allocate. Shridhar From pgsql-performance-owner@postgresql.org Thu Apr 10 10:26:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1FFDF475F16 for ; Thu, 10 Apr 2003 10:26:42 -0400 (EDT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 9EB0D475CEE for ; Thu, 10 Apr 2003 10:26:34 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id KAA12467; Thu, 10 Apr 2003 10:26:12 -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 xma012460; Thu, 10 Apr 03 10:25:42 -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 KAA01073; Thu, 10 Apr 2003 10:20:26 -0400 Message-ID: <3E957F44.A1106F6A@nsd.ca> Date: Thu, 10 Apr 2003 10:27:16 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane Cc: jim@nasby.net, "scott.marlowe" , Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) References: <00a001c2febb$631141d0$6900a8c0@mattspc> <20030409184744.W31861@flake.decibel.org> <11732.1049934037@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-30.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/107 X-Sequence-Number: 1613 Tom, What appends when PG scans a table that is is too big to fit in the cache? Won't the whole cache get trashed and swapped off to disk? Shouldn't there be a way to lock some tables in PG cache? Who about caracterizing some of the RAM like: scan, index, small frequently used tables. JLL Tom Lane wrote: > [...] > PG is *not* any smarter about the usage patterns of its disk buffers > than the kernel is; it uses a simple LRU algorithm that is surely no > brighter than what the kernel uses. (We have looked at smarter buffer > recycling rules, but failed to see any performance improvement.) So the > notion that PG can do a better job of cache management than the kernel > is really illusory. About the only advantage you gain from having data > directly in PG buffers rather than kernel buffers is saving the CPU > effort needed to move data across the userspace boundary --- which is > not zero, but it's sure a lot less than the time spent for actual I/O. > > So my take on it is that you want shared_buffers fairly small, and let > the kernel do the bulk of the heavy lifting for disk cache. That's what > it does for a living, so let it do what it does best. You only want > shared_buffers big enough so you don't spend too many CPU cycles shoving > data back and forth between PG buffers and kernel disk cache. The > default shared_buffers setting of 64 is surely too small :-(, but my > feeling is that values in the low thousands are enough to get past the > knee of that curve in most cases. From pgsql-performance-owner@postgresql.org Thu Apr 10 10:40:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 06564474E42 for ; Thu, 10 Apr 2003 10:40:17 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id BF5BB4762A2 for ; Thu, 10 Apr 2003 10:40:15 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3AEeF2L004073; Thu, 10 Apr 2003 10:40:15 -0400 (EDT) To: Jean-Luc Lachance Cc: jim@nasby.net, "scott.marlowe" , Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) In-reply-to: <3E957F44.A1106F6A@nsd.ca> References: <00a001c2febb$631141d0$6900a8c0@mattspc> <20030409184744.W31861@flake.decibel.org> <11732.1049934037@sss.pgh.pa.us> <3E957F44.A1106F6A@nsd.ca> Comments: In-reply-to Jean-Luc Lachance message dated "Thu, 10 Apr 2003 10:27:16 -0400" Date: Thu, 10 Apr 2003 10:40:15 -0400 Message-ID: <4072.1049985615@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/108 X-Sequence-Number: 1614 Jean-Luc Lachance writes: > Shouldn't there be a way to lock some tables in PG cache? In my opinion, no. I do not think a manual locking feature could possibly be used effectively. It could very easily be abused to decrease net performance, though :-( It does seem that a smarter buffer management algorithm would be a good idea, but past experiments have failed to show any measurable benefit. Perhaps those experiments were testing the wrong conditions. I'd still be happy to see LRU(k) or some such method put in, if someone can prove that it actually does anything useful for us. (As best I recall, I only tested LRU-2 with pgbench. Perhaps Josh's benchmarking project will offer a wider variety of interesting scenarios.) regards, tom lane From pgsql-performance-owner@postgresql.org Thu Apr 10 12:49:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E203047592C for ; Thu, 10 Apr 2003 12:49:00 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id AD5BA474E42 for ; Thu, 10 Apr 2003 12:48:56 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3AGkdRF007995; Thu, 10 Apr 2003 10:46:39 -0600 (MDT) Date: Thu, 10 Apr 2003 10:42:35 -0600 (MDT) From: "scott.marlowe" To: "Jim C. Nasby" Cc: Matthew Nuzum , Pgsql-Performance Subject: Re: choosing the right platform In-Reply-To: <20030409185843.X31861@flake.decibel.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/109 X-Sequence-Number: 1615 On Wed, 9 Apr 2003, Jim C. Nasby wrote: > On Wed, Apr 09, 2003 at 10:51:34AM -0600, scott.marlowe wrote: > > Secondly, look carefully at using persistant connections in large numbers. > > > > While persistant connections DO represent a big savings in connect time, > > the savings are lost in the noise of many PHP applications. > > > > i.e. my dual PIII swiss army knife server can initiate single persistant > > connections at 1,000,000 a second (reusing the old ones of course). > > non-persistant connects happen at 1,000 times a second. Most of my > > scripts run in 1/10th of a second or so, so the 1/1000th used to connect > > is noise to me. > > My $0.02 from my experience with Sybase and DB2: > It's not the connection *time* that's an issue, it's the amount of > resources (mostly memory) used by each database connection. Each db2 > connection to a database uses 4-8 meg of memory; Agreed. > on my pgsql system, > each connection appears to be using about 4M. This is the resident set, > which I believe indicates memory that basically can't be shared. All > this memory is memory that can't be used for buffering/caching; on a > system with a hundred connections, it can really start to add up. If I run "select * from logs" from two different psql sessions on my backup box hitting my main box (psql would hold the result set and throw the results off if I ran it on the main box) I get this output from top: No (pgsql) load: 8:58am up 9 days, 22:43, 4 users, load average: 0.65, 0.54, 0.35 169 processes: 168 sleeping, 1 running, 0 zombie, 0 stopped CPU0 states: 0.1% user, 0.1% system, 0.0% nice, 99.1% idle CPU1 states: 32.1% user, 3.2% system, 0.0% nice, 64.0% idle Mem: 1543980K av, 1049864K used, 494116K free, 265928K shrd, 31404K buff Swap: 2048208K av, 0K used, 2048208K free 568600K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 10241 postgres 9 0 4216 4216 4136 S 0.0 0.2 0:05 postmaster 10242 postgres 9 0 4444 4444 4156 S 0.0 0.2 0:00 postmaster 10243 postgres 9 0 4812 4812 4148 S 0.0 0.3 0:00 postmaster 1 psql select *: 9:03am up 9 days, 22:48, 2 users, load average: 0.71, 0.71, 0.46 166 processes: 165 sleeping, 1 running, 0 zombie, 0 stopped CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle CPU1 states: 0.1% user, 2.0% system, 0.0% nice, 97.3% idle Mem: 1543980K av, 1052188K used, 491792K free, 265928K shrd, 32036K buff Swap: 2048208K av, 0K used, 2048208K free 570656K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 10241 postgres 10 0 4216 4216 4136 S 0.0 0.2 0:05 postmaster 10242 postgres 9 0 4448 4448 4156 S 0.0 0.2 0:00 postmaster 10243 postgres 9 0 4812 4812 4148 S 0.0 0.3 0:00 postmaster 18026 postgres 9 0 236M 236M 235M S 0.0 15.6 0:12 postmaster 18035 postgres 10 0 5832 5732 5096 S 0.0 0.3 0:00 postmaster 2 psql select *: 9:03am up 9 days, 22:49, 2 users, load average: 0.58, 0.66, 0.45 166 processes: 165 sleeping, 1 running, 0 zombie, 0 stopped CPU0 states: 0.0% user, 2.2% system, 0.0% nice, 97.2% idle CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle Mem: 1543980K av, 1053152K used, 490828K free, 265928K shrd, 32112K buff Swap: 2048208K av, 0K used, 2048208K free 570684K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 10241 postgres 8 0 4216 4216 4136 S 0.0 0.2 0:05 postmaster 10242 postgres 9 0 4448 4448 4156 S 0.0 0.2 0:00 postmaster 10243 postgres 9 0 4812 4812 4148 S 0.0 0.3 0:00 postmaster 18026 postgres 9 0 236M 236M 235M S 0.0 15.6 0:12 postmaster 18035 postgres 9 0 236M 236M 235M S 0.0 15.6 0:12 postmaster The difference between SIZE and SHARE is the delta, which is only something like 3 or 4 megs for the initial select * from logs, but the second one is only 1 meg. On average, the actual increase in memory usage for postgresql isn't that great, usually about 1 meg. Running out of memory isn't really a problem with connections<=200 and 1 gig of ram, as long as sort_mem isn't too high. I/O contention is the killer at that point, as is CPU load. From pgsql-performance-owner@postgresql.org Thu Apr 10 12:58:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 04643475CEE for ; Thu, 10 Apr 2003 12:58:03 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id DB99E475AE5 for ; Thu, 10 Apr 2003 12:58:01 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3AGtfRF008847; Thu, 10 Apr 2003 10:55:41 -0600 (MDT) Date: Thu, 10 Apr 2003 10:51:38 -0600 (MDT) From: "scott.marlowe" To: "Jim C. Nasby" Cc: Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: choosing the right platform In-Reply-To: <20030409184744.W31861@flake.decibel.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/110 X-Sequence-Number: 1616 On Wed, 9 Apr 2003, Jim C. Nasby wrote: > On Wed, Apr 09, 2003 at 11:55:56AM -0600, scott.marlowe wrote: > > A couple more suggestions. One is to never allocate more than 50% of your > > memory to a database's shared buffers, i.e. let the OS buffer the disks en > > masse, while the database should have a smaller buffer for the most recent > > accesses. This is because kernel caching is usually faster and more > > efficient than the database doing it, and this becomes more an issue with > > large chunks of memory, which both Linux and BSD are quite good at > > caching, and postgresql, not so good. > > That seems odd... shouldn't pgsql be able to cache information better > since it would be cached in whatever format is best for it, rather than > the raw page format (or maybe that is the best format). Yes and no. The problem isn't that the data is closer to postgresql in it's buffers versus further away in kernel buffers, it's that postgresql's caching algorhythm isn't performance tweaked for very large settings, it's performance tweaked to provide good performance on smaller machines, with say 4 or 16 Megs of shared buffers. Handling large buffers requires a different approach to handling small ones, and the kernel is optimized in that direction. Also, the kernel in most Oses, i.e. Linux and BSD tends to use "spare ram" with abandon as cache memory, so if you've got 4 gigs of ram, with 200 Megs set aside for postgresql, it's quite likely that the kernel cache can hold ALL your dataset for you once it's been read in once. So, the data is already cached once. Caching it again in Postgresql only gains a little, since the speed difference of postgresql shared buffer / cache and kernel caches is very small. However, the speed going to the hard drive is much slower. What you don't want is a postgresql cache that's bigger (on average) than the kernel cache, since the kernel cache will then be "thrashing" when you access information not currently in either cache. I.e. postgresql becomes your only cache, and kernel caching stops working for you and becomes just overhead, since you never get anything from it if it's too small to cache something long enough to be used again. > There's also the > issue of having to go through more layers of software if you're relying > on the OS caching. All the tuning info I've seen for every other > database I've worked with specifically recommends giving the database as > much memory as you possibly can, the theory being that it will do a much > better job of caching than the OS will. That's old school thinking. There was a day when kernel caching was much slower, and writing directly to your devices in a raw mode was the only way to ensure good performance. Nowadays, most modern Unix kernels and their file systems are a match for most database needs. heck, with some storage systems, the performance of the file system is just not really an issue, it's the bandwidth of the connector you use. Note that this is a good thing (TM) since it frees the postgresql development team to do other things than worry about caching 1 gig of data. From pgsql-performance-owner@postgresql.org Thu Apr 10 13:17:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 06FF4475EDF for ; Thu, 10 Apr 2003 13:17:50 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D8392475AE5 for ; Thu, 10 Apr 2003 13:17:48 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3AHHd2L005113; Thu, 10 Apr 2003 13:17:39 -0400 (EDT) To: "scott.marlowe" Cc: "Jim C. Nasby" , Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: choosing the right platform In-reply-to: References: Comments: In-reply-to "scott.marlowe" message dated "Thu, 10 Apr 2003 10:51:38 -0600" Date: Thu, 10 Apr 2003 13:17:39 -0400 Message-ID: <5112.1049995059@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/111 X-Sequence-Number: 1617 "scott.marlowe" writes: > Note that this is a good thing (TM) since it frees the postgresql > development team to do other things than worry about caching 1 gig of > data. Yeah. I think this is one very fundamental difference of design philosophy between Postgres and more-traditional databases such as Oracle. We prefer to let the kernel and filesystem do their jobs, and we assume they will do them well; whereas Oracle wants to bypass if not replace the kernel and filesystem. Partly this is a matter of the PG project not having the manpower to replace those layers. But I believe the world has changed in the last twenty years, and the Oracle approach is now obsolete: it's now costing them design and maintenance effort that isn't providing much return. Modern kernels and filesystems are *good*, and it's not easy to do better. We should focus our efforts on functionality that doesn't just duplicate what the OS can do. This design approach shows up in other areas too. For instance, in another thread I was just pointing out that there is no need for our frontend/backend protocol to solve communication problems like dropped or duplicated packets; TCP does that perfectly well already. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Apr 10 13:21:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3AEB8476331 for ; Thu, 10 Apr 2003 13:21:02 -0400 (EDT) Received: from mail.nbc.attcanada.ca (tor-vs3.nbc.netcom.ca [207.181.89.35]) by postgresql.org (Postfix) with ESMTP id 0467947632D for ; Thu, 10 Apr 2003 13:20:59 -0400 (EDT) Received: from localhost (firewall.procedium.com [216.13.191.82]) by mail.nbc.attcanada.ca (bela (1.1)/8.12.8) with ESMTP id h3AHKn0d017896 for ; Thu, 10 Apr 2003 13:20:58 -0400 (EDT) Date: Thu, 10 Apr 2003 10:20:49 -0700 From: Boris Popov X-Mailer: The Bat! (v1.62i) Business Reply-To: Boris Popov Organization: Procedium Software X-Priority: 3 (Normal) Message-ID: <564664787.20030410102049@procedium.com> To: pgsql-performance Subject: Reference data for performance testing? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-1.6 required=5.0 tests=BAYES_30 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/112 X-Sequence-Number: 1618 Hello, We're evaluating postgresql as a backend choice for our next generation software and would like to perform some rough measurements in-house. Where could I get my hands on some reference data, say few very large tables with a total size of over 1G that we could run. I noticed earlier discussion about Tiger data, but 30G is a bit too much for what we need. Any other ideas or suggestions? Thanks. -- -Boris From pgsql-performance-owner@postgresql.org Thu Apr 10 13:23:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B89A6475CEE for ; Thu, 10 Apr 2003 13:23:03 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id F3401475AE5 for ; Thu, 10 Apr 2003 13:23:02 -0400 (EDT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2955117; Thu, 10 Apr 2003 10:22:56 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Boris Popov , pgsql-performance Subject: Re: Reference data for performance testing? Date: Thu, 10 Apr 2003 10:22:50 -0700 User-Agent: KMail/1.4.3 References: <564664787.20030410102049@procedium.com> In-Reply-To: <564664787.20030410102049@procedium.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304101022.50663.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/113 X-Sequence-Number: 1619 Boris, > We're evaluating postgresql as a backend choice for our next > generation software and would like to perform some rough measurements > in-house. Where could I get my hands on some reference data, say few > very large tables with a total size of over 1G that we could run. I > noticed earlier discussion about Tiger data, but 30G is a bit too much > for what we need. Any other ideas or suggestions? The same discussion references the FCC data, which is more managably sized. Please share your results, if you can! --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 10 13:24:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A10F547592C for ; Thu, 10 Apr 2003 13:24:56 -0400 (EDT) Received: from mail.nbc.attcanada.ca (tor-vs3.nbc.netcom.ca [207.181.89.35]) by postgresql.org (Postfix) with ESMTP id C3BA2474E42 for ; Thu, 10 Apr 2003 13:24:55 -0400 (EDT) Received: from localhost (firewall.procedium.com [216.13.191.82]) by mail.nbc.attcanada.ca (bela (1.1)/8.12.8) with ESMTP id h3AHOq0d019974; Thu, 10 Apr 2003 13:24:54 -0400 (EDT) Date: Thu, 10 Apr 2003 10:24:51 -0700 From: Boris Popov X-Mailer: The Bat! (v1.62i) Business Reply-To: Boris Popov Organization: Procedium Software X-Priority: 3 (Normal) Message-ID: <1014906905.20030410102451@procedium.com> To: Josh Berkus Cc: pgsql-performance Subject: Re: Reference data for performance testing? In-Reply-To: <200304101022.50663.josh@agliodbs.com> References: <564664787.20030410102049@procedium.com> <200304101022.50663.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-29.0 required=5.0 tests=BAYES_20,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/114 X-Sequence-Number: 1620 Hello Josh, Thursday, April 10, 2003, 10:22:50 AM, you wrote: JB> Boris, >> We're evaluating postgresql as a backend choice for our next >> generation software and would like to perform some rough measurements >> in-house. Where could I get my hands on some reference data, say few >> very large tables with a total size of over 1G that we could run. I >> noticed earlier discussion about Tiger data, but 30G is a bit too much >> for what we need. Any other ideas or suggestions? JB> The same discussion references the FCC data, which is more managably sized. JB> Please share your results, if you can! I can't find a link right now, could you tell me where can I download it? -- -Boris From pgsql-performance-owner@postgresql.org Thu Apr 10 13:35:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B397B476323 for ; Thu, 10 Apr 2003 13:35:29 -0400 (EDT) Received: from hotmail.com (f85.law12.hotmail.com [64.4.19.85]) by postgresql.org (Postfix) with ESMTP id 03454476305 for ; Thu, 10 Apr 2003 13:35:25 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 10 Apr 2003 10:32:49 -0700 Received: from 200.67.80.182 by lw12fd.law12.hotmail.msn.com with HTTP; Thu, 10 Apr 2003 17:32:49 GMT X-Originating-IP: [200.67.80.182] X-Originating-Email: [cecilia_ag@hotmail.com] From: "Cecilia Alvarez" To: pgsql-performance@postgresql.org Subject: Slow Visual Basic application Date: Thu, 10 Apr 2003 12:32:49 -0500 Mime-Version: 1.0 Content-Type: text/html; charset=iso-8859-1 Message-ID: X-OriginalArrivalTime: 10 Apr 2003 17:32:49.0499 (UTC) FILETIME=[35051AB0:01C2FF87] X-Spam-Status: No, hits=0.0 required=5.0 tests=BAYES_30,HTML_20_30 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/115 X-Sequence-Number: 1621
Hi,
I have a visual basic application and the access to postgress is very slow.
If I run the query on PGadminII the answer is quite good but if I run the same query from the application it takes a long time (I debugged it). 11seconds .vs. 5 minutes.
I would like to know if I have a problem with my connection to postgres or my odbc.
The string connection is:
 
gobjBD.StringConexion = "Provider=MSDataShape.1;DRIVER={PostgreSQL};DATABASE=mydatabase;
SERVER=192.9.200.5;PORT=5432;UID=postgres;PWD="
 
I�ll really apreciate your help.
Thanks
Cecilia


�nete al mayor servicio mundial de correo electr�nico: Haz clic aqu� From pgsql-performance-owner@postgresql.org Thu Apr 10 13:47:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B5F8E47592C for ; Thu, 10 Apr 2003 13:47:46 -0400 (EDT) Received: from moya.trilug.org (moya.trilug.org [64.244.27.141]) by postgresql.org (Postfix) with ESMTP id CA5E3474E42 for ; Thu, 10 Apr 2003 13:47:42 -0400 (EDT) Received: from trilug.org (vpn.ccgroupnet.com [207.103.85.62]) (using SSLv3 with cipher DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by moya.trilug.org (Postfix) with ESMTP id 45AE6A0025 for ; Thu, 10 Apr 2003 13:47:40 -0400 (EDT) Date: Thu, 10 Apr 2003 13:47:44 -0400 Subject: Re: Reference data for performance testing? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Chris Hedemark To: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit In-Reply-To: <564664787.20030410102049@procedium.com> Message-Id: <88A7D7B4-6B7C-11D7-829D-0003939CC61E@trilug.org> X-Request-Pgp: http://yonderway.com/chris/hedemark.gpg X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-28.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/116 X-Sequence-Number: 1622 On Thursday, April 10, 2003, at 01:20 PM, Boris Popov wrote: > We're evaluating postgresql as a backend choice for our next > generation software and would like to perform some rough measurements > in-house. Where could I get my hands on some reference data, say few > very large tables with a total size of over 1G that we could run. I > noticed earlier discussion about Tiger data, but 30G is a bit too much > for what we need. Any other ideas or suggestions? Actually Tiger is broken down into easily digestable chunks; you don't grab all 30G at once. Pick one moderate size state to work with and you've got about the right size data set. From pgsql-performance-owner@postgresql.org Thu Apr 10 14:58:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26E58475AE5; Thu, 10 Apr 2003 14:58:16 -0400 (EDT) Received: from fddlnint05.fds.com (fddlnint05.fds.com [208.15.91.52]) by postgresql.org (Postfix) with ESMTP id 53DCB475EFD; Thu, 10 Apr 2003 14:58:09 -0400 (EDT) In-Reply-To: Subject: Re: Slow Visual Basic application To: cecilia_ag@hotmail.com Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org X-Mailer: Lotus Notes Release 6.0 September 26, 2002 Message-ID: From: "Patrick Hatcher" Date: Thu, 10 Apr 2003 11:52:45 -0700 X-MIMETrack: Serialize by Router on FDDLNINT05/FSG/SVR/FDD(Release 5.0.4 |June 8, 2000) at 04/10/2003 02:54:26 PM MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable X-Spam-Status: No, hits=-9.0 required=5.0 tests=BAYES_10,IN_REP_TO autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/117 X-Sequence-Number: 1623 It appears you are trying to create a cube by using MSDataShape. Correct? This could be the cause of the slow query. Why not use a straight ADO connection? Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn =3D New ADODB.Connection Set rs =3D New ADODB.Recordset cn.ConnectionString =3D "driver=3D{PostgreSQL};server=3D192.9.200.5;uid=3D;= pwd =3D;database=3Dmydatabase" cn.ConnectionTimeout =3D 300 cn.CursorLocation =3D adUseClient cn.Open Set rs =3D cn.Execute("Select * from table1) =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=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 "Cecilia Alvarez"=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 To: pgsql-perfor= mance@postgresql.org=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 Sent by: cc:=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 pgsql-performance-owner@post Subject: [PERFOR= M] Slow Visual Basic application=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 gresql.org=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=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=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=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 04/10/2003 10:32 AM=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=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=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 Hi, I have a visual basic application and the access to postgress is very slow. If I run the query on PGadminII the answer is quite good but if I run the same query from the application it takes a long time (I debugged it). 11seconds .vs. 5 minutes. I would like to know if I have a problem with my connection to postgres or my odbc. The string connection is: gobjBD.StringConexion =3D "Provider=3DMSDataShape.1;DRIVER =3D{PostgreSQL};DATABASE=3Dmydatabase; SERVER=3D192.9.200.5;PORT=3D5432;UID=3Dpostgres;PWD=3D" I=B4ll really apreciate your help. Thanks Cecilia =DAnete al mayor servicio mundial de correo electr=F3nico: Haz clic aqu=ED From pgsql-performance-owner@postgresql.org Thu Apr 10 14:59:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2623D47592C for ; Thu, 10 Apr 2003 14:59:29 -0400 (EDT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id B4EBA474E42 for ; Thu, 10 Apr 2003 14:59:27 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id OAA16964; Thu, 10 Apr 2003 14:58: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 xma016962; Thu, 10 Apr 03 14:58:16 -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 OAA03220; Thu, 10 Apr 2003 14:52:59 -0400 Message-ID: <3E95BF2B.B93FD0EF@nsd.ca> Date: Thu, 10 Apr 2003 14:59:55 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane Cc: jim@nasby.net, "scott.marlowe" , Matthew Nuzum , "'Josh Berkus'" , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) References: <00a001c2febb$631141d0$6900a8c0@mattspc> <20030409184744.W31861@flake.decibel.org> <11732.1049934037@sss.pgh.pa.us> <3E957F44.A1106F6A@nsd.ca> <4072.1049985615@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-30.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/118 X-Sequence-Number: 1624 How can we solve the problem of cache trashing when scanning large tables? Tom Lane wrote: > > Jean-Luc Lachance writes: > > Shouldn't there be a way to lock some tables in PG cache? > > In my opinion, no. I do not think a manual locking feature could > possibly be used effectively. It could very easily be abused to > decrease net performance, though :-( > > It does seem that a smarter buffer management algorithm would be a good > idea, but past experiments have failed to show any measurable benefit. > Perhaps those experiments were testing the wrong conditions. I'd still > be happy to see LRU(k) or some such method put in, if someone can prove > that it actually does anything useful for us. (As best I recall, I only > tested LRU-2 with pgbench. Perhaps Josh's benchmarking project will > offer a wider variety of interesting scenarios.) > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Thu Apr 10 19:15:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0D7DD476036 for ; Thu, 10 Apr 2003 19:15:08 -0400 (EDT) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 8D840476032 for ; Thu, 10 Apr 2003 19:15:06 -0400 (EDT) Received: from ronpc [63.68.5.2] by torque.intervideoinc.com (SMTPD32-5.05) id AFBA1B60152; Thu, 10 Apr 2003 16:35:22 -0700 From: "Ron Mayer" To: "Josh Berkus" , "Matthew Nuzum" , "'Pgsql-Performance'" Cc: Subject: Re: Caching (was Re: choosing the right platform) Date: Thu, 10 Apr 2003 16:06:40 -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.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal In-Reply-To: <200304092045.29503.josh@agliodbs.com> X-Spam-Status: No, hits=-14.3 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE,SMTPD_IN_RCVD autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/119 X-Sequence-Number: 1625 Short summary... I think sort_mem matters quite a bit (20-40%) on my data-warehousing applications. Am I doing something wrong to need so much sort_mem? Josh wrote: >> ** It's better to not use huge amount of sort-mem... > >...However, I have never seen a database use more than 32mb sort mem >in a single process, so I don't think the 2GB limit will hurt you much ... Do you think this is true in data warehousing applications as well? During the ETL part of data warehousing, large sorts are often used to get the "new" values that need to be inserted into "dimension" tables, like this: INSERT INTO dimension_val (id,val) SELECT nextval('val_seq'),val FROM (SELECT DISTINCT val FROM import_table EXCEPT SELECT val FROM dimension_val) as a; As far as I can tell, this query typically does two sorts, one for the distinct, and one for the except. In a data warehouse we have here, we load about 3 million rows each week; load time improved from about 9 to 7 hours by breaking up such queries into expressions that only require one sort at a time, and surrounding the expressions with "set sort_mem=something_big" statements to give it enough space to not hit the disk. SET SORT_MEM=300000; CREATE TEMPORARY TABLE potential_new_values AS SELECT DISTINCT val FROM import_table; ... SET SORT_MEM=1000; Anyone else have similar experience, or am I doing something wrong to need so much SORT_MEM? Ron PS: Below is an example of another real-world query from the same reporting system that benefits from a sort_mem over 32M. Explain analyze (below) shows a 40% improvement by having the sort fit in memory. 10Meg and 32Meg take over 22 seconds. 100Meg takes 14. ==================================================================================================== logs2=# logs2=# logs2=# set sort_mem=10000; SET VARIABLE logs2=# explain analyze select distinct category from c_transaction_credit; NOTICE: QUERY PLAN: Unique (cost=71612.82..72838.69 rows=49035 width=17) (actual time=20315.47..22457.21 rows=2914 loops=1) -> Sort (cost=71612.82..71612.82 rows=490348 width=17) (actual time=20315.46..21351.42 rows=511368 loops=1) -> Seq Scan on c_transaction_credit (cost=0.00..14096.48 rows=490348 width=17) (actual time=0.08..2932.72 rows=511368 loops=1) Total runtime: 22475.63 msec EXPLAIN logs2=# set sort_mem=32000; SET VARIABLE logs2=# explain analyze select distinct category from c_transaction_credit; NOTICE: QUERY PLAN: Unique (cost=60442.82..61668.69 rows=49035 width=17) (actual time=22657.31..24794.19 rows=2914 loops=1) -> Sort (cost=60442.82..60442.82 rows=490348 width=17) (actual time=22657.30..23714.43 rows=511368 loops=1) -> Seq Scan on c_transaction_credit (cost=0.00..14096.48 rows=490348 width=17) (actual time=0.07..3020.83 rows=511368 loops=1) Total runtime: 24811.65 msec EXPLAIN logs2=# set sort_mem=100000; SET VARIABLE logs2=# explain analyze select distinct category from c_transaction_credit; NOTICE: QUERY PLAN: Unique (cost=60442.82..61668.69 rows=49035 width=17) (actual time=12205.19..14012.57 rows=2914 loops=1) -> Sort (cost=60442.82..60442.82 rows=490348 width=17) (actual time=12205.18..12710.16 rows=511368 loops=1) -> Seq Scan on c_transaction_credit (cost=0.00..14096.48 rows=490348 width=17) (actual time=0.08..3001.05 rows=511368 loops=1) Total runtime: 14187.96 msec EXPLAIN logs2=# From pgsql-performance-owner@postgresql.org Thu Apr 10 20:13:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C4C48474E42 for ; Thu, 10 Apr 2003 20:13:34 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 03A24474E4F for ; Thu, 10 Apr 2003 20:13:30 -0400 (EDT) Received: from [216.135.165.74] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2955916; Thu, 10 Apr 2003 17:13:26 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Help analyzing 7.2.4 EXPLAIN Date: Thu, 10 Apr 2003 17:13:19 -0700 User-Agent: KMail/1.4.3 Cc: Pgsql-Performance References: <200304091715.19565.josh@agliodbs.com> <11860.1049935883@sss.pgh.pa.us> In-Reply-To: <11860.1049935883@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304101713.19953.josh@agliodbs.com> X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/120 X-Sequence-Number: 1626 Tom, If you're interested, here's the query I ended up with. It's much uglier t= han=20 the original query, but gives me slightly more data (one bit of information= =20 is seperated into 2 columns rather than rolled up), is 100ms faster, and=20 should not slow down much with the growth of the tables: SELECT users.user_id, (users.fname || COALESCE(' ' || users.minit, '') || '= '=20 || users.lname) as atty_name, users.lname, COALESCE ( (SELECT if_addendee_conflict(users.user_id, 3272, '2003-04-15 10:00', '1= =20 days'::INTERVAL, events.event_id, events.event_date, events.duration, event_cats.status, '30 minutes', staff_id) as cflt FROM event_types, event_cats, event_days, events, event_staff WHERE events.event_id =3D event_days.event_id and events.etype_id =3D event_types.etype_id AND event_types.ecat_id =3D event_cats.ecat_id AND event_days.event_day BETWEEN '2003-04-15' AND '2003-04-16 10:00' AND events.event_id <> 3272 AND events.event_id =3D event_staff.event_id AND event_staff.staff_id =3D users.user_id AND event_cats.status IN (1,3) ORDER BY cflt LIMIT 1), (SELECT 'LEAVE'::TEXT FROM event_types, event_cats, event_days, events WHERE events.event_id =3D event_days.event_id and events.etype_id =3D event_types.etype_id AND event_types.ecat_id =3D event_cats.ecat_id AND event_days.event_day BETWEEN '2003-04-15' AND '2003-04-16 10:00' AND events.event_id <> 3272 AND event_cats.status =3D 4) ) AS conflict, (SELECT (staff_id > 0) FROM event_staff WHERE event_id =3D 3272 AND staff_id =3D users.user_id) as assigned FROM users WHERE EXISTS (SELECT teams_users.user_id FROM teams_users JOIN teams_tree ON teams_users.team_id =3D teams_tree.team_id WHERE teams_tree.treeno BETWEEN 3 and 4 AND teams_users.user_id =3D users.user_id) AND users.status > 0 ORDER BY conflict, users.lname, atty_name; --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 11 11:19:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ADCC64762D7 for ; Fri, 11 Apr 2003 11:19:24 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id DC0624762A2 for ; Fri, 11 Apr 2003 11:19:23 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3BFIBRF006302; Fri, 11 Apr 2003 09:18:11 -0600 (MDT) Date: Fri, 11 Apr 2003 09:14:00 -0600 (MDT) From: "scott.marlowe" To: Ron Mayer Cc: Josh Berkus , Matthew Nuzum , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-21.8 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTE_TWICE_1, USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/121 X-Sequence-Number: 1627 On Thu, 10 Apr 2003, Ron Mayer wrote: > > Short summary... > > I think sort_mem matters quite a bit (20-40%) on > my data-warehousing applications. > > Am I doing something wrong to need so much sort_mem? No. In fact, it's not uncommon for certain queries to need WAY more sort memory than most queries. The mistake that gets made is setting sort_mem to something like 32 meg for every sort. There are many "sorts" on my machine that are coming from well ordered data, and don't really need to be done in memory to be reasonably fast. Those can run fine with 8 meg sort_mem. For things with less well ordered in the database, or where the data set is really big (100s of megs of data being sorted) it often helps to just grab a 100 meg sort_mem for the session. If sort_mem is too big, the OS will likely wind up swapping it or shared memory out and thrashing at the worst, or just surrendering all spare memory to sort_mem, thus flushing all fs cache. For a lot of apps, it's all about the sweet spot of memory to each subsystem, and sort_mem can go from nibbling memory to eating it like Nibbler from Futurama in seconds if you set it just a little too high and have the right parallel load on your server. So, as long as you aren't starving your server of resources, setting sort_mem higher is fine. From pgsql-performance-owner@postgresql.org Fri Apr 11 12:16:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 587FD475F5F for ; Fri, 11 Apr 2003 12:16:20 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 5859F4762A2 for ; Fri, 11 Apr 2003 12:16:04 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2956889; Fri, 11 Apr 2003 09:15:57 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Ron Mayer" , "Matthew Nuzum" , "'Pgsql-Performance'" Subject: Re: Caching (was Re: choosing the right platform) Date: Fri, 11 Apr 2003 09:15:15 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200304110915.15060.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/122 X-Sequence-Number: 1628 Ron, > In a data warehouse we have here, we load about 3 million rows > each week; load time improved from about 9 to 7 hours > by breaking up such queries into expressions that only require > one sort at a time, and surrounding the expressions with > "set sort_mem=3Dsomething_big" statements to give it enough > space to not hit the disk. > > SET SORT_MEM=3D300000; > CREATE TEMPORARY TABLE potential_new_values AS > SELECT DISTINCT val FROM import_table; > ... > SET SORT_MEM=3D1000; > > Anyone else have similar experience, or am I doing something > wrong to need so much SORT_MEM? No, this sounds very reasonable to me. I do a similar operation on one of = my=20 systems as part of a nightly data transformation for reporting. Since I=20 haven't had to do those on tables over 150,000 rows, I haven't seen the kin= d=20 of RAM usage you experience. > Below is an example of another real-world query from the same > reporting system that benefits from a sort_mem over 32M. > Explain analyze (below) shows a 40% improvement by having > the sort fit in memory. Cool! That's a perfect example of sizing sort_mem for the query. Mind if= I=20 steal it for an article at some point? --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Fri Apr 11 13:38:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 56FD847644D for ; Fri, 11 Apr 2003 13:38:32 -0400 (EDT) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 27E6147651D for ; Fri, 11 Apr 2003 13:33:48 -0400 (EDT) Received: from ronpc [63.68.5.2] by torque.intervideoinc.com (SMTPD32-5.05) id A13F233100F2; Fri, 11 Apr 2003 10:54:07 -0700 From: "Ron Mayer" To: "Josh Berkus" , "Matthew Nuzum" , "'Pgsql-Performance'" Cc: Subject: Re: Caching (was Re: choosing the right platform) Date: Fri, 11 Apr 2003 10:25:24 -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.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal In-Reply-To: <200304110915.15060.josh@agliodbs.com> X-Spam-Status: No, hits=-14.8 required=5.0 tests=BAYES_20,IN_REP_TO,MSGID_GOOD_EXCHANGE,QUOTED_EMAIL_TEXT, SMTPD_IN_RCVD autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/123 X-Sequence-Number: 1629 Josh wrote: >Ron, >> Below is an example of another real-world query from the same >> reporting system that benefits from a sort_mem over 32M. >> Explain analyze (below) shows a 40% improvement by having >> the sort fit in memory. > >Cool! That's a perfect example of sizing sort_mem for the query. Mind if I >steal it for an article at some point? Gladly! BTW... if you're writing a tuning article, the most interesting one I've seen is: http://otn.oracle.com/oramag/webcolumns/2002/techarticles/scalzo_linux01.html I like how they broke down the process in many steps and measured after each. I'm was intrigued by how much Linux's VM tweaking (vm.bdflush) affected performance mattered as much at the more-commontly tweaked "noatime". Ron From pgsql-performance-owner@postgresql.org Sat Apr 12 13:06:20 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 002F6475B85 for ; Sat, 12 Apr 2003 13:06:19 -0400 (EDT) Received: from smtp-relay-3.sea.adobe.com (smtp-relay-3.adobe.com [192.150.22.10]) by postgresql.org (Postfix) with ESMTP id 321F2475AE4 for ; Sat, 12 Apr 2003 13:06:13 -0400 (EDT) Received: from inner-relay-3.corp.adobe.com (inner-relay-3 [153.32.251.51]) by smtp-relay-3.sea.adobe.com (8.12.9/8.12.9) with ESMTP id h3CH67rT009475 for ; Sat, 12 Apr 2003 10:06:13 -0700 (PDT) Received: from mail-321.corp.adobe.com (mail-321 [153.32.2.46]) by inner-relay-3.corp.adobe.com (8.12.3/8.12.3) with ESMTP id h3CH67iQ028819 for ; Sat, 12 Apr 2003 10:06:07 -0700 (PDT) Received: from adobe.com (c-155-123.corp.adobe.com [153.32.155.123]) by mail-321.corp.adobe.com (8.11.4/8.11.4) with ESMTP id h3CH4o922189 for ; Sat, 12 Apr 2003 10:04:50 -0700 (PDT) Message-ID: <3E98498C.80306@adobe.com> Date: Sat, 12 Apr 2003 10:14:52 -0700 From: shane hill User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance Subject: update query blows out References: <564664787.20030410102049@procedium.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-18.6 required=5.0 tests=BAYES_10,REFERENCES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/124 X-Sequence-Number: 1630 Hi folks, sorry if the following is confusing, I have just tried to provide the pertinent info and I have been up for more than 24 hours working. I am getting weary.... I am having a problem with an update transaction. I need to update 4000+ records but the update query keeps blowing out postgres and at times I am forced to restart the postmaster or reboot my server if I update 2500+ records. The query is fine with 2225 records it is just somewhere beyond 2225 that brings the server down. I assumed this was related to the shared memory settings but when I tried changing those values the behavior was identical. I did not try beyond 256 megs for shmmax. I then tried the temporary solution of lowering the number of shared_buffers and max_connections but that did not change anything either. I then tried using the IN operator but that did not change anything either I am wondering if there is some other limit that I am hitting in MacOSX that is not related to the SHM vars. I hope I am just overlooking something simple and that the list will come back with some chiding and an answer :) does anybody have any suggestions? thank you very much, -Shane ----------------------------------------------------------- SQL DETAILS: my query is of this form: BEGIN; UPDATE "mytable" SET "n_filtered"=0,"n_dirty"=1 where ("s_fileName" = 'filename1' OR "s_fileName" = 'filename2' ....... OR "s_fileName" = 'filename2000') AND ("n_objId=12345); COMMIT; explain tells me this: seq scan on "mytable" (cost=0.00..5020.00 rows=5 width=174) Filter ......... ----------------------------------------------------------- ----------------------------------------------------------- SYSTEM: os: Mac 10.2.4 chip: 1.4 GHz ram: 1 GB ----------------------------------------------------------- ----------------------------------------------------------- ERROR MESSAGE: server process (pid 650) was terminated by signal 11 all server processes terminated; reinitializing shared memopry and semaphores ----------------------------------------------------------- ----------------------------------------------------------- SOLUTIONS I HAVE TRIED 1. tweaking the five kern.sysv vars. to every configurable option possible currently I am at: kern.sysv.shmmax: 1073741824 kern.sysv.shmmin: 256 kern.sysv.shmmni: 8192 kern.sysv.shmseg: 2048 kern.sysv.shmall: 262144 (I know shmmin is way too high according to the stuff I read, I was just getting desperate, I have tried just leaving it at 1) 2. lowering the number of shared_buffers and max_connections to 32:16 32:8 16:8 in postgresql.conf currently I am at 64 shared_bufs and 32 max_connects (these were the defaults) 3. Using the IN sql operator rather than a bunch of ORs, but I still have the same problem ------------------------------------- From pgsql-performance-owner@postgresql.org Sat Apr 12 13:17:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D7A4E475AA9 for ; Sat, 12 Apr 2003 13:17:01 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 12A2347580B for ; Sat, 12 Apr 2003 13:17:01 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3CHGP2L018801; Sat, 12 Apr 2003 13:16:25 -0400 (EDT) To: shane hill Cc: pgsql-performance Subject: Re: update query blows out In-reply-to: <3E98498C.80306@adobe.com> References: <564664787.20030410102049@procedium.com> <3E98498C.80306@adobe.com> Comments: In-reply-to shane hill message dated "Sat, 12 Apr 2003 10:14:52 -0700" Date: Sat, 12 Apr 2003 13:16:24 -0400 Message-ID: <18800.1050167784@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/125 X-Sequence-Number: 1631 shane hill writes: > I am having a problem with an update transaction. I need to update 4000+ > records but the update query keeps blowing out postgres and at times I > am forced to restart the postmaster or reboot my server if I update > 2500+ records. The query is fine with 2225 records it is just somewhere > beyond 2225 that brings the server down. What Postgres version? Can you get a backtrace from the core dump? regards, tom lane From pgsql-performance-owner@postgresql.org Sat Apr 12 14:06:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AE5C24762E1 for ; Sat, 12 Apr 2003 14:06:33 -0400 (EDT) Received: from smtp-relay-3.sea.adobe.com (smtp-relay-3.adobe.com [192.150.22.10]) by postgresql.org (Postfix) with ESMTP id 2C04F47580B for ; Sat, 12 Apr 2003 14:06:31 -0400 (EDT) Received: from inner-relay-3.corp.adobe.com (inner-relay-3 [153.32.251.51]) by smtp-relay-3.sea.adobe.com (8.12.9/8.12.9) with ESMTP id h3CI6LrT013974; Sat, 12 Apr 2003 11:06:27 -0700 (PDT) Received: from mail-321.corp.adobe.com (mail-321 [153.32.2.46]) by inner-relay-3.corp.adobe.com (8.12.3/8.12.3) with ESMTP id h3CI6GiQ000739; Sat, 12 Apr 2003 11:06:16 -0700 (PDT) Received: from adobe.com (c-155-123.corp.adobe.com [153.32.155.123]) by mail-321.corp.adobe.com (8.11.4/8.11.4) with ESMTP id h3CI4r927796; Sat, 12 Apr 2003 11:04:59 -0700 (PDT) Message-ID: <3E98579F.8040904@adobe.com> Date: Sat, 12 Apr 2003 11:14:55 -0700 From: shane hill User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance Subject: Re: update query blows out References: <564664787.20030410102049@procedium.com> <3E98498C.80306@adobe.com> <18800.1050167784@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------070800090800020601030107" X-Spam-Status: No, hits=-25.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,REFERENCES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/126 X-Sequence-Number: 1632 This is a multi-part message in MIME format. --------------070800090800020601030107 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Postgres 7.3.1 The crash log is attached: thank you very much! -Shane Tom Lane wrote: >shane hill writes: > > >>I am having a problem with an update transaction. I need to update 4000+ >>records but the update query keeps blowing out postgres and at times I >>am forced to restart the postmaster or reboot my server if I update >>2500+ records. The query is fine with 2225 records it is just somewhere >>beyond 2225 that brings the server down. >> >> > >What Postgres version? Can you get a backtrace from the core dump? > > regards, tom lane > > >---------------------------(end of broadcast)--------------------------- >TIP 6: Have you searched our list archives? > >http://archives.postgresql.org > > > > --------------070800090800020601030107 Content-Type: text/plain; name="postmaster.crash.log" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="postmaster.crash.log" Date/Time: 2003-04-11 22:44:26 -0700 OS Version: 10.2.4 (Build 6I35) Host: qesx Command: postmaster PID: 622 Exception: EXC_BAD_ACCESS (0x0001) Codes: KERN_INVALID_ADDRESS (0x0001) at 0xbff7ffc0 Thread 0 Crashed: #0 0x000acb88 in eval_const_expressions_mutator (clauses.c:1130) #1 0x000add34 in expression_tree_mutator (clauses.c:2314) #2 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #3 0x000add34 in expression_tree_mutator (clauses.c:2314) #4 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #5 0x000add34 in expression_tree_mutator (clauses.c:2314) #6 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #7 0x000add34 in expression_tree_mutator (clauses.c:2314) #8 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #9 0x000add34 in expression_tree_mutator (clauses.c:2314) #10 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #11 0x000add34 in expression_tree_mutator (clauses.c:2314) #12 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #13 0x000add34 in expression_tree_mutator (clauses.c:2314) #14 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #15 0x000add34 in expression_tree_mutator (clauses.c:2314) #16 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #17 0x000add34 in expression_tree_mutator (clauses.c:2314) #18 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #19 0x000add34 in expression_tree_mutator (clauses.c:2314) #20 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #21 0x000add34 in expression_tree_mutator (clauses.c:2314) #22 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #23 0x000add34 in expression_tree_mutator (clauses.c:2314) #24 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #25 0x000add34 in expression_tree_mutator (clauses.c:2314) #26 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #27 0x000add34 in expression_tree_mutator (clauses.c:2314) #28 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #29 0x000add34 in expression_tree_mutator (clauses.c:2314) #30 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #31 0x000add34 in expression_tree_mutator (clauses.c:2314) #32 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #33 0x000add34 in expression_tree_mutator (clauses.c:2314) #34 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #35 0x000add34 in expression_tree_mutator (clauses.c:2314) #36 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #37 0x000add34 in expression_tree_mutator (clauses.c:2314) #38 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #39 0x000add34 in expression_tree_mutator (clauses.c:2314) #40 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #41 0x000add34 in expression_tree_mutator (clauses.c:2314) #42 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #43 0x000add34 in expression_tree_mutator (clauses.c:2314) #44 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #45 0x000add34 in expression_tree_mutator (clauses.c:2314) #46 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #47 0x000add34 in expression_tree_mutator (clauses.c:2314) #48 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #49 0x000add34 in expression_tree_mutator (clauses.c:2314) #50 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #51 0x000add34 in expression_tree_mutator (clauses.c:2314) #52 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #53 0x000add34 in expression_tree_mutator (clauses.c:2314) #54 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #55 0x000add34 in expression_tree_mutator (clauses.c:2314) #56 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #57 0x000add34 in expression_tree_mutator (clauses.c:2314) #58 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #59 0x000add34 in expression_tree_mutator (clauses.c:2314) #60 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #61 0x000add34 in expression_tree_mutator (clauses.c:2314) #62 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #63 0x000add34 in expression_tree_mutator (clauses.c:2314) #64 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #65 0x000add34 in expression_tree_mutator (clauses.c:2314) #66 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #67 0x000add34 in expression_tree_mutator (clauses.c:2314) #68 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #69 0x000add34 in expression_tree_mutator (clauses.c:2314) #70 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #71 0x000add34 in expression_tree_mutator (clauses.c:2314) #72 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #73 0x000add34 in expression_tree_mutator (clauses.c:2314) #74 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #75 0x000add34 in expression_tree_mutator (clauses.c:2314) #76 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #77 0x000add34 in expression_tree_mutator (clauses.c:2314) #78 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #79 0x000add34 in expression_tree_mutator (clauses.c:2314) #80 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #81 0x000add34 in expression_tree_mutator (clauses.c:2314) #82 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #83 0x000add34 in expression_tree_mutator (clauses.c:2314) #84 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #85 0x000add34 in expression_tree_mutator (clauses.c:2314) #86 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #87 0x000add34 in expression_tree_mutator (clauses.c:2314) #88 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #89 0x000add34 in expression_tree_mutator (clauses.c:2314) #90 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #91 0x000add34 in expression_tree_mutator (clauses.c:2314) #92 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #93 0x000add34 in expression_tree_mutator (clauses.c:2314) #94 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #95 0x000add34 in expression_tree_mutator (clauses.c:2314) #96 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #97 0x000add34 in expression_tree_mutator (clauses.c:2314) #98 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #99 0x000add34 in expression_tree_mutator (clauses.c:2314) #100 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #101 0x000add34 in expression_tree_mutator (clauses.c:2314) #102 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #103 0x000add34 in expression_tree_mutator (clauses.c:2314) #104 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #105 0x000add34 in expression_tree_mutator (clauses.c:2314) #106 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #107 0x000add34 in expression_tree_mutator (clauses.c:2314) #108 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #109 0x000add34 in expression_tree_mutator (clauses.c:2314) #110 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #111 0x000add34 in expression_tree_mutator (clauses.c:2314) #112 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #113 0x000add34 in expression_tree_mutator (clauses.c:2314) #114 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #115 0x000add34 in expression_tree_mutator (clauses.c:2314) #116 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #117 0x000add34 in expression_tree_mutator (clauses.c:2314) #118 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #119 0x000add34 in expression_tree_mutator (clauses.c:2314) #120 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #121 0x000add34 in expression_tree_mutator (clauses.c:2314) #122 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #123 0x000add34 in expression_tree_mutator (clauses.c:2314) #124 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #125 0x000add34 in expression_tree_mutator (clauses.c:2314) #126 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #127 0x000add34 in expression_tree_mutator (clauses.c:2314) #128 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #129 0x000add34 in expression_tree_mutator (clauses.c:2314) #130 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #131 0x000add34 in expression_tree_mutator (clauses.c:2314) #132 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #133 0x000add34 in expression_tree_mutator (clauses.c:2314) #134 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #135 0x000add34 in expression_tree_mutator (clauses.c:2314) #136 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #137 0x000add34 in expression_tree_mutator (clauses.c:2314) #138 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #139 0x000add34 in expression_tree_mutator (clauses.c:2314) #140 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #141 0x000add34 in expression_tree_mutator (clauses.c:2314) #142 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #143 0x000add34 in expression_tree_mutator (clauses.c:2314) #144 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #145 0x000add34 in expression_tree_mutator (clauses.c:2314) #146 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #147 0x000add34 in expression_tree_mutator (clauses.c:2314) #148 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #149 0x000add34 in expression_tree_mutator (clauses.c:2314) #150 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #151 0x000add34 in expression_tree_mutator (clauses.c:2314) #152 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #153 0x000add34 in expression_tree_mutator (clauses.c:2314) #154 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #155 0x000add34 in expression_tree_mutator (clauses.c:2314) #156 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #157 0x000add34 in expression_tree_mutator (clauses.c:2314) #158 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #159 0x000add34 in expression_tree_mutator (clauses.c:2314) #160 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #161 0x000add34 in expression_tree_mutator (clauses.c:2314) #162 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #163 0x000add34 in expression_tree_mutator (clauses.c:2314) #164 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #165 0x000add34 in expression_tree_mutator (clauses.c:2314) #166 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #167 0x000add34 in expression_tree_mutator (clauses.c:2314) #168 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #169 0x000add34 in expression_tree_mutator (clauses.c:2314) #170 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #171 0x000add34 in expression_tree_mutator (clauses.c:2314) #172 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #173 0x000add34 in expression_tree_mutator (clauses.c:2314) #174 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #175 0x000add34 in expression_tree_mutator (clauses.c:2314) #176 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #177 0x000add34 in expression_tree_mutator (clauses.c:2314) #178 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #179 0x000add34 in expression_tree_mutator (clauses.c:2314) #180 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #181 0x000add34 in expression_tree_mutator (clauses.c:2314) #182 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #183 0x000add34 in expression_tree_mutator (clauses.c:2314) #184 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #185 0x000add34 in expression_tree_mutator (clauses.c:2314) #186 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #187 0x000add34 in expression_tree_mutator (clauses.c:2314) #188 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #189 0x000add34 in expression_tree_mutator (clauses.c:2314) #190 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #191 0x000add34 in expression_tree_mutator (clauses.c:2314) #192 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #193 0x000add34 in expression_tree_mutator (clauses.c:2314) #194 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #195 0x000add34 in expression_tree_mutator (clauses.c:2314) #196 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #197 0x000add34 in expression_tree_mutator (clauses.c:2314) #198 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #199 0x000add34 in expression_tree_mutator (clauses.c:2314) #200 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #201 0x000add34 in expression_tree_mutator (clauses.c:2314) #202 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #203 0x000add34 in expression_tree_mutator (clauses.c:2314) #204 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #205 0x000add34 in expression_tree_mutator (clauses.c:2314) #206 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #207 0x000add34 in expression_tree_mutator (clauses.c:2314) #208 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #209 0x000add34 in expression_tree_mutator (clauses.c:2314) #210 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #211 0x000add34 in expression_tree_mutator (clauses.c:2314) #212 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #213 0x000add34 in expression_tree_mutator (clauses.c:2314) #214 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #215 0x000add34 in expression_tree_mutator (clauses.c:2314) #216 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #217 0x000add34 in expression_tree_mutator (clauses.c:2314) #218 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #219 0x000add34 in expression_tree_mutator (clauses.c:2314) #220 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #221 0x000add34 in expression_tree_mutator (clauses.c:2314) #222 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #223 0x000add34 in expression_tree_mutator (clauses.c:2314) #224 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #225 0x000add34 in expression_tree_mutator (clauses.c:2314) #226 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #227 0x000add34 in expression_tree_mutator (clauses.c:2314) #228 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #229 0x000add34 in expression_tree_mutator (clauses.c:2314) #230 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #231 0x000add34 in expression_tree_mutator (clauses.c:2314) #232 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #233 0x000add34 in expression_tree_mutator (clauses.c:2314) #234 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #235 0x000add34 in expression_tree_mutator (clauses.c:2314) #236 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #237 0x000add34 in expression_tree_mutator (clauses.c:2314) #238 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #239 0x000add34 in expression_tree_mutator (clauses.c:2314) #240 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #241 0x000add34 in expression_tree_mutator (clauses.c:2314) #242 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #243 0x000add34 in expression_tree_mutator (clauses.c:2314) #244 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #245 0x000add34 in expression_tree_mutator (clauses.c:2314) #246 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #247 0x000add34 in expression_tree_mutator (clauses.c:2314) #248 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #249 0x000add34 in expression_tree_mutator (clauses.c:2314) #250 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #251 0x000add34 in expression_tree_mutator (clauses.c:2314) #252 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #253 0x000add34 in expression_tree_mutator (clauses.c:2314) #254 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #255 0x000add34 in expression_tree_mutator (clauses.c:2314) #256 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #257 0x000add34 in expression_tree_mutator (clauses.c:2314) #258 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #259 0x000add34 in expression_tree_mutator (clauses.c:2314) #260 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #261 0x000add34 in expression_tree_mutator (clauses.c:2314) #262 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #263 0x000add34 in expression_tree_mutator (clauses.c:2314) #264 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #265 0x000add34 in expression_tree_mutator (clauses.c:2314) #266 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #267 0x000add34 in expression_tree_mutator (clauses.c:2314) #268 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #269 0x000add34 in expression_tree_mutator (clauses.c:2314) #270 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #271 0x000add34 in expression_tree_mutator (clauses.c:2314) #272 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #273 0x000add34 in expression_tree_mutator (clauses.c:2314) #274 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #275 0x000add34 in expression_tree_mutator (clauses.c:2314) #276 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #277 0x000add34 in expression_tree_mutator (clauses.c:2314) #278 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #279 0x000add34 in expression_tree_mutator (clauses.c:2314) #280 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #281 0x000add34 in expression_tree_mutator (clauses.c:2314) #282 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #283 0x000add34 in expression_tree_mutator (clauses.c:2314) #284 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #285 0x000add34 in expression_tree_mutator (clauses.c:2314) #286 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #287 0x000add34 in expression_tree_mutator (clauses.c:2314) #288 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #289 0x000add34 in expression_tree_mutator (clauses.c:2314) #290 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #291 0x000add34 in expression_tree_mutator (clauses.c:2314) #292 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #293 0x000add34 in expression_tree_mutator (clauses.c:2314) #294 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #295 0x000add34 in expression_tree_mutator (clauses.c:2314) #296 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #297 0x000add34 in expression_tree_mutator (clauses.c:2314) #298 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #299 0x000add34 in expression_tree_mutator (clauses.c:2314) #300 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #301 0x000add34 in expression_tree_mutator (clauses.c:2314) #302 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #303 0x000add34 in expression_tree_mutator (clauses.c:2314) #304 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #305 0x000add34 in expression_tree_mutator (clauses.c:2314) #306 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #307 0x000add34 in expression_tree_mutator (clauses.c:2314) #308 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #309 0x000add34 in expression_tree_mutator (clauses.c:2314) #310 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #311 0x000add34 in expression_tree_mutator (clauses.c:2314) #312 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #313 0x000add34 in expression_tree_mutator (clauses.c:2314) #314 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #315 0x000add34 in expression_tree_mutator (clauses.c:2314) #316 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #317 0x000add34 in expression_tree_mutator (clauses.c:2314) #318 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #319 0x000add34 in expression_tree_mutator (clauses.c:2314) #320 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #321 0x000add34 in expression_tree_mutator (clauses.c:2314) #322 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #323 0x000add34 in expression_tree_mutator (clauses.c:2314) #324 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #325 0x000add34 in expression_tree_mutator (clauses.c:2314) #326 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #327 0x000add34 in expression_tree_mutator (clauses.c:2314) #328 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #329 0x000add34 in expression_tree_mutator (clauses.c:2314) #330 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #331 0x000add34 in expression_tree_mutator (clauses.c:2314) #332 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #333 0x000add34 in expression_tree_mutator (clauses.c:2314) #334 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #335 0x000add34 in expression_tree_mutator (clauses.c:2314) #336 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #337 0x000add34 in expression_tree_mutator (clauses.c:2314) #338 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #339 0x000add34 in expression_tree_mutator (clauses.c:2314) #340 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #341 0x000add34 in expression_tree_mutator (clauses.c:2314) #342 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #343 0x000add34 in expression_tree_mutator (clauses.c:2314) #344 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #345 0x000add34 in expression_tree_mutator (clauses.c:2314) #346 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #347 0x000add34 in expression_tree_mutator (clauses.c:2314) #348 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #349 0x000add34 in expression_tree_mutator (clauses.c:2314) #350 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #351 0x000add34 in expression_tree_mutator (clauses.c:2314) #352 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #353 0x000add34 in expression_tree_mutator (clauses.c:2314) #354 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #355 0x000add34 in expression_tree_mutator (clauses.c:2314) #356 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #357 0x000add34 in expression_tree_mutator (clauses.c:2314) #358 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #359 0x000add34 in expression_tree_mutator (clauses.c:2314) #360 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #361 0x000add34 in expression_tree_mutator (clauses.c:2314) #362 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #363 0x000add34 in expression_tree_mutator (clauses.c:2314) #364 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #365 0x000add34 in expression_tree_mutator (clauses.c:2314) #366 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #367 0x000add34 in expression_tree_mutator (clauses.c:2314) #368 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #369 0x000add34 in expression_tree_mutator (clauses.c:2314) #370 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #371 0x000add34 in expression_tree_mutator (clauses.c:2314) #372 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #373 0x000add34 in expression_tree_mutator (clauses.c:2314) #374 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #375 0x000add34 in expression_tree_mutator (clauses.c:2314) #376 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #377 0x000add34 in expression_tree_mutator (clauses.c:2314) #378 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #379 0x000add34 in expression_tree_mutator (clauses.c:2314) #380 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #381 0x000add34 in expression_tree_mutator (clauses.c:2314) #382 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #383 0x000add34 in expression_tree_mutator (clauses.c:2314) #384 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #385 0x000add34 in expression_tree_mutator (clauses.c:2314) #386 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #387 0x000add34 in expression_tree_mutator (clauses.c:2314) #388 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #389 0x000add34 in expression_tree_mutator (clauses.c:2314) #390 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #391 0x000add34 in expression_tree_mutator (clauses.c:2314) #392 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #393 0x000add34 in expression_tree_mutator (clauses.c:2314) #394 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #395 0x000add34 in expression_tree_mutator (clauses.c:2314) #396 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #397 0x000add34 in expression_tree_mutator (clauses.c:2314) #398 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #399 0x000add34 in expression_tree_mutator (clauses.c:2314) #400 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #401 0x000add34 in expression_tree_mutator (clauses.c:2314) #402 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #403 0x000add34 in expression_tree_mutator (clauses.c:2314) #404 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #405 0x000add34 in expression_tree_mutator (clauses.c:2314) #406 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #407 0x000add34 in expression_tree_mutator (clauses.c:2314) #408 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #409 0x000add34 in expression_tree_mutator (clauses.c:2314) #410 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #411 0x000add34 in expression_tree_mutator (clauses.c:2314) #412 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #413 0x000add34 in expression_tree_mutator (clauses.c:2314) #414 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #415 0x000add34 in expression_tree_mutator (clauses.c:2314) #416 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #417 0x000add34 in expression_tree_mutator (clauses.c:2314) #418 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #419 0x000add34 in expression_tree_mutator (clauses.c:2314) #420 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #421 0x000add34 in expression_tree_mutator (clauses.c:2314) #422 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #423 0x000add34 in expression_tree_mutator (clauses.c:2314) #424 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #425 0x000add34 in expression_tree_mutator (clauses.c:2314) #426 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #427 0x000add34 in expression_tree_mutator (clauses.c:2314) #428 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #429 0x000add34 in expression_tree_mutator (clauses.c:2314) #430 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #431 0x000add34 in expression_tree_mutator (clauses.c:2314) #432 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #433 0x000add34 in expression_tree_mutator (clauses.c:2314) #434 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #435 0x000add34 in expression_tree_mutator (clauses.c:2314) #436 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #437 0x000add34 in expression_tree_mutator (clauses.c:2314) #438 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #439 0x000add34 in expression_tree_mutator (clauses.c:2314) #440 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #441 0x000add34 in expression_tree_mutator (clauses.c:2314) #442 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #443 0x000add34 in expression_tree_mutator (clauses.c:2314) #444 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #445 0x000add34 in expression_tree_mutator (clauses.c:2314) #446 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #447 0x000add34 in expression_tree_mutator (clauses.c:2314) #448 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #449 0x000add34 in expression_tree_mutator (clauses.c:2314) #450 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #451 0x000add34 in expression_tree_mutator (clauses.c:2314) #452 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #453 0x000add34 in expression_tree_mutator (clauses.c:2314) #454 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #455 0x000add34 in expression_tree_mutator (clauses.c:2314) #456 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #457 0x000add34 in expression_tree_mutator (clauses.c:2314) #458 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #459 0x000add34 in expression_tree_mutator (clauses.c:2314) #460 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #461 0x000add34 in expression_tree_mutator (clauses.c:2314) #462 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #463 0x000add34 in expression_tree_mutator (clauses.c:2314) #464 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #465 0x000add34 in expression_tree_mutator (clauses.c:2314) #466 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #467 0x000add34 in expression_tree_mutator (clauses.c:2314) #468 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #469 0x000add34 in expression_tree_mutator (clauses.c:2314) #470 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #471 0x000add34 in expression_tree_mutator (clauses.c:2314) #472 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #473 0x000add34 in expression_tree_mutator (clauses.c:2314) #474 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #475 0x000add34 in expression_tree_mutator (clauses.c:2314) #476 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #477 0x000add34 in expression_tree_mutator (clauses.c:2314) #478 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #479 0x000add34 in expression_tree_mutator (clauses.c:2314) #480 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #481 0x000add34 in expression_tree_mutator (clauses.c:2314) #482 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #483 0x000add34 in expression_tree_mutator (clauses.c:2314) #484 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #485 0x000add34 in expression_tree_mutator (clauses.c:2314) #486 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #487 0x000add34 in expression_tree_mutator (clauses.c:2314) #488 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #489 0x000add34 in expression_tree_mutator (clauses.c:2314) #490 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #491 0x000add34 in expression_tree_mutator (clauses.c:2314) #492 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #493 0x000add34 in expression_tree_mutator (clauses.c:2314) #494 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #495 0x000add34 in expression_tree_mutator (clauses.c:2314) #496 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #497 0x000add34 in expression_tree_mutator (clauses.c:2314) #498 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #499 0x000add34 in expression_tree_mutator (clauses.c:2314) #500 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #501 0x000add34 in expression_tree_mutator (clauses.c:2314) #502 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #503 0x000add34 in expression_tree_mutator (clauses.c:2314) #504 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #505 0x000add34 in expression_tree_mutator (clauses.c:2314) #506 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) #507 0x000add34 in expression_tree_mutator (clauses.c:2314) #508 0x000acbb8 in eval_const_expressions_mutator (clauses.c:1149) PPC Thread State: srr0: 0x000acb88 srr1: 0x0000d930 vrsave: 0x00000000 xer: 0x20000000 lr: 0x000acb80 ctr: 0x000acb70 mq: 0x00000000 r0: 0x000add34 r1: 0xbff80030 r2: 0x24024424 r3: 0x0157ff90 r4: 0x00000000 r5: 0x000001f5 r6: 0x00001f40 r7: 0x0000000c r8: 0x00000000 r9: 0x01202b18 r10: 0x00000000 r11: 0x00000000 r12: 0x000acb70 r13: 0x001a0c30 r14: 0x00afa008 r15: 0xbfffee60 r16: 0x00000002 r17: 0x00000001 r18: 0x001a2dd4 r19: 0x0019e9d0 r20: 0x00000002 r21: 0x001a6f84 r22: 0x00000000 r23: 0x00000000 r24: 0x001a6f84 r25: 0x00000000 r26: 0x000acb70 r27: 0x00000000 r28: 0x0157ff90 r29: 0x01581130 r30: 0x00000000 r31: 0x000acb80 --------------070800090800020601030107-- From pgsql-performance-owner@postgresql.org Sat Apr 12 16:53:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4553C4762EF for ; Sat, 12 Apr 2003 16:53:43 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 886334762E1 for ; Sat, 12 Apr 2003 16:53:42 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3CKrN2L019652; Sat, 12 Apr 2003 16:53:23 -0400 (EDT) To: shane hill Cc: pgsql-performance Subject: Re: update query blows out In-reply-to: <3E98579F.8040904@adobe.com> References: <564664787.20030410102049@procedium.com> <3E98498C.80306@adobe.com> <18800.1050167784@sss.pgh.pa.us> <3E98579F.8040904@adobe.com> Comments: In-reply-to shane hill message dated "Sat, 12 Apr 2003 11:14:55 -0700" Date: Sat, 12 Apr 2003 16:53:23 -0400 Message-ID: <19651.1050180803@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/127 X-Sequence-Number: 1633 shane hill writes: > I am having a problem with an update transaction. I need to update 4000+ > records but the update query keeps blowing out postgres and at times I > am forced to restart the postmaster or reboot my server if I update > 2500+ records. The query is fine with 2225 records it is just somewhere > beyond 2225 that brings the server down. > [ core dump in heavily-recursive routine ] I think you are running into a stack-size problem. A quick look at "ulimit -a" on my own OS X machine shows that the default stack limit is a mere 512KB, which is verging on the ridiculously small :-(. Try setting "ulimit -s 10000" or so in the script that launches the postmaster. Now that I look at it, the -d setting is on the miserly side as well ... regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 13 21:45:06 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A64734760E3 for ; Sun, 13 Apr 2003 21:45:04 -0400 (EDT) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id ED07047580B for ; Sun, 13 Apr 2003 21:45:03 -0400 (EDT) Received: (qmail 19493 invoked by uid 500); 14 Apr 2003 01:45:47 -0000 Date: Sun, 13 Apr 2003 20:45:47 -0500 From: Bruno Wolff III To: pgsql-performance@postgresql.org Subject: Multicolumn indexes and equal conditions Message-ID: <20030414014547.GA19450@wolff.to> Mail-Followup-To: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/128 X-Sequence-Number: 1634 I noticed that when a multicolumn index exists it isn't necessarily fully used when the first column is constrained by an equals condition. However by adding a redundant sort condition you can get both columns used. In the following examples crate has an index on gameid and areaid. The examples below are for 7.4 development, but 7.3.2 behaves similarly. explain analyze select areaid from crate where gameid = 'TTN' order by areaid; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Sort (cost=132.93..133.02 rows=36 width=11) (actual time=5.44..5.57 rows=287 loops=1) Sort Key: areaid -> Index Scan using crate_game on crate (cost=0.00..132.00 rows=36 width=11) (actual time=0.06..1.94 rows=287 loops=1) Index Cond: (gameid = 'TTN'::text) Total runtime: 5.81 msec (5 rows) explain analyze select areaid from crate where gameid = 'TTN' order by gameid, areaid; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------- Index Scan using crate_game on crate (cost=0.00..132.00 rows=36 width=18) (actual time=0.08..2.06 rows=287 loops=1) Index Cond: (gameid = 'TTN'::text) Total runtime: 2.51 msec (3 rows) From pgsql-performance-owner@postgresql.org Tue Apr 15 05:47:20 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 35CD2476349 for ; Tue, 15 Apr 2003 05:47:19 -0400 (EDT) Received: from shsis (unknown [211.102.12.252]) by postgresql.org (Postfix) with ESMTP id 28FC4474E44 for ; Tue, 15 Apr 2003 05:46:55 -0400 (EDT) Received: from linweidong (localhost [127.0.0.1]) by shsis.sis.sh.cn (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTPA id <0HDD00MKCPSXWX@shsis.sis.sh.cn> for pgsql-performance@postgresql.org; Tue, 15 Apr 2003 17:46:09 +0800 (CST) Date: Tue, 15 Apr 2003 17:44:44 +0800 From: linweidong Subject: for help! To: pgsql-performance@postgresql.org Message-id: <000901c30333$a52b7550$3c10a9c0@jinrong.sis.sh.cn> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Mailer: Microsoft Outlook Express 6.00.2800.1106 Content-type: multipart/alternative; boundary="Boundary_(ID_Ey6rZIIpjMasACNrZ7e5XQ)" X-Priority: 3 X-MSMail-priority: Normal X-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_20,HTML_60_70,RCVD_IN_OSIRUSOFT_COM,SATISFACTION version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/129 X-Sequence-Number: 1635 This is a multi-part message in MIME format. --Boundary_(ID_Ey6rZIIpjMasACNrZ7e5XQ) Content-type: text/plain; charset=iso-2022-jp Content-transfer-encoding: 7BIT Hi, I am writing to you to discuss the performance problem of postgreSQL database we encountered in our project. I want to get suggestions from you. The postgreSQL database we used need to process several millions records. There are only six tables in the database. one of them contains several million records, the Others are less smaller. We need select more than 100 thousands records from the talbe which contains several million records in 10 seconds. In the process of selecting, the speed of selecting is not stable. Sometimes it cost 2 minutes , but sometimes 20 seconds. After analyzing the time wasting in the process, we found the speed of function Count(*) is very slow. At the same time we have finished the setup of some parameters like max_fsm_relation, max_fsm_pages, share memory size etc, but the performance is not improved satisfied. Under this condition, I want get some useful suggestion from you. How to optimize the database? How to improve the Count(*)? Because we want to get the number of records in the recordset we got. Thank you every much! I hope hear from you soon. Wind 2003-4-15 --Boundary_(ID_Ey6rZIIpjMasACNrZ7e5XQ) Content-type: text/html; charset=iso-2022-jp Content-transfer-encoding: 7BIT

Hi,

 

 I am writing to you to discuss the performance problem of postgreSQL database we encountered in our project. I  want to get suggestions from you.

 

The postgreSQL database we used need to process several millions records. There are only six tables in the database. one of them contains several million records, the  Others are less smaller. We need select more than 100 thousands records from the talbe which contains several million records in 10 seconds.  In the process of selecting, the speed of selecting is not stable. Sometimes it cost 2 minutes , but sometimes 20 seconds. After analyzing the time wasting in the process, we found the speed of  function Count(*) is very slow. At the same time we have finished the setup of some parameters like max_fsm_relation, max_fsm_pages, share memory size etc, but the performance is not improved satisfied.

 

Under this condition, I want get some useful suggestion from you. How to optimize the database?  How to improve the Count(*)? Because we  want to get the number of records in the recordset  we got.

 

Thank you every much! I hope hear from you soon.

                                                                                                 Wind

                                                                                                      2003-4-15

--Boundary_(ID_Ey6rZIIpjMasACNrZ7e5XQ)-- From pgsql-performance-owner@postgresql.org Tue Apr 15 05:54:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9E4B847633C for ; Tue, 15 Apr 2003 05:54:06 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 9C3F0475F1C for ; Tue, 15 Apr 2003 05:54:04 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h3F9s6J20564 for ; Tue, 15 Apr 2003 15:24:06 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h3F9s5220559 for ; Tue, 15 Apr 2003 15:24:05 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: Re: for help! Date: Tue, 15 Apr 2003 15:24:11 +0530 User-Agent: KMail/1.5 References: <000901c30333$a52b7550$3c10a9c0@jinrong.sis.sh.cn> In-Reply-To: <000901c30333$a52b7550$3c10a9c0@jinrong.sis.sh.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304151524.11721.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-31.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SATISFACTION,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/130 X-Sequence-Number: 1636 On Tuesday 15 April 2003 15:14, you wrote: > The postgreSQL database we used need to process several millions records. > There are only six tables in the database. one of them contains several > million records, the Others are less smaller. We need select more than 100 > thousands records from the talbe which contains several million records in > 10 seconds. In the process of selecting, the speed of selecting is not > stable. Sometimes it cost 2 minutes , but sometimes 20 seconds. After > analyzing the time wasting in the process, we found the speed of function > Count(*) is very slow. At the same time we have finished the setup of some > parameters like max_fsm_relation, max_fsm_pages, share memory size etc, but > the performance is not improved satisfied. Why do you need to do select count(*) to select more than 100 thousand records? Postgresql being MVCC database, select count(*) is not going to be anywhere near good, especially if you have transactions occuring on table. As far as just selecting rows from table, that should be tad fast if there are proper indexes, table in analyzed every now and then and there are enough shared buffers. If you post your queries and table schemas, that would be much helpful. Your tweaked settings in postgresql.conf and hardware spec. would be good as well. > Under this condition, I want get some useful suggestion from you. How to > optimize the database? How to improve the Count(*)? Because we want to > get the number of records in the recordset we got. If you are using say libpq, you don't need to issue a select count(*) where foo and select where foo, to obtain record count and the records themselves. I believe every other interface stemming from libpq should provide any such hooks as well. Never used any other myself (barring ecpg) HTH Shridhar From pgsql-general-owner@postgresql.org Tue Apr 15 10:23:45 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8DBDE474E44; Tue, 15 Apr 2003 10:23:42 -0400 (EDT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id AB4F34758F1; Tue, 15 Apr 2003 10:23:37 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id h3FENUf06986; Tue, 15 Apr 2003 10:23:30 -0400 (EDT) From: Bruce Momjian Message-Id: <200304151423.h3FENUf06986@candle.pha.pa.us> Subject: Re: [PERFORM] Yet Another (Simple) Case of Index not used In-Reply-To: <3E93348C.20208@cvc.net> To: gearond@cvc.net Date: Tue, 15 Apr 2003 10:23:30 -0400 (EDT) Cc: Dann Corbit , Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/886 X-Sequence-Number: 40951 Dennis Gearon wrote: > from mysql manual: > ------------------------------------------------------------- > "COUNT(*) is optimized to return very quickly if the SELECT retrieves from one > table, no other columns are retrieved, and there is no WHERE clause. For example: > > mysql> select COUNT(*) from student;" > ------------------------------------------------------------- > > A nice little optimization, maybe not possible in a MVCC system. I think the only thing you can do with MVCC is to cache the value and tranaction id for "SELECT AGG(*) FROM tab" and make the cached value visible to transaction id's greater than the one that executed the query, and invalidate the cache every time the table is modified. In fact, don't clear the cache, just record the transaction id of the table modification command so we can use standard visibility routines to make the cache usable as long as possiible. The cleanest way would probably be to create an aggregate cache system table, and to insert into it when someone does an unqualified aggregate, and to delete from it when someone modifies the table --- the MVCC tuple visibility rules are handled automatically. Queries can look in there to see if a visible cached value already exists. Of course, the big question is whether this would be a big win, and whether the cost of upkeep would justify 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 Tue Apr 15 11:40:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 58523475A80 for ; Tue, 15 Apr 2003 11:40:03 -0400 (EDT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by postgresql.org (Postfix) with ESMTP id DB5A3474E44 for ; Tue, 15 Apr 2003 11:40:01 -0400 (EDT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Tue, 15 Apr 2003 10:40:11 -0500 Subject: Re: for help! From: Will LaShell To: Shridhar Daithankar Cc: pgsql-performance@postgresql.org In-Reply-To: <200304151524.11721.shridhar_daithankar@nospam.persistent.co.in> References: <000901c30333$a52b7550$3c10a9c0@jinrong.sis.sh.cn> <200304151524.11721.shridhar_daithankar@nospam.persistent.co.in> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-UbhYXUzDSQc081K5WCyV" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 15 Apr 2003 08:40:05 -0700 Message-Id: <1050421206.25390.16.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Spam-Status: No, hits=-28.1 required=5.0 tests=BAYES_10,IN_REP_TO,PGP_SIGNATURE_2,REFERENCES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/132 X-Sequence-Number: 1638 --=-UbhYXUzDSQc081K5WCyV Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > > Under this condition, I want get some useful suggestion from you. How to > > optimize the database? How to improve the Count(*)? Because we want to > > get the number of records in the recordset we got. >=20 > If you are using say libpq, you don't need to issue a select count(*) whe= re=20 > foo and select where foo, to obtain record count and the records themselv= es.=20 > I believe every other interface stemming from libpq should provide any su= ch=20 > hooks as well. Never used any other myself (barring ecpg) The python interfaces most definitely do. Doing the count is quite unnecessary just as Shridhar points out. > HTH >=20 > Shridhar >=20 --=-UbhYXUzDSQc081K5WCyV 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+nCfVZr3R5kgOZd0RAvZ6AJ9+P+AyG5dHJOgeqZiFlMdcHoJcMgCgiFjf ofi+x2dMuVC+Fjr+5qCctw4= =T1tv -----END PGP SIGNATURE----- --=-UbhYXUzDSQc081K5WCyV-- From pgsql-performance-owner@postgresql.org Tue Apr 15 11:49:17 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 02256475A80 for ; Tue, 15 Apr 2003 11:49:16 -0400 (EDT) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id C3B77474E44 for ; Tue, 15 Apr 2003 11:49:14 -0400 (EDT) Received: (qmail 13965 invoked from network); 15 Apr 2003 15:49:18 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 15 Apr 2003 15:49:18 -0000 From: "Robert John Shepherd" To: Subject: Do Views offer any performance advantage? Date: Tue, 15 Apr 2003 16:49:18 +0100 Message-ID: <001f01c30366$93427720$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-1.6 required=5.0 tests=BAYES_30 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/133 X-Sequence-Number: 1639 Hi all, Whilst I often use views for convenience, is there any performance advantage at all in using a view rather than running the same query directly on the tables themselves? Is it quicker to run a full complex query rather than run a much simpler query on a view? (Hope that makes sense) Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-general-owner@postgresql.org Tue Apr 15 12:29:39 2003 X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 017F5476237; Tue, 15 Apr 2003 12:29:38 -0400 (EDT) Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by postgresql.org (Postfix) with ESMTP id 0F39F4758F1; Tue, 15 Apr 2003 12:29:37 -0400 (EDT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) id 195TJV-0005Iu-0W; Tue, 15 Apr 2003 17:29:41 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 1198B176C4; Tue, 15 Apr 2003 17:29:40 +0100 (BST) Received: from client.archonet.com (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with ESMTP id 6BAFB176BB; Tue, 15 Apr 2003 17:29:39 +0100 (BST) Content-Type: text/plain; charset="iso-8859-1" From: Richard Huxton Organization: Archonet Ltd To: Bruce Momjian , gearond@cvc.net Subject: Re: [PERFORM] Yet Another (Simple) Case of Index not used Date: Tue, 15 Apr 2003 17:29:45 +0100 User-Agent: KMail/1.4.3 Cc: Dann Corbit , Denis , pgsql-performance@postgresql.org, pgsql-general@postgresql.org, pgsql-sql@postgresql.org References: <200304151423.h3FENUf06986@candle.pha.pa.us> In-Reply-To: <200304151423.h3FENUf06986@candle.pha.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304151729.45657.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/893 X-Sequence-Number: 40958 On Tuesday 15 Apr 2003 3:23 pm, Bruce Momjian wrote: > Dennis Gearon wrote: > > from mysql manual: > > ------------------------------------------------------------- > > "COUNT(*) is optimized to return very quickly if the SELECT retrieves > > from one table, no other columns are retrieved, and there is no WHERE > > clause. For example: > > > > mysql> select COUNT(*) from student;" > > ------------------------------------------------------------- > The cleanest way would probably be to create an aggregate cache system > table, and to insert into it when someone does an unqualified aggregate, > and to delete from it when someone modifies the table --- the MVCC tuple > visibility rules are handled automatically. Queries can look in there > to see if a visible cached value already exists. Of course, the big > question is whether this would be a big win, and whether the cost of > upkeep would justify it. If the rule system could handle something like: CREATE RULE quick_foo_count AS ON SELECT count(*) FROM foo=20 DO INSTEAD SELECT quick_count FROM agg_cache WHERE tbl_name=3D'foo'; The whole thing could be handled by user-space triggers/rules and still=20 invisible to the end-user. --=20 Richard Huxton From pgsql-performance-owner@postgresql.org Tue Apr 15 12:39:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 055D8474E44 for ; Tue, 15 Apr 2003 12:39:21 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 4E82D476348 for ; Tue, 15 Apr 2003 12:39:19 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3FGd1lo006538; Tue, 15 Apr 2003 10:39:02 -0600 (MDT) Date: Tue, 15 Apr 2003 10:34:21 -0600 (MDT) From: "scott.marlowe" To: linweidong Cc: Subject: Re: for help! In-Reply-To: <000901c30333$a52b7550$3c10a9c0@jinrong.sis.sh.cn> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/135 X-Sequence-Number: 1641 On Tue, 15 Apr 2003, linweidong wrote: > Under this condition, I want get some useful suggestion from you. How to > optimize the database? How to improve the Count(*)? Because we want to get > the number of records in the recordset we got. Well, you can always use the trick of putting an on insert / delete trigger on the table that maintains a single row table with the current count. That way, whenever a row is added or removed, the count is updated. this will slow down inserts and deletes a little, but TANSTAAFL. From pgsql-performance-owner@postgresql.org Tue Apr 15 13:26:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B394F476347 for ; Tue, 15 Apr 2003 13:26:24 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D5CBB476342 for ; Tue, 15 Apr 2003 13:26:23 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3FHQNU6008833; Tue, 15 Apr 2003 13:26:23 -0400 (EDT) To: "Robert John Shepherd" Cc: pgsql-performance@postgresql.org Subject: Re: Do Views offer any performance advantage? In-reply-to: <001f01c30366$93427720$f3b0313e@LAIKA> References: <001f01c30366$93427720$f3b0313e@LAIKA> Comments: In-reply-to "Robert John Shepherd" message dated "Tue, 15 Apr 2003 16:49:18 +0100" Date: Tue, 15 Apr 2003 13:26:23 -0400 Message-ID: <8832.1050427583@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/136 X-Sequence-Number: 1642 "Robert John Shepherd" writes: > Whilst I often use views for convenience, is there any performance > advantage at all in using a view rather than running the same query > directly on the tables themselves? No, a view is just a macro. There is probably some minuscule cost difference involved --- you save parsing and parse analysis of a long query string. On the other hand, you pay to pull the view definition from the catalogs and merge it into the given query. I'd not care to hazard a guess on whether the actual net cost is more or less; but in any case these costs will be swamped by query planning and execution, if the query is complex. If you're concerned about reducing parse/plan overhead for repetitive queries, the prepared-statement facility (new in 7.3) is what to look at. Views won't do much for you. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 15 15:05:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BC9F147633C for ; Tue, 15 Apr 2003 15:05:20 -0400 (EDT) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id 02512476333 for ; Tue, 15 Apr 2003 15:05:20 -0400 (EDT) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id BB74513832C; Tue, 15 Apr 2003 15:04:14 -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 195Viw-0005Er-00; Tue, 15 Apr 2003 15:04:06 -0400 To: pgsql-performance@postgresql.org Subject: Using indexes for like foo% type queries when foo isn't constant (not a locale issue) From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 15 Apr 2003 15:04:04 -0400 Message-ID: <87of37oa57.fsf@stark.dyndns.tv> Lines: 41 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-12.9 required=5.0 tests=BAYES_01,USER_AGENT_GNUS_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/137 X-Sequence-Number: 1643 In the following query postgres doesn't use the index. In the hard-coded version below it does. I suppose it can't because it's possible the "target" could have wildcards etc in them. Is there any way to indicate the postgres that that won't happen? This is going to be even more of an issue when preparsed queries happen because even in the hard coded example it will be an issue. I know in Oracle if you parse a query with a LIKE :1||'%' type expression it still plans to use the index and that's extremely useful. I don't know what it does if there's a % in the parameter, it either takes the performance hit or it doesn't treat them as special? db=> explain analyze select postalcode, abs(substr(target,6,1)::integer-substr(postalcode,6,1)::integer) as dist from postalcodes, (select 'L6C2M6'::text as target) as t where postalcode like substr(target,1,5)||'%' order by dist asc limit 2; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=12182.77..12182.77 rows=2 width=42) (actual time=9226.17..9226.18 rows=2 loops=1) -> Sort (cost=12182.77..12186.16 rows=1359 width=42) (actual time=9226.16..9226.16 rows=2 loops=1) Sort Key: abs(((substr(t.target, 6, 1))::integer - (substr((postalcodes.postalcode)::text, 6, 1))::integer)) -> Nested Loop (cost=0.00..12112.04 rows=1359 width=42) (actual time=3262.89..9205.25 rows=8 loops=1) Join Filter: ("inner".postalcode ~~ (substr("outer".target, 1, 5) || '%'::text)) -> Subquery Scan t (cost=0.00..0.01 rows=1 width=0) (actual time=0.04..0.05 rows=1 loops=1) -> Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.02..0.02 rows=1 loops=1) -> Seq Scan on postalcodes (cost=0.00..7335.69 rows=271769 width=10) (actual time=5.52..3268.74 rows=271769 loops=1) Total runtime: 9241.92 msec (9 rows) db=> explain analyze select postalcode, abs(substr('L6C2M6',6,1)::integer-substr(postalcode,6,1)::integer) as dist from postalcodes where postalcode like substr('L6C2M6',1,5)||'%' order by dist asc limit 2; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=3.29..3.29 rows=1 width=10) (actual time=36.54..36.55 rows=2 loops=1) -> Sort (cost=3.29..3.29 rows=1 width=10) (actual time=36.53..36.54 rows=2 loops=1) Sort Key: abs((6 - (substr((postalcode)::text, 6, 1))::integer)) -> Index Scan using idx_postalcodes_postalcodeon on postalcodes (cost=0.00..3.28 rows=1 width=10) (actual time=35.91..36.33 rows=8 loops=1) Index Cond: ((postalcode >= 'L6C2M'::bpchar) AND (postalcode < 'L6C2N'::bpchar)) Filter: (postalcode ~~ 'L6C2M%'::text) Total runtime: 36.93 msec (7 rows) -- greg From pgsql-performance-owner@postgresql.org Tue Apr 15 15:55:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD3D847633C for ; Tue, 15 Apr 2003 15:55:13 -0400 (EDT) Received: from smtp.web.de (smtp02.web.de [217.72.192.151]) by postgresql.org (Postfix) with ESMTP id DFF29474E44 for ; Tue, 15 Apr 2003 15:55:08 -0400 (EDT) Received: from p508188a2.dip0.t-ipconnect.de ([80.129.136.162] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 195WWH-0000Sl-00 for pgsql-performance@postgresql.org; Tue, 15 Apr 2003 21:55:05 +0200 Message-ID: <3E9C63A8.4040801@web.de> Date: Tue, 15 Apr 2003 21:55:20 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Do Views offer any performance advantage? References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us> In-Reply-To: <8832.1050427583@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_NJABL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/138 X-Sequence-Number: 1644 Tom Lane wrote: > >There is probably some minuscule cost difference involved --- you save >parsing and parse analysis of a long query string. On the other hand, >you pay to pull the view definition from the catalogs and merge it into >the given query. I'd not care to hazard a guess on whether the actual >net cost is more or less; but in any case these costs will be swamped >by query planning and execution, if the query is complex. > Actually, there are cases when a view can impact performance. If you are joining a view, it seems to be treated as a subquery, that might have a much larger result than you would like. Imagine SELECT something FROM A JOIN B JOIN C ... WHERE A.primaryKeyFoo=1234 ... where C is a view, containing JOINs itself, I observed a query plan (7.3.2) like A JOIN B JOIN (D JOIN E) instead of A JOIN B JOIN D JOIN E which would be much more efficient for the A.primaryKeyFoo restriction. From pgsql-performance-owner@postgresql.org Tue Apr 15 19:37:05 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9DD65475458 for ; Tue, 15 Apr 2003 19:37:04 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 036AA474E44 for ; Tue, 15 Apr 2003 19:37:04 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3FNb6U6011036; Tue, 15 Apr 2003 19:37:06 -0400 (EDT) To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: Do Views offer any performance advantage? In-reply-to: <3E9C63A8.4040801@web.de> References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us> <3E9C63A8.4040801@web.de> Comments: In-reply-to Andreas Pflug message dated "Tue, 15 Apr 2003 21:55:20 +0200" Date: Tue, 15 Apr 2003 19:37:06 -0400 Message-ID: <11035.1050449826@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/139 X-Sequence-Number: 1645 Andreas Pflug writes: > Actually, there are cases when a view can impact performance. > If you are joining a view, it seems to be treated as a subquery, that > might have a much larger result than you would like. > Imagine > SELECT something > FROM A JOIN B JOIN C ... > WHERE A.primaryKeyFoo=1234 ... > where C is a view, containing JOINs itself, I observed a query plan > (7.3.2) like > A JOIN B JOIN (D JOIN E) > instead of > A JOIN B JOIN D JOIN E which would be much more efficient for the > A.primaryKeyFoo restriction. This is not the view's fault though --- the same would have happened if you'd written explicitly FROM A JOIN B JOIN (D JOIN E) 7.4 will be less rigid about this (with or without a view ...) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 16 02:10:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 56600475A45 for ; Wed, 16 Apr 2003 02:10:44 -0400 (EDT) Received: from smtp.kocks.com (adsl-66-124-90-234.dsl.snfc21.pacbell.net [66.124.90.234]) by postgresql.org (Postfix) with ESMTP id 88D8447592C for ; Wed, 16 Apr 2003 02:10:43 -0400 (EDT) Received: from GARP (fwinside.kocks.com [10.10.10.1]) by smtp.kocks.com (mail) with SMTP id C328A28AC3 for ; Tue, 15 Apr 2003 23:10:43 -0700 (PDT) Reply-To: From: "dex" To: Subject: Is there a performance between Inherits and Views? Date: Tue, 15 Apr 2003 23:10: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.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-7.3 required=5.0 tests=BAYES_30,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/140 X-Sequence-Number: 1646 Hello, In building a schema, I'd like to know if it makes sense from a performance standpoint to use views instead of an object oriented structure (i.e. inherits). I would guess that the overhead of the queries against inherited tables is higher than queries against views, but I don't know. In the cities / capitals example below, I could make queries such as: SELECT name FROM capitals; or SELECT name FROM capital_cities; But which one would be faster? In my real world example, I will have one small base object table (i.e. cities in the example) and many direct descendents of that base table (e.g. capitals, beaches, national parks, suburbs in the example). This could be implemented as one small base table and with many tables inheriting from the base. Or, it could be implemented as one larger (but not huge) lookup table with many views. What's the better choice from a performance standpoint? Thanks! --dex -- -- Schema with Inherits -- CREATE TABLE cities ( name text, population float, altitude int -- (in ft) ); CREATE TABLE capitals ( state char(2) ) INHERITS (cities); -- -- Schema with View -- CREATE TABLE all_cities ( name text, population float, altitude int, state char(2) ); CREATE VIEW just_cities AS SELECT all_cities.name, all_cities.population, all_cities.altitude FROM all_cities; -- or perhaps with a where clause, as in CREATE VIEW capital_cities AS SELECT all_cities.name, all_cities.population, all_cities.altitude FROM all_cities WHERE (all_cities.state IS NOT NULL); From pgsql-performance-owner@postgresql.org Wed Apr 16 20:03:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 59E43475EEE for ; Wed, 16 Apr 2003 20:03:08 -0400 (EDT) Received: from spunge-bob.discern.com (moore.discerncomm.com [130.107.25.153]) by postgresql.org (Postfix) with ESMTP id 79792475ECE for ; Wed, 16 Apr 2003 20:03:07 -0400 (EDT) Received: by spunge-bob.discern.com (Postfix, from userid 1000) id 4CA5B27C88; Tue, 15 Apr 2003 23:58:28 -0700 (PDT) Subject: dum query plan From: Jonathan Moore To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.5 Date: 15 Apr 2003 23:58:28 -0700 Message-Id: <1050476308.20872.19.camel@spunge-bob> Mime-Version: 1.0 X-Spam-Status: No, hits=-12.0 required=5.0 tests=BAYES_10,DATE_IN_PAST_12_24,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/147 X-Sequence-Number: 1653 I am wondering why it uses the O(n^2) nested loop when there is a O(N) methoud using btree indexes for a merg join. I am using 7.2.1 would upgrading fix my problime or is it somthing else? Given the schema: drop table Entry_Pairs; create table Entry_Pairs ( left_entry int REFERENCES Entry ON DELETE RESTRICT, right_entry int REFERENCES Entry ON DELETE RESTRICT, relation int NOT NULL , subtract bool NOT NULL , comment int NULL REFERENCES Comment ON DELETE SET NULL, UNIQUE (left_entry, right_entry, relation) ); CREATE INDEX entry_pairs_left_index ON entry_pairs (left_entry); CREATE INDEX entry_pairs_right_index ON entry_pairs (right_entry); -- You get this" dblex=> explain select A.left_entry from entry_pairs A, entry_pairs B where A.right_entry != B.left_entry; NOTICE: QUERY PLAN: Nested Loop (cost=100000000.00..102876671.17 rows=97545252 width=12) -> Seq Scan on entry_pairs a (cost=0.00..167.77 rows=9877 width=8) -> Seq Scan on entry_pairs b (cost=0.00..167.77 rows=9877 width=4) EXPLAIN That is dum. If you just walk both B-Tree indexes there is a O(n) search. I tryed to turn off netsed loops but it still did it. (the reason the cost is 100000000.00 is a artifact from turing off loops) -Jonathan From pgsql-performance-owner@postgresql.org Wed Apr 16 04:45:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EF2904758F1 for ; Wed, 16 Apr 2003 04:45:41 -0400 (EDT) Received: from smtp.web.de (smtp01.web.de [217.72.192.180]) by postgresql.org (Postfix) with ESMTP id 89CD8475458 for ; Wed, 16 Apr 2003 04:45:10 -0400 (EDT) Received: from p50818648.dip0.t-ipconnect.de ([80.129.134.72] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 195iXQ-0002uG-00; Wed, 16 Apr 2003 10:45:04 +0200 Message-ID: <3E9D1820.6000100@web.de> Date: Wed, 16 Apr 2003 10:45:20 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane , pgsql-performance@postgresql.org Subject: Re: Do Views offer any performance advantage? References: <001f01c30366$93427720$f3b0313e@LAIKA> <8832.1050427583@sss.pgh.pa.us> <3E9C63A8.4040801@web.de> <11035.1050449826@sss.pgh.pa.us> In-Reply-To: <11035.1050449826@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_NJABL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/141 X-Sequence-Number: 1647 Tom Lane wrote: >This is not the view's fault though --- the same would have happened >if you'd written explicitly > > FROM A JOIN B JOIN (D JOIN E) > That's right, I just wanted to warn about accessive use of joins with views. I noticed this in an application, where quite big views where joined for convenience, and the result wasn't satisfying. > >7.4 will be less rigid about this (with or without a view ...) > Good! Regards, Andreas From pgsql-performance-owner@postgresql.org Wed Apr 16 11:48:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 64D96475C3D for ; Wed, 16 Apr 2003 11:48:52 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 9118F475C15 for ; Wed, 16 Apr 2003 11:48:51 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2967362; Wed, 16 Apr 2003 08:48:49 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "scott.marlowe" , linweidong Subject: Re: for help! Date: Wed, 16 Apr 2003 08:48:36 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200304160848.36431.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/142 X-Sequence-Number: 1648 Scott, > Well, you can always use the trick of putting an on insert / delete > trigger on the table that maintains a single row table with the current > count. That way, whenever a row is added or removed, the count is > updated. this will slow down inserts and deletes a little, but TANSTAAFL. BTW, I tested this for a client. I found the performance penalty on inser= ts=20 and updates to be: -- For a single stream of intermittent updates from a single connection on an adequately powered server with moderate disk support (IDE Linux RA= ID) (100 inserts/updates per minute, with VACUUM every 5 minutes) PL/pgSQL Trigger: 20% penalty C Trigger: 9-11% penalty -- For 5 streams of inserts and updates at high volume on an overloaded server with moderate disk support (dual fast SCSI disks) (1000 inserts/updates per minute, vacuum every 5 minutes) PL/pgSQL Trigger: 65% penalty C Trigger: 40% penalty Please note that the effective performance penalty on inserts and updates w= as=20 dramatically higher for large batches of updates than for small ones. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 16 11:53:15 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E2CF6476304 for ; Wed, 16 Apr 2003 11:53:12 -0400 (EDT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 2674F476302 for ; Wed, 16 Apr 2003 11:53:07 -0400 (EDT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 195pDk-0002Ot-00 for ; Wed, 16 Apr 2003 11:53:12 -0400 Received: by dba2 (Postfix, from userid 1019) id 60732CF00; Wed, 16 Apr 2003 11:53:12 -0400 (EDT) Date: Wed, 16 Apr 2003 11:53:12 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: for help! Message-ID: <20030416155312.GF19999@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200304160848.36431.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200304160848.36431.josh@agliodbs.com> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/143 X-Sequence-Number: 1649 On Wed, Apr 16, 2003 at 08:48:36AM -0700, Josh Berkus wrote: > Scott, > > > Well, you can always use the trick of putting an on insert / delete > > trigger on the table that maintains a single row table with the current > > count. That way, whenever a row is added or removed, the count is > BTW, I tested this for a client. I found the performance penalty > on inserts and updates to be: [. . .] > Please note that the effective performance penalty on inserts and > updates was dramatically higher for large batches of updates than > for small ones. Presumably the problem was to do with contention? This is why I don't really like the "update one row" approach for this sort of thing. But you _could_ write a trigger which inserts into a "staging" table, and write a little daemon which only updates the count table with the data from the staging table. It's a mighty ugly hack, but it ought to work. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Apr 16 12:01:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B3D11475A45 for ; Wed, 16 Apr 2003 12:01:52 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id F24CE475458 for ; Wed, 16 Apr 2003 12:01:51 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3GG1uU6018665; Wed, 16 Apr 2003 12:01:56 -0400 (EDT) To: Andrew Sullivan Cc: pgsql-performance@postgresql.org Subject: Re: for help! In-reply-to: <20030416155312.GF19999@libertyrms.info> References: <200304160848.36431.josh@agliodbs.com> <20030416155312.GF19999@libertyrms.info> Comments: In-reply-to Andrew Sullivan message dated "Wed, 16 Apr 2003 11:53:12 -0400" Date: Wed, 16 Apr 2003 12:01:56 -0400 Message-ID: <18664.1050508916@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/144 X-Sequence-Number: 1650 Andrew Sullivan writes: > But you _could_ write a trigger which inserts into a "staging" table, > and write a little daemon which only updates the count table with the > data from the staging table. It's a mighty ugly hack, but it ought > to work. The $64 question with this sort of thing is "how accurate (up-to-date) does the count have to be?". Given that Josh is willing to vacuum every five minutes, he might find that returning pg_class.reltuples is Close Enough (TM). regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 16 12:12:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6857F475458 for ; Wed, 16 Apr 2003 12:12:24 -0400 (EDT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 52211475458 for ; Wed, 16 Apr 2003 12:11:53 -0400 (EDT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 195pVu-0002gN-00 for ; Wed, 16 Apr 2003 12:11:58 -0400 Received: by dba2 (Postfix, from userid 1019) id C9F36CF00; Wed, 16 Apr 2003 12:11:58 -0400 (EDT) Date: Wed, 16 Apr 2003 12:11:58 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: for help! Message-ID: <20030416161158.GH19999@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200304160848.36431.josh@agliodbs.com> <20030416155312.GF19999@libertyrms.info> <18664.1050508916@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18664.1050508916@sss.pgh.pa.us> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/145 X-Sequence-Number: 1651 On Wed, Apr 16, 2003 at 12:01:56PM -0400, Tom Lane wrote: > Given that Josh is willing to vacuum every five minutes, he might find > that returning pg_class.reltuples is Close Enough (TM). Certainly, it's not going to be any farther off than the staging-table+real-table approach, anyway. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Wed Apr 16 12:26:59 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C976A47636F for ; Wed, 16 Apr 2003 12:26:58 -0400 (EDT) Received: from mail2.mediadesign.nl (md2.mediadesign.nl [212.19.205.67]) by postgresql.org (Postfix) with SMTP id CC56547633C for ; Wed, 16 Apr 2003 12:26:53 -0400 (EDT) Received: (qmail 5909 invoked by uid 666); 16 Apr 2003 16:26:58 -0000 Date: Wed, 16 Apr 2003 18:26:58 +0200 From: Vincent van Leeuwen To: pgsql-performance@postgresql.org Subject: the RAID question, again Message-ID: <20030416162657.GK1836@md2.mediadesign.nl> Mail-Followup-To: pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam-Status: No, hits=-12.1 required=5.0 tests=BAYES_10,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/146 X-Sequence-Number: 1652 Hi, I want to ask the 'which RAID setup is best for PostgreSQL?' question again. I've read a large portion of the archives of this list, but generally the answer is 'depends on your needs' with a few different camps. My needs are as follows: dedicated PostgreSQL server for a website, which does much more select queries than insert/updates (although, due to a lot of caching outside the database, we will be doing more updates than usual for a website). The machine which will be built for this is going to be something like a dual Xeon 2.4GHz, 4GB RAM, and a SCSI hardware RAID controller with some cache RAM and 6-7 36GB 15K rpm disks. We have good experiences with ICP Vortex controllers, so I'll probably end up buying on of those again (the GDT8514RZ looks nice: http://www.icp-vortex.com/english/product/pci/rzu320/8514rz_e.htm ) We normally use Debian linux with a 2.4 kernel, but we're thinking we might play around with FreeBSD and see how that runs before making the final choice. The RAID setup I have in my head is as follows: 4 disks for a RAID 10 array, for the PG data area 2 disks for a RAID 1 array, for the OS, swap (it won't swap) and, most importantly, WAL files 1 disk for hot spare RAID 1 isn't ideal for a WAL disks because of the (small) write penalty, but I'm not sure I want to risk losing the WAL files. As far as I know PG doesn't really like losing them :) This array shouldn't see much I/O outside of the WAL files, since the OS and PG itself should be completely in RAM when it's started up. RAID 5 is more cost-effective for the data storage, but write-performance is much lower than RAID 10. The hot-spare is non-negotiable, it has saved my life a number of times ;) Performance and reliability are the prime concerns for this setup. We normally run our boxes at extremely high loads because we don't have the budget we need. Cost is an issue, but since our website is always growing at an insane pace I'd rather drop some cash on a fast server now and hope to hold out till the end of this year than having to rush out and buy another mediocre server in a few months. Am I on the right track or does anyone have any tips I could use? On a side note: this box will be bought a few days or weeks from now and tested during a week or so before we put it in our production environment (if everything goes well). If anyone is interested in any benchmark results from it (possibly even FreeBSD vs Linux :)) that can probably be arranged. Vincent van Leeuwen Media Design - http://www.mediadesign.nl/ From pgsql-performance-owner@postgresql.org Thu Apr 17 11:29:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6DE004758F1 for ; Thu, 17 Apr 2003 11:29:40 -0400 (EDT) Received: from spunge-bob.discern.com (dsl092-251-241.sfo2.dsl.speakeasy.net [66.92.251.241]) by postgresql.org (Postfix) with ESMTP id B6545475458 for ; Thu, 17 Apr 2003 11:29:39 -0400 (EDT) Received: by spunge-bob.discern.com (Postfix, from userid 1000) id E89FD27C88; Wed, 16 Apr 2003 15:02:49 -0700 (PDT) Subject: dum query plan: more info. From: Jonathan Moore To: pgsql-performance@postgresql.org Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.5 Date: 16 Apr 2003 15:02:49 -0700 Message-Id: <1050530569.20873.120.camel@spunge-bob> Mime-Version: 1.0 X-Spam-Status: No, hits=-12.0 required=5.0 tests=BAYES_10,DATE_IN_PAST_12_24,USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/153 X-Sequence-Number: 1659 I now under stand that my join was rong but none of the seguestions are the optimal solution to the problime. You can make this order n if you try. The trick is to use a mearg join using sorted list of the unique keys in each colum join. The question you are asking is what left hand entrys do not exist on the right. select A.left form pairs A, pairs B where A.left != B.right; (note: my code in the first example select left form the rong table but it dosn't change the search.) take the DB: (1,2) (2,1) (1,5) (4,5) (5,2) Sort the colums: left right ==== ===== 1 1 2 2 4 5 5 Start at the top you see that you have 1 in both columes there for you know that 1 is not a answer. pop both colums. same for 2. Whe you get to the top of the lists as 4, 5; you know that 4 apperas on the only in the left colum as you don't see it on the right. pop the left colum. now you see that 5 is on both sides so 5 is not a canadate. You are out of options so you are done 4 is the only value that is on the left and only on the left. This methoud is order O(n) if both colums have b-tree indexes so you don't have to pre sort them othere wise it is O(n*log(n)) as the sort is the greatest complexity. In eathere case it is way better then O(n^2) for almost any n. I have this implmented in my code by selecting each colum and then doing the mearg my self more expensive then a in db join as there is pointless data copys. sudo perl for the hole thing is: #!/usr/bin/not-realy-perl my @left = select distinct left_entry from entry_pairs order by left_entry; my @right = select distinct right_entry from entry_pairs order by right_entry; my @only_left; while (1) { if (not @left) { last; #done } elsif (not @right) { push @only_left, $left[0]; pop @left; } elsif ($left[0] == $right[0]) { pop @left; pop @right; } elsif ($left[0] < $right[0]) { push @only_left, $left[0]; pop @left; } elsif ($left[0] > $right[0]) { pop @right; } } -Jonathan From pgsql-performance-owner@postgresql.org Wed Apr 16 21:21:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E1FFE47610C for ; Wed, 16 Apr 2003 21:21:28 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 225A0475FC8 for ; Wed, 16 Apr 2003 21:21:28 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id DDA3CD616; Wed, 16 Apr 2003 18:21:31 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id D35045C04; Wed, 16 Apr 2003 18:21:31 -0700 (PDT) Date: Wed, 16 Apr 2003 18:21:31 -0700 (PDT) From: Stephan Szabo To: Jonathan Moore Cc: Subject: Re: dum query plan In-Reply-To: <1050476308.20872.19.camel@spunge-bob> Message-ID: <20030416175935.T79767-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/148 X-Sequence-Number: 1654 On 15 Apr 2003, Jonathan Moore wrote: > I am wondering why it uses the O(n^2) nested loop when there is a O(N) > methoud using btree indexes for a merg join. I am using 7.2.1 would > upgrading fix my problime or is it somthing else? > > Given the schema: > > drop table Entry_Pairs; > create table Entry_Pairs ( > left_entry int REFERENCES Entry ON DELETE RESTRICT, > right_entry int REFERENCES Entry ON DELETE RESTRICT, > relation int NOT NULL , > subtract bool NOT NULL , > comment int NULL REFERENCES Comment ON DELETE SET NULL, > UNIQUE (left_entry, right_entry, relation) > ); > CREATE INDEX entry_pairs_left_index ON entry_pairs (left_entry); > CREATE INDEX entry_pairs_right_index ON entry_pairs (right_entry); > -- > > You get this" > > dblex=> explain select A.left_entry from entry_pairs A, entry_pairs B > where A.right_entry != B.left_entry; > NOTICE: QUERY PLAN: > > Nested Loop (cost=100000000.00..102876671.17 rows=97545252 width=12) > -> Seq Scan on entry_pairs a (cost=0.00..167.77 rows=9877 width=8) > -> Seq Scan on entry_pairs b (cost=0.00..167.77 rows=9877 width=4) > > EXPLAIN > > That is dum. If you just walk both B-Tree indexes there is a O(n) > search. I tryed to turn off netsed loops but it still did it. (the > reason the cost is 100000000.00 is a artifact from turing off loops) Can you describe the algorithm you think it should be taking with perhaps a small set of data like say (given only left and right): (1,2) (3,4) (5,6) (I think the query should return 1,1,1,3,3,3,5,5,5 for this case) From pgsql-performance-owner@postgresql.org Wed Apr 16 22:32:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DA574475A45 for ; Wed, 16 Apr 2003 22:32:53 -0400 (EDT) Received: from c001.snv.cp.net (h013.c001.snv.cp.net [209.228.32.127]) by postgresql.org (Postfix) with SMTP id A9ECE475458 for ; Wed, 16 Apr 2003 22:32:52 -0400 (EDT) Received: (cpmta 1682 invoked from network); 16 Apr 2003 19:32:56 -0700 Received: from 209.228.32.120 (HELO mail.dilger.cc.criticalpath.net) by smtp.register-admin.com (209.228.32.127) with SMTP; 16 Apr 2003 19:32:56 -0700 X-Sent: 17 Apr 2003 02:32:56 GMT Received: from [216.68.146.219] by mail.dilger.cc with HTTP; Wed, 16 Apr 2003 19:32:54 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: pgsql.spam@vinz.nl Cc: pgsql-performance@postgresql.org From: "Nikolaus Dilger" Subject: Re: the RAID question, again X-Sent-From: nikolaus@dilger.cc Date: Wed, 16 Apr 2003 19:32:54 -0700 (PDT) X-Mailer: Web Mail 5.3.0-6_sol28 Message-Id: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> X-Spam-Status: No, hits=-12.9 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,QUOTE_TWICE_1 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/149 X-Sequence-Number: 1655 Vincent, In my eyes the best disk I/O configuration is a balance of performance, price and administrative effort. Your set-up looks relatively good. Howver, price seems not to be your greatest concern. Otherwise you would favor RAID 5 and/or leave out the spare disk. One improvement area may be to put all 6 disks into a RAID 10 group. That way you have more I/O bandwith. One watchout is that the main memory of your machine may be better than the one of your RAID controller. The RAID controller has Integrated 128MB PC133 ECC SDRAM. You did not state what kind of memory your server has. Regards, Nikolaus On Wed, 16 Apr 2003 18:26:58 +0200, Vincent van Leeuwen wrote: > > Hi, > > I want to ask the 'which RAID setup is best for > PostgreSQL?' question again. > I've read a large portion of the archives of this list, > but generally the > answer is 'depends on your needs' with a few different > camps. > > My needs are as follows: dedicated PostgreSQL server > for a website, which does > much more select queries than insert/updates (although, > due to a lot of > caching outside the database, we will be doing more > updates than usual for a > website). > > The machine which will be built for this is going to be > something like a dual > Xeon 2.4GHz, 4GB RAM, and a SCSI hardware RAID > controller with some cache RAM > and 6-7 36GB 15K rpm disks. We have good experiences > with ICP Vortex > controllers, so I'll probably end up buying on of those > again (the GDT8514RZ > looks nice: > http://www.icp-vortex.com/english/product/pci/rzu320/8514rz_e.htm > ) > > We normally use Debian linux with a 2.4 kernel, but > we're thinking we might > play around with FreeBSD and see how that runs before > making the final choice. > > The RAID setup I have in my head is as follows: > > 4 disks for a RAID 10 array, for the PG data area > 2 disks for a RAID 1 array, for the OS, swap (it won't > swap) and, most > importantly, WAL files > 1 disk for hot spare > > RAID 1 isn't ideal for a WAL disks because of the > (small) write penalty, but > I'm not sure I want to risk losing the WAL files. As > far as I know PG doesn't > really like losing them :) This array shouldn't see > much I/O outside of the > WAL files, since the OS and PG itself should be > completely in RAM when it's > started up. > > RAID 5 is more cost-effective for the data storage, but > write-performance is > much lower than RAID 10. > > The hot-spare is non-negotiable, it has saved my life a > number of times ;) > > Performance and reliability are the prime concerns for > this setup. We normally > run our boxes at extremely high loads because we don't > have the budget we > need. Cost is an issue, but since our website is always > growing at an insane > pace I'd rather drop some cash on a fast server now and > hope to hold out till > the end of this year than having to rush out and buy > another mediocre server > in a few months. > > Am I on the right track or does anyone have any tips I > could use? > > > On a side note: this box will be bought a few days or > weeks from now and > tested during a week or so before we put it in our > production environment (if > everything goes well). If anyone is interested in any > benchmark results from > it (possibly even FreeBSD vs Linux :)) that can > probably be arranged. > > > Vincent van Leeuwen > Media Design - http://www.mediadesign.nl/ > > > ---------------------------(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 Apr 16 23:15:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BCB06475956 for ; Wed, 16 Apr 2003 23:15:42 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id BAAAA475458 for ; Wed, 16 Apr 2003 23:15:38 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3H3FVU6002844; Wed, 16 Apr 2003 23:15:31 -0400 (EDT) To: Jonathan Moore Cc: pgsql-performance@postgresql.org Subject: Re: dum query plan In-reply-to: <1050476308.20872.19.camel@spunge-bob> References: <1050476308.20872.19.camel@spunge-bob> Comments: In-reply-to Jonathan Moore message dated "15 Apr 2003 23:58:28 -0700" Date: Wed, 16 Apr 2003 23:15:31 -0400 Message-ID: <2843.1050549331@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/150 X-Sequence-Number: 1656 Jonathan Moore writes: > I am wondering why it uses the O(n^2) nested loop when there is a O(N) > methoud using btree indexes for a merg join. With an inequality for the WHERE condition? I don't think so. The expected output is of size O(N^2), so how could the algorithm take less than O(N^2) steps? > dblex=> explain select A.left_entry from entry_pairs A, entry_pairs B > where A.right_entry != B.left_entry; regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 16 23:21:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6E025475ECE for ; Wed, 16 Apr 2003 23:21:06 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id B6251475A45 for ; Wed, 16 Apr 2003 23:21:05 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2968753; Wed, 16 Apr 2003 20:21:05 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Nikolaus Dilger" , pgsql.spam@vinz.nl Subject: Re: the RAID question, again Date: Wed, 16 Apr 2003 20:20:50 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> In-Reply-To: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> MIME-Version: 1.0 Message-Id: <200304162020.50103.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-21.9 required=5.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/151 X-Sequence-Number: 1657 Vincent, > One watchout is that the main memory of your machine > may be better than the one of your RAID controller. > The RAID controller has Integrated 128MB PC133 ECC > SDRAM. You did not state what kind of memory your > server has. Nickolaus has a good point. With a high-end Linux server, and a medium-en= d=20 RAID card, it's sometimes faster to use Linux software RAID than harware=20 raid. Not all the time, though. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Thu Apr 17 10:11:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ECAF7475D91 for ; Thu, 17 Apr 2003 10:11:19 -0400 (EDT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id DF6D3475F1B for ; Thu, 17 Apr 2003 10:11:15 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id KAA30572; Thu, 17 Apr 2003 10:11:07 -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 xma030568; Thu, 17 Apr 03 10:11:02 -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 KAA27904; Thu, 17 Apr 2003 10:05:29 -0400 Message-ID: <3E9EB653.B6E200B4@nsd.ca> Date: Thu, 17 Apr 2003 10:12:35 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: Jonathan Moore Cc: pgsql-performance@postgresql.org Subject: Re: dum query plan References: <1050476308.20872.19.camel@spunge-bob> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-30.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/152 X-Sequence-Number: 1658 Your WHERE clause is the reason you get O(N^2). How about describing in words what you want. maybe what you really want is: select left_entry from entry_pairs A where not exists ( select 1 from entry_pairs B where A.right_entry = B.left_entry) JLL Jonathan Moore wrote: > > I am wondering why it uses the O(n^2) nested loop when there is a O(N) > methoud using btree indexes for a merg join. I am using 7.2.1 would > upgrading fix my problime or is it somthing else? > > Given the schema: > > drop table Entry_Pairs; > create table Entry_Pairs ( > left_entry int REFERENCES Entry ON DELETE RESTRICT, > right_entry int REFERENCES Entry ON DELETE RESTRICT, > relation int NOT NULL , > subtract bool NOT NULL , > comment int NULL REFERENCES Comment ON DELETE SET NULL, > UNIQUE (left_entry, right_entry, relation) > ); > CREATE INDEX entry_pairs_left_index ON entry_pairs (left_entry); > CREATE INDEX entry_pairs_right_index ON entry_pairs (right_entry); > -- > > You get this" > > dblex=> explain select A.left_entry from entry_pairs A, entry_pairs B > where A.right_entry != B.left_entry; > NOTICE: QUERY PLAN: > > Nested Loop (cost=100000000.00..102876671.17 rows=97545252 width=12) > -> Seq Scan on entry_pairs a (cost=0.00..167.77 rows=9877 width=8) > -> Seq Scan on entry_pairs b (cost=0.00..167.77 rows=9877 width=4) > > EXPLAIN > > That is dum. If you just walk both B-Tree indexes there is a O(n) > search. I tryed to turn off netsed loops but it still did it. (the > reason the cost is 100000000.00 is a artifact from turing off loops) > > -Jonathan > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org From pgsql-performance-owner@postgresql.org Thu Apr 17 12:28:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A0CAD475C15 for ; Thu, 17 Apr 2003 12:28:31 -0400 (EDT) Received: from email02.aon.at (WARSL401PIP7.highway.telekom.at [195.3.96.94]) by postgresql.org (Postfix) with SMTP id 3034C475C3D for ; Thu, 17 Apr 2003 12:28:22 -0400 (EDT) Received: (qmail 401110 invoked from network); 17 Apr 2003 16:24:24 -0000 Received: from m160p004.dipool.highway.telekom.at (HELO cantor) ([62.46.9.228]) (envelope-sender ) by qmail2rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 17 Apr 2003 16:24:24 -0000 From: Manfred Koizar To: Jonathan Moore Cc: pgsql-performance@postgresql.org Subject: Re: dum query plan: more info. Date: Thu, 17 Apr 2003 18:24:24 +0200 Message-ID: References: <1050530569.20873.120.camel@spunge-bob> In-Reply-To: <1050530569.20873.120.camel@spunge-bob> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-32.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_FORTE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/154 X-Sequence-Number: 1660 On 16 Apr 2003 15:02:49 -0700, Jonathan Moore wrote: >select A.left form pairs A, pairs B where A.left != B.right; > >take the DB: > >(1,2) >(2,1) >(1,5) >(4,5) >(5,2) > >[...] 4 is the only value that is on the left and only >on the left. But this is not the answer to your SQL statement. The correct answer is: left ------ 1 1 1 1 2 2 2 1 1 1 1 4 4 4 4 4 5 5 5 (19 rows) What you are looking for is more like SELECT left FROM pairs EXCEPT SELECT right FROM pairs; >This methoud is order O(n) if both colums have b-tree indexes so you >don't have to pre sort them othere wise it is O(n*log(n)) as the sort is >the greatest complexity. In eathere case it is way better then O(n^2) >for almost any n. And I'm sure it will not take O(n^2) time in Postgres. Servus Manfred From pgsql-performance-owner@postgresql.org Thu Apr 17 12:31:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1762A4762A2 for ; Thu, 17 Apr 2003 12:31:47 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A27A3476141 for ; Thu, 17 Apr 2003 12:31:45 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3HGVnU6011333; Thu, 17 Apr 2003 12:31:49 -0400 (EDT) To: Jonathan Moore Cc: pgsql-performance@postgresql.org Subject: Re: dum query plan: more info. In-reply-to: <1050530569.20873.120.camel@spunge-bob> References: <1050530569.20873.120.camel@spunge-bob> Comments: In-reply-to Jonathan Moore message dated "16 Apr 2003 15:02:49 -0700" Date: Thu, 17 Apr 2003 12:31:49 -0400 Message-ID: <11332.1050597109@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/155 X-Sequence-Number: 1661 Jonathan Moore writes: > I now under stand that my join was rong but none of the seguestions are > the optimal solution to the problime. You can make this order n if you > try. The trick is to use a mearg join using sorted list of the unique > keys in each colum join. The question you are asking is what left hand > entrys do not exist on the right. In that case maybe what you are after is select a.* from a left join b on (a.left = b.right) where b.right is null; which is a pretty grotty hack using the outer-join rules, but should work efficiently. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Apr 17 13:48:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 95FAC475458 for ; Thu, 17 Apr 2003 13:48:17 -0400 (EDT) Received: from smtp.kocks.com (adsl-66-124-90-234.dsl.snfc21.pacbell.net [66.124.90.234]) by postgresql.org (Postfix) with ESMTP id 4205A4758F1 for ; Thu, 17 Apr 2003 13:48:16 -0400 (EDT) Received: from GARP (fwinside.kocks.com [10.10.10.1]) by smtp.kocks.com (mail) with SMTP id 2208128BDA for ; Thu, 17 Apr 2003 10:48:16 -0700 (PDT) Reply-To: From: "dex" To: Subject: Performance of Inherits versus Views Date: Thu, 17 Apr 2003 10:48:16 -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.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-8.8 required=5.0 tests=BAYES_20,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/156 X-Sequence-Number: 1662 Hello, Is it more efficient to use a schema with Inherits or schema with Views. I can see logically how to use both for my case and I'm trying to make a decision. I would guess that the overhead of the queries against inherited tables is higher than queries against views, but I don't know. At the bottom of this message, I've included the cities / capitals examples implemented both as schema using inheritance and as schema using views. Using the example, I could make queries such as: SELECT name FROM capitals; -- capitals in inherited or SELECT name FROM capital_cities; -- capital cities is a view But which one would be faster? In my real world example, I will either have one small base class table (i.e. cities in the example) and many direct descendents of that base table (e.g. capitals, beaches, national parks, suburbs in the example). Or, it could be implemented as one larger (but not huge) lookup table with many views against that lookup table. What would you do? Thanks! --dex -- -- Schema with Inherits -- CREATE TABLE cities ( name text, population float, altitude int -- (in ft) ); CREATE TABLE capitals ( state char(2) ) INHERITS (cities); -- -- Schema with View -- CREATE TABLE all_cities ( name text, population float, altitude int, state char(2) ); CREATE VIEW just_cities AS SELECT all_cities.name, all_cities.population, all_cities.altitude FROM all_cities; -- or perhaps with a where clause, as in CREATE VIEW capital_cities AS SELECT all_cities.name, all_cities.population, all_cities.altitude FROM all_cities WHERE (all_cities.state IS NOT NULL); From pgsql-performance-owner@postgresql.org Thu Apr 17 15:17:11 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6BE434758F1 for ; Thu, 17 Apr 2003 15:17:09 -0400 (EDT) Received: from mail.cs.umass.edu (loki.cs.umass.edu [128.119.243.168]) by postgresql.org (Postfix) with ESMTP id 7F982475458 for ; Thu, 17 Apr 2003 15:17:08 -0400 (EDT) Received: from phobos.cs.umass.edu (phobos.cs.umass.edu [128.119.243.161]) by mail.cs.umass.edu (8.12.6/8.12.5) with ESMTP id h3HJH8jh012376 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Thu, 17 Apr 2003 15:17:08 -0400 Date: Thu, 17 Apr 2003 15:17:01 -0400 (EDT) From: Victor Danilchenko To: pgsql-performance@postgresql.org Subject: Query speed problems Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checked: This message probably not SPAM X-Spam-Score: -5.8, Required: 5 X-Spam-Tests: USER_AGENT_PINE X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-12.3 required=5.0 tests=BAYES_01,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/157 X-Sequence-Number: 1663 Hi, In the process of developing an API for web/perl/postrgres interactions, I have come up against a peculiar problem; a rather simple query, run on two relatively small tables, takes as much as 0.4 seconds on my development system (it's a P2 266, which in this case is a good thing, as it exposes speed issues). I tried accomplishging the same thing via subqueries and joins, and both methods give me similarly bad result (join query is a little slower, but only a little). The queries I have tested are as follows: SELECT DISTINCT maker.* FROM maker,model WHERE maker.id=model.maker SELECT DISTINCT maker.* FROM maker join model ON maker.id=model.maker The point of the queries is to extract only the maker rows which are referenced from the model table. I would happily use another way to achieve the same end, should anyone suggest it. "maker" has only 137 rows, "model" only 1233 rows. I test the performance in perl, by taking time right before and after query execution. Executing the queries takes anywhere between .3 and .5 seconds, depending on some other factors (removing the 'distinct' keyword from the 1st query shaves about .1 second off of the execution time for example). These execution times seem ridiculous. Any idea what the culprit may be? I hope it's not the text fields, 'cuz those fields are important. Both tables are quite simple: # \d maker Table "public.maker" Column | Type | Modifiers ------------+-----------------------+----------- id | character varying(4) | not null fullname | character varying(20) | contact | character varying(20) | phone | character varying(15) | service_no | character varying(20) | lastuser | character varying(30) | comments | text | Indexes: maker_pkey primary key btree (id) Triggers: RI_ConstraintTrigger_18881, RI_ConstraintTrigger_18882 # \d model Table "public.model" Column | Type | Modifiers ---------------+-----------------------+--------------------------------------------- id | integer | not null default nextval('model_ids'::text) name | character varying(20) | not null maker | character varying(4) | type_hardware | character varying(4) | fullname | character varying(40) | spec | character varying(50) | lastuser | character varying(30) | comments | text | size_cap | character varying(10) | Indexes: model_pkey primary key btree (id), unique_model unique btree (name, maker, type_hardware) Check constraints: "nonempty_fullname" (fullname > ''::character varying) Foreign Key constraints: valid_maker FOREIGN KEY (maker) REFERENCES \ maker(id) ON UPDATE NO ACTION ON DELETE NO ACTION, valid_type FOREIGN KEY (type_hardware) REFERENCES type_hardware(id) ON UPDATE NO ACTION ON DELETE NO ACTION -- | Victor Danilchenko | Any sufficiently advanced | | danilche@cs.umass.edu | technology is indistinguishable | | CSCF | 5-4231 | from a Perl script. | From pgsql-performance-owner@postgresql.org Thu Apr 17 15:38:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1F674758F1 for ; Thu, 17 Apr 2003 15:38:42 -0400 (EDT) Received: from mail.cs.umass.edu (loki.cs.umass.edu [128.119.243.168]) by postgresql.org (Postfix) with ESMTP id 12547475458 for ; Thu, 17 Apr 2003 15:38:42 -0400 (EDT) Received: from phobos.cs.umass.edu (phobos.cs.umass.edu [128.119.243.161]) by mail.cs.umass.edu (8.12.6/8.12.5) with ESMTP id h3HJcgjh016856 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Thu, 17 Apr 2003 15:38:42 -0400 Date: Thu, 17 Apr 2003 15:38:37 -0400 (EDT) From: Victor Danilchenko To: pgsql-performance@postgresql.org Subject: Re: Query speed problems In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checked: This message probably not SPAM X-Spam-Score: -15.7, Required: 5 X-Spam-Tests: IN_REP_TO,REFERENCES,USER_AGENT_PINE X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-22.0 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/158 X-Sequence-Number: 1664 Sorry, I forgot to specify software versions. I am running RHL 8.0 (Linux kernel 2.4.18), and postgres 7.3. -- | Victor Danilchenko +------------------------------------+ | danilche@cs.umass.edu | I don't have to outrun the bear -- | | CSCF | 5-4231 | I just have to outrun YOU! | From pgsql-performance-owner@postgresql.org Thu Apr 17 15:55:15 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A79084758F1 for ; Thu, 17 Apr 2003 15:55:13 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id E4C1D475458 for ; Thu, 17 Apr 2003 15:55:09 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E1FDAD612; Thu, 17 Apr 2003 12:55:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id D7AAB5C03; Thu, 17 Apr 2003 12:55:10 -0700 (PDT) Date: Thu, 17 Apr 2003 12:55:10 -0700 (PDT) From: Stephan Szabo To: Victor Danilchenko Cc: Subject: Re: Query speed problems In-Reply-To: Message-ID: <20030417125211.J91312-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/159 X-Sequence-Number: 1665 On Thu, 17 Apr 2003, Victor Danilchenko wrote: > The queries I have tested are as follows: > > SELECT DISTINCT maker.* FROM maker,model WHERE maker.id=model.maker > SELECT DISTINCT maker.* FROM maker join model ON maker.id=model.maker > > The point of the queries is to extract only the maker rows which > are referenced from the model table. I would happily use another way to > achieve the same end, should anyone suggest it. What does explain analyze show for the query? > "maker" has only 137 rows, "model" only 1233 rows. I test the > performance in perl, by taking time right before and after query > execution. Executing the queries takes anywhere between .3 and .5 > seconds, depending on some other factors (removing the 'distinct' > keyword from the 1st query shaves about .1 second off of the execution > time for example). > Column | Type | Modifiers > ---------------+-----------------------+--------------------------------------------- > id | integer | not null default nextval('model_ids'::text) > name | character varying(20) | not null > maker | character varying(4) | > type_hardware | character varying(4) | > fullname | character varying(40) | > spec | character varying(50) | > lastuser | character varying(30) | > comments | text | > size_cap | character varying(10) | > Indexes: model_pkey primary key btree (id), > unique_model unique btree (name, maker, type_hardware) > Check constraints: "nonempty_fullname" (fullname > ''::character varying) > Foreign Key constraints: valid_maker FOREIGN KEY (maker) REFERENCES \ > maker(id) ON UPDATE NO ACTION ON DELETE NO ACTION, > valid_type FOREIGN KEY (type_hardware) > REFERENCES type_hardware(id) ON UPDATE NO ACTION ON DELETE NO ACTION Hmm, it doesn't look to me like model.maker= type queries are indexable with this set of things. An index on model(maker) might help. From pgsql-performance-owner@postgresql.org Thu Apr 17 15:59:07 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A9FCD475956 for ; Thu, 17 Apr 2003 15:59:05 -0400 (EDT) Received: from mail.speakeasy.net (mail14.speakeasy.net [216.254.0.214]) by postgresql.org (Postfix) with ESMTP id 7E0B547592C for ; Thu, 17 Apr 2003 15:59:04 -0400 (EDT) Received: (qmail 20098 invoked from network); 17 Apr 2003 19:59:12 -0000 Received: from unknown (HELO pdarley) (kinesis@[64.81.9.230]) (envelope-sender ) by mail14.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 17 Apr 2003 19:59:12 -0000 From: "Peter Darley" To: "Victor Danilchenko" , Subject: Re: Query speed problems Date: Thu, 17 Apr 2003 12:59:07 -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.2416 (9.0.2910.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-21.0 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE,ORIGINAL_MESSAGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/160 X-Sequence-Number: 1666 Victor, I'm not sure, but I think an exists might be faster for you. It wouldn't have to deal with the Cartesian product of the tables. SELECT DISTINCT maker.* FROM maker WHERE exists (SELECT 1 FROM model WHERE model.maker=maker.id); Thanks, Peter Darley -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Victor Danilchenko Sent: Thursday, April 17, 2003 12:17 PM To: pgsql-performance@postgresql.org Subject: [PERFORM] Query speed problems Hi, In the process of developing an API for web/perl/postrgres interactions, I have come up against a peculiar problem; a rather simple query, run on two relatively small tables, takes as much as 0.4 seconds on my development system (it's a P2 266, which in this case is a good thing, as it exposes speed issues). I tried accomplishging the same thing via subqueries and joins, and both methods give me similarly bad result (join query is a little slower, but only a little). The queries I have tested are as follows: SELECT DISTINCT maker.* FROM maker,model WHERE maker.id=model.maker SELECT DISTINCT maker.* FROM maker join model ON maker.id=model.maker The point of the queries is to extract only the maker rows which are referenced from the model table. I would happily use another way to achieve the same end, should anyone suggest it. "maker" has only 137 rows, "model" only 1233 rows. I test the performance in perl, by taking time right before and after query execution. Executing the queries takes anywhere between .3 and .5 seconds, depending on some other factors (removing the 'distinct' keyword from the 1st query shaves about .1 second off of the execution time for example). These execution times seem ridiculous. Any idea what the culprit may be? I hope it's not the text fields, 'cuz those fields are important. Both tables are quite simple: # \d maker Table "public.maker" Column | Type | Modifiers ------------+-----------------------+----------- id | character varying(4) | not null fullname | character varying(20) | contact | character varying(20) | phone | character varying(15) | service_no | character varying(20) | lastuser | character varying(30) | comments | text | Indexes: maker_pkey primary key btree (id) Triggers: RI_ConstraintTrigger_18881, RI_ConstraintTrigger_18882 # \d model Table "public.model" Column | Type | Modifiers ---------------+-----------------------+------------------------------------ --------- id | integer | not null default nextval('model_ids'::text) name | character varying(20) | not null maker | character varying(4) | type_hardware | character varying(4) | fullname | character varying(40) | spec | character varying(50) | lastuser | character varying(30) | comments | text | size_cap | character varying(10) | Indexes: model_pkey primary key btree (id), unique_model unique btree (name, maker, type_hardware) Check constraints: "nonempty_fullname" (fullname > ''::character varying) Foreign Key constraints: valid_maker FOREIGN KEY (maker) REFERENCES \ maker(id) ON UPDATE NO ACTION ON DELETE NO ACTION, valid_type FOREIGN KEY (type_hardware) REFERENCES type_hardware(id) ON UPDATE NO ACTION ON DELETE NO ACTION -- | Victor Danilchenko | Any sufficiently advanced | | danilche@cs.umass.edu | technology is indistinguishable | | CSCF | 5-4231 | from a Perl script. | ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From pgsql-performance-owner@postgresql.org Thu Apr 17 16:24:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DD62F4758F1 for ; Thu, 17 Apr 2003 16:24:24 -0400 (EDT) Received: from mail.cs.umass.edu (loki.cs.umass.edu [128.119.243.168]) by postgresql.org (Postfix) with ESMTP id E3BA8475458 for ; Thu, 17 Apr 2003 16:24:23 -0400 (EDT) Received: from phobos.cs.umass.edu (phobos.cs.umass.edu [128.119.243.161]) by mail.cs.umass.edu (8.12.6/8.12.5) with ESMTP id h3HKOMjh029751 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Thu, 17 Apr 2003 16:24:22 -0400 Date: Thu, 17 Apr 2003 16:24:17 -0400 (EDT) From: Victor Danilchenko To: Peter Darley Cc: pgsql-performance@postgresql.org Subject: Re: Query speed problems In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checked: This message probably not SPAM X-Spam-Score: -32.2, Required: 5 X-Spam-Tests: EMAIL_ATTRIBUTION, IN_REP_TO, QUOTED_EMAIL_TEXT, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT_PINE X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-38.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/161 X-Sequence-Number: 1667 On Thu, 17 Apr 2003, Peter Darley wrote: >Victor, > I'm not sure, but I think an exists might be faster for you. It wouldn't >have to deal with the Cartesian product of the tables. > >SELECT DISTINCT maker.* FROM maker WHERE exists (SELECT 1 FROM model WHERE >model.maker=maker.id); That was indeed significantly faster. *very* significantly faster. As you may guess, I am an SQL newbie, and working my way through the language. I figured there would be a faster way to do what I was doing, but sunqueries or joins was the only way I could figure out. Again, thanks for the helpful reply, and for your promptness. I still want to figure out why the subquery version was taking so damned long, but it's nice to have a working fast solution. >-----Original Message----- >From: pgsql-performance-owner@postgresql.org >[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Victor >Danilchenko >Sent: Thursday, April 17, 2003 12:17 PM >To: pgsql-performance@postgresql.org >Subject: [PERFORM] Query speed problems > > > Hi, > > In the process of developing an API for web/perl/postrgres >interactions, I have come up against a peculiar problem; a rather simple >query, run on two relatively small tables, takes as much as 0.4 seconds >on my development system (it's a P2 266, which in this case is a good >thing, as it exposes speed issues). I tried accomplishging the same >thing via subqueries and joins, and both methods give me similarly bad >result (join query is a little slower, but only a little). > > The queries I have tested are as follows: > >SELECT DISTINCT maker.* FROM maker,model WHERE maker.id=model.maker >SELECT DISTINCT maker.* FROM maker join model ON maker.id=model.maker > > The point of the queries is to extract only the maker rows which >are referenced from the model table. I would happily use another way to >achieve the same end, should anyone suggest it. > > "maker" has only 137 rows, "model" only 1233 rows. I test the >performance in perl, by taking time right before and after query >execution. Executing the queries takes anywhere between .3 and .5 >seconds, depending on some other factors (removing the 'distinct' >keyword from the 1st query shaves about .1 second off of the execution >time for example). > > These execution times seem ridiculous. Any idea what the culprit >may be? I hope it's not the text fields, 'cuz those fields are >important. > > Both tables are quite simple: > ># \d maker > Table "public.maker" > Column | Type | Modifiers >------------+-----------------------+----------- > id | character varying(4) | not null > fullname | character varying(20) | > contact | character varying(20) | > phone | character varying(15) | > service_no | character varying(20) | > lastuser | character varying(30) | > comments | text | >Indexes: maker_pkey primary key btree (id) >Triggers: RI_ConstraintTrigger_18881, > RI_ConstraintTrigger_18882 > ># \d model > Table "public.model" > Column | Type | Modifiers >---------------+-----------------------+------------------------------------ >--------- > id | integer | not null default >nextval('model_ids'::text) > name | character varying(20) | not null > maker | character varying(4) | > type_hardware | character varying(4) | > fullname | character varying(40) | > spec | character varying(50) | > lastuser | character varying(30) | > comments | text | > size_cap | character varying(10) | >Indexes: model_pkey primary key btree (id), > unique_model unique btree (name, maker, type_hardware) >Check constraints: "nonempty_fullname" (fullname > ''::character varying) >Foreign Key constraints: valid_maker FOREIGN KEY (maker) REFERENCES \ > maker(id) ON UPDATE NO ACTION ON DELETE NO >ACTION, > valid_type FOREIGN KEY (type_hardware) >REFERENCES type_hardware(id) ON UPDATE NO ACTION ON DELETE NO ACTION > >-- >| Victor Danilchenko | Any sufficiently advanced | >| danilche@cs.umass.edu | technology is indistinguishable | >| CSCF | 5-4231 | from a Perl script. | > > >---------------------------(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 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- | Victor Danilchenko | Curiosity was framed; | | danilche@cs.umass.edu | Ignorance killed the cat. | | CSCF | 5-4231 | -- Anonymous | From pgsql-performance-owner@postgresql.org Thu Apr 17 16:30:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 256AD4758F1 for ; Thu, 17 Apr 2003 16:30:07 -0400 (EDT) Received: from mail.cs.umass.edu (loki.cs.umass.edu [128.119.243.168]) by postgresql.org (Postfix) with ESMTP id 11A47475458 for ; Thu, 17 Apr 2003 16:30:04 -0400 (EDT) Received: from phobos.cs.umass.edu (phobos.cs.umass.edu [128.119.243.161]) by mail.cs.umass.edu (8.12.6/8.12.5) with ESMTP id h3HKU2jh030364 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Thu, 17 Apr 2003 16:30:02 -0400 Date: Thu, 17 Apr 2003 16:29:57 -0400 (EDT) From: Victor Danilchenko To: Stephan Szabo Cc: pgsql-performance@postgresql.org Subject: Re: Query speed problems In-Reply-To: <20030417125211.J91312-100000@megazone23.bigpanda.com> Message-ID: References: <20030417125211.J91312-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checked: This message probably not SPAM X-Spam-Score: -32.2, Required: 5 X-Spam-Tests: EMAIL_ATTRIBUTION, IN_REP_TO, QUOTED_EMAIL_TEXT, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT_PINE X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-38.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/162 X-Sequence-Number: 1668 On Thu, 17 Apr 2003, Stephan Szabo wrote: > >On Thu, 17 Apr 2003, Victor Danilchenko wrote: > >> The queries I have tested are as follows: >> >> SELECT DISTINCT maker.* FROM maker,model WHERE maker.id=model.maker >> SELECT DISTINCT maker.* FROM maker join model ON maker.id=model.maker >> >> The point of the queries is to extract only the maker rows which >> are referenced from the model table. I would happily use another way to >> achieve the same end, should anyone suggest it. > >What does explain analyze show for the query? # explain analyze SELECT DISTINCT * FROM maker WHERE id=model.maker; NOTICE: Adding missing FROM-clause entry for table "model" QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Unique (cost=230.58..255.24 rows=123 width=171) (actual time=238.20..293.21 rows=128 loops=1) -> Sort (cost=230.58..233.66 rows=1233 width=171) (actual time=238.19..241.07 rows=1233 loops=1) Sort Key: maker.id, maker.fullname, maker.contact, maker.phone, maker.service_no, maker.lastuser, maker.comments -> Merge Join (cost=0.00..167.28 rows=1233 width=171) (actual time=0.27..81.49 rows=1233 loops=1) Merge Cond: ("outer".id = "inner".maker) -> Index Scan using maker_pkey on maker (cost=0.00..52.00 rows=1000 width=164) (actual time=0.11..4.29 rows=137 loops=1) -> Index Scan using makers on model (cost=0.00..94.28 rows=1233 width=7) (actual time=0.04..27.34 rows=1233 loops=1) Total runtime: 295.30 msec (8 rows) Following a suggestion sent in private mail, I have created an index for model.maker column: # create index model_maker on model(maker); but that doesn't seem to have made an appreciable difference in performance -- it's only about .05 seconds more than the above number if I drop the index. Many thanks for your help. >> "maker" has only 137 rows, "model" only 1233 rows. I test the >> performance in perl, by taking time right before and after query >> execution. Executing the queries takes anywhere between .3 and .5 >> seconds, depending on some other factors (removing the 'distinct' >> keyword from the 1st query shaves about .1 second off of the execution >> time for example). > >> Column | Type | Modifiers >> ---------------+-----------------------+--------------------------------------------- >> id | integer | not null default nextval('model_ids'::text) >> name | character varying(20) | not null >> maker | character varying(4) | >> type_hardware | character varying(4) | >> fullname | character varying(40) | >> spec | character varying(50) | >> lastuser | character varying(30) | >> comments | text | >> size_cap | character varying(10) | >> Indexes: model_pkey primary key btree (id), >> unique_model unique btree (name, maker, type_hardware) >> Check constraints: "nonempty_fullname" (fullname > ''::character varying) >> Foreign Key constraints: valid_maker FOREIGN KEY (maker) REFERENCES \ >> maker(id) ON UPDATE NO ACTION ON DELETE NO ACTION, >> valid_type FOREIGN KEY (type_hardware) >> REFERENCES type_hardware(id) ON UPDATE NO ACTION ON DELETE NO ACTION > >Hmm, it doesn't look to me like model.maker= type queries are >indexable with this set of things. An index on model(maker) might help. > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > -- | Victor Danilchenko | Curiosity was framed; | | danilche@cs.umass.edu | Ignorance killed the cat. | | CSCF | 5-4231 | -- Anonymous | From pgsql-performance-owner@postgresql.org Thu Apr 17 17:08:50 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 359204758F1 for ; Thu, 17 Apr 2003 17:08:50 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 82D4C475458 for ; Thu, 17 Apr 2003 17:08:49 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 2CA74D602; Thu, 17 Apr 2003 14:08:51 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 2253F5C03; Thu, 17 Apr 2003 14:08:51 -0700 (PDT) Date: Thu, 17 Apr 2003 14:08:51 -0700 (PDT) From: Stephan Szabo To: Victor Danilchenko Cc: Subject: Re: Query speed problems In-Reply-To: Message-ID: <20030417140458.Q92220-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/163 X-Sequence-Number: 1669 On Thu, 17 Apr 2003, Victor Danilchenko wrote: > Unique (cost=230.58..255.24 rows=123 width=171) (actual > time=238.20..293.21 rows=128 loops=1) > -> Sort (cost=230.58..233.66 rows=1233 width=171) (actual > time=238.19..241.07 rows=1233 loops=1) > Sort Key: maker.id, maker.fullname, maker.contact, > maker.phone, maker.service_no, maker.lastuser, maker.comments > -> Merge Join (cost=0.00..167.28 rows=1233 width=171) (actual > time=0.27..81.49 rows=1233 loops=1) > Merge Cond: ("outer".id = "inner".maker) > -> Index Scan using maker_pkey on maker > (cost=0.00..52.00 rows=1000 width=164) (actual time=0.11..4.29 > rows=137 loops=1) > -> Index Scan using makers on model (cost=0.00..94.28 > rows=1233 width=7) (actual time=0.04..27.34 rows=1233 loops=1) > Total runtime: 295.30 msec > (8 rows) Hmm, well, for this version, it looks like most of the time is probably going into the sort. I wonder if raising sort_mem would help this version of the query (try a set sort_mem=8192; before running the query). This isn't likely to get the time below like 160 msec though. > Following a suggestion sent in private mail, I have created an > index for model.maker column: > > # create index model_maker on model(maker); > > but that doesn't seem to have made an appreciable difference in > performance -- it's only about .05 seconds more than the above number if > I drop the index. Yeah, it looks like it's already using an index, but I didn't see that index in the list of indexes on the table in the original mail, wierd. From pgsql-performance-owner@postgresql.org Thu Apr 17 21:26:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2CD29475D91 for ; Thu, 17 Apr 2003 21:26:12 -0400 (EDT) Received: from c001.snv.cp.net (h021.c001.snv.cp.net [209.228.32.135]) by postgresql.org (Postfix) with SMTP id 5075D475ADE for ; Thu, 17 Apr 2003 21:26:11 -0400 (EDT) Received: (cpmta 17407 invoked from network); 17 Apr 2003 18:26:13 -0700 Received: from 209.228.32.129 (HELO mail.dilger.cc.criticalpath.net) by smtp.register-admin.com (209.228.32.135) with SMTP; 17 Apr 2003 18:26:13 -0700 X-Sent: 18 Apr 2003 01:26:13 GMT Received: from [216.68.146.219] by mail.dilger.cc with HTTP; Thu, 17 Apr 2003 18:26:12 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: danilche@cs.umass.edu Cc: pgsql-performance@postgresql.org From: "Nikolaus Dilger" Subject: Re: Query speed problems X-Sent-From: nikolaus@dilger.cc Date: Thu, 17 Apr 2003 18:26:12 -0700 (PDT) X-Mailer: Web Mail 5.3.0-6_sol28 Message-Id: <20030417182613.4395.h015.c001.wm@mail.dilger.cc.criticalpath.net> X-Spam-Status: No, hits=-13.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTE_TWICE_1 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/164 X-Sequence-Number: 1670 Victor, What is the issue? You get sub second response time. Why waste your time trying to make it faster? If you have a query that runs serveral minutes or hours then its worthwhile tuning. Or if your query gets executed several thausend times a day. Regards, Nikolaus On Thu, 17 Apr 2003 15:17:01 -0400 (EDT), Victor Danilchenko wrote: > > Hi, > > In the process of developing an API for > web/perl/postrgres > interactions, I have come up against a peculiar > problem; a rather simple > query, run on two relatively small tables, takes as > much as 0.4 seconds > on my development system (it's a P2 266, which in this > case is a good > thing, as it exposes speed issues). I tried > accomplishging the same > thing via subqueries and joins, and both methods give > me similarly bad > result (join query is a little slower, but only a > little). > > The queries I have tested are as follows: > > SELECT DISTINCT maker.* FROM maker,model WHERE > maker.id=model.maker > SELECT DISTINCT maker.* FROM maker join model ON > maker.id=model.maker > > The point of the queries is to extract only the maker > rows which > are referenced from the model table. I would happily > use another way to > achieve the same end, should anyone suggest it. > > "maker" has only 137 rows, "model" only 1233 rows. I > test the > performance in perl, by taking time right before and > after query > execution. Executing the queries takes anywhere between > .3 and .5 > seconds, depending on some other factors (removing the > 'distinct' > keyword from the 1st query shaves about .1 second off > of the execution > time for example). > > These execution times seem ridiculous. Any idea what > the culprit > may be? I hope it's not the text fields, 'cuz those > fields are > important. > > Both tables are quite simple: > > # \d maker > Table "public.maker" > Column | Type | Modifiers > ------------+-----------------------+----------- > id | character varying(4) | not null > fullname | character varying(20) | > contact | character varying(20) | > phone | character varying(15) | > service_no | character varying(20) | > lastuser | character varying(30) | > comments | text | > Indexes: maker_pkey primary key btree (id) > Triggers: RI_ConstraintTrigger_18881, > RI_ConstraintTrigger_18882 > > # \d model > Table "public.model" > Column | Type | > Modifiers > ---------------+-----------------------+--------------------------------------------- > id | integer | not null > default nextval('model_ids'::text) > name | character varying(20) | not null > maker | character varying(4) | > type_hardware | character varying(4) | > fullname | character varying(40) | > spec | character varying(50) | > lastuser | character varying(30) | > comments | text | > size_cap | character varying(10) | > Indexes: model_pkey primary key btree (id), > unique_model unique btree (name, maker, > type_hardware) > Check constraints: "nonempty_fullname" (fullname > > ''::character varying) > Foreign Key constraints: valid_maker FOREIGN KEY > (maker) REFERENCES \ > maker(id) ON UPDATE NO > ACTION ON DELETE NO ACTION, > valid_type FOREIGN KEY > (type_hardware) > REFERENCES type_hardware(id) ON UPDATE NO ACTION ON > DELETE NO ACTION > > -- > | Victor Danilchenko | Any sufficiently advanced > | > | danilche@cs.umass.edu | technology is > indistinguishable | > | CSCF | 5-4231 | from a Perl script. > | > > > ---------------------------(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-hackers-owner@postgresql.org Fri Apr 18 01:11:35 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9E4CE475ADE; Fri, 18 Apr 2003 01:11:34 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id C6430475458; Fri, 18 Apr 2003 01:11:33 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Thu, 17 Apr 2003 22:11:33 -0700 Date: Thu, 17 Apr 2003 22:11:33 -0700 From: Kevin Brown To: pgsql-hackers@postgresql.org Cc: pgsql-performance@postgresql.org Subject: Foreign key performance Message-ID: <20030418051133.GK1833@filer> Mail-Followup-To: Kevin Brown , pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-9.4 required=5.0 tests=BAYES_20,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/678 X-Sequence-Number: 38168 I'm using 7.3.2 on Linux, with a decent amount of muscle behind it (1.5 GHz PPro CPU, 1G mem, 20M/sec disks, xlog on different disk than data). I've got a database that has several foreign keys, and I'm copying a bunch of data from an MS-SQL server into it via Perl DBI. I noticed that inserts into this database are very slow, on the order of 100 per second on this hardware. All the inserts are happening in a single transaction. The postmaster I'm connected to appears to be CPU limited, as it's pegging the CPU at a constant 85 percent or more. I have no problem with that under normal circumstances (i.e., the foreign key constraints are actively being enforced): it may well be the nature of foreign keys, but the problem is this: all the keys are DEFERRABLE INITIALLY DEFERRED and, on top of that, the Perl program will SET CONSTRAINTS ALL DEFERRED at the beginning of the transaction. If I remove all the foreign key constraints, my performance goes up to 700 inserts per second! Why isn't the insert performance with all the constraints deferred approximating that of the performance I get without the foreign keys?? If anything, I should get a big delay at transaction commit time while all the foreign key constraints are checked (and, indeed, I get that too), but the performance during the transaction prior to the commit should be the same as it is without the foreign key constraints. It's almost as if the foreign key constraints are being invoked and the results ignored during the inserts... In essence, this smells like a bug to me, but I don't know enough about the internals to really call it that. Any ideas on what can be done about this? -- Kevin Brown kevin@sysexperts.com From pgsql-hackers-owner@postgresql.org Fri Apr 18 01:30:51 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id ED2B5475ADE; Fri, 18 Apr 2003 01:30:49 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 3184A475458; Fri, 18 Apr 2003 01:30:46 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id CDB7CD612; Thu, 17 Apr 2003 22:30:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C36475C03; Thu, 17 Apr 2003 22:30:45 -0700 (PDT) Date: Thu, 17 Apr 2003 22:30:45 -0700 (PDT) From: Stephan Szabo To: Kevin Brown Cc: , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <20030418051133.GK1833@filer> Message-ID: <20030417222628.G97462-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/679 X-Sequence-Number: 38169 On Thu, 17 Apr 2003, Kevin Brown wrote: > I have no problem with that under normal circumstances (i.e., the > foreign key constraints are actively being enforced): it may well be > the nature of foreign keys, but the problem is this: all the keys are > DEFERRABLE INITIALLY DEFERRED and, on top of that, the Perl program > will SET CONSTRAINTS ALL DEFERRED at the beginning of the transaction. > > If I remove all the foreign key constraints, my performance goes up to > 700 inserts per second! > > Why isn't the insert performance with all the constraints deferred > approximating that of the performance I get without the foreign keys?? It appears (from some not terribly scientific experiments - see below) that it's likely to be related to managing the deferred trigger queue given that in my case at least running the constraints non-deferred was negligible in comparison. On batch inserts to three tables each with a foreign key to a table containing one row (and inserts of lots of that value), I saw a ratio of approximately 1:1.7:7 for normal inserts:non-deferred fk:deferred fk on my 7.4 dev server. From pgsql-hackers-owner@postgresql.org Fri Apr 18 02:06:08 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BB5B0476344 for ; Fri, 18 Apr 2003 02:06:07 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id E593E476342 for ; Fri, 18 Apr 2003 02:06:04 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3I664U6001967; Fri, 18 Apr 2003 02:06:05 -0400 (EDT) To: Stephan Szabo Cc: Kevin Brown , pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] Foreign key performance In-reply-to: <20030417222628.G97462-100000@megazone23.bigpanda.com> References: <20030417222628.G97462-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Thu, 17 Apr 2003 22:30:45 -0700" Date: Fri, 18 Apr 2003 02:06:04 -0400 Message-ID: <1966.1050645964@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/683 X-Sequence-Number: 38173 Stephan Szabo writes: > It appears (from some not terribly scientific experiments - see below) > that it's likely to be related to managing the deferred trigger queue > given that in my case at least running the constraints non-deferred was > negligible in comparison. At one time the deferred-trigger queue had an O(N^2) behavioral problem for large N = number of pending trigger events. But I thought we'd fixed that. What's the test case exactly? Can you get a profile with gprof? regards, tom lane From pgsql-hackers-owner@postgresql.org Fri Apr 18 02:25:23 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CE704475ADE; Fri, 18 Apr 2003 02:25:21 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 95BAD475458; Fri, 18 Apr 2003 02:25:20 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D00B9D613; Thu, 17 Apr 2003 23:25:20 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C5C805C03; Thu, 17 Apr 2003 23:25:20 -0700 (PDT) Date: Thu, 17 Apr 2003 23:25:20 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <1966.1050645964@sss.pgh.pa.us> Message-ID: <20030417231421.O97534-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/685 X-Sequence-Number: 38175 On Fri, 18 Apr 2003, Tom Lane wrote: > Stephan Szabo writes: > > It appears (from some not terribly scientific experiments - see below) > > that it's likely to be related to managing the deferred trigger queue > > given that in my case at least running the constraints non-deferred was > > negligible in comparison. > > At one time the deferred-trigger queue had an O(N^2) behavioral problem > for large N = number of pending trigger events. But I thought we'd > fixed that. What's the test case exactly? Can you get a profile with > gprof? I'm going to tomorrow hopefully - but it looks to me that we fixed one, but possibly not another place where we read through the list unnecessarily AFAICS. I think deferredTriggerInvokeEvents (when called with immediate_only = true) is going to go through the entire list looking for immediate triggers to fire after each statement. However, excepting set constraints, any immediate triggers for any event added prior to this statement will by necessity have already been run unless I'm missing something, which means that we're often looking through entries that aren't going to have any triggers to run now in any case. Keeping a pointer to the end of the list as of last statement and going through the list from there cut the time for the deferred case in half in my simple test (about 3.3x the no fk and just under 2x the immediate). From pgsql-hackers-owner@postgresql.org Fri Apr 18 10:47:13 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 36464475E91 for ; Fri, 18 Apr 2003 10:47:12 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 7A4CE475458 for ; Fri, 18 Apr 2003 10:47:11 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 04455D619; Fri, 18 Apr 2003 07:47:15 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id EE18D5C02; Fri, 18 Apr 2003 07:47:15 -0700 (PDT) Date: Fri, 18 Apr 2003 07:47:15 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <20030417231421.O97534-100000@megazone23.bigpanda.com> Message-ID: <20030418073753.B1912-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/691 X-Sequence-Number: 38181 [Not sure this really is relevant for -performance at this point] On Thu, 17 Apr 2003, Stephan Szabo wrote: > On Fri, 18 Apr 2003, Tom Lane wrote: > > > Stephan Szabo writes: > > > It appears (from some not terribly scientific experiments - see below) > > > that it's likely to be related to managing the deferred trigger queue > > > given that in my case at least running the constraints non-deferred was > > > negligible in comparison. > > > > At one time the deferred-trigger queue had an O(N^2) behavioral problem > > for large N = number of pending trigger events. But I thought we'd > > fixed that. What's the test case exactly? Can you get a profile with > > gprof? > > I'm going to tomorrow hopefully - but it looks to me that we fixed one, but Argh. I'm getting that state where gprof returns all 0s for times. I'm pretty sure this has come up before along with how to get it to work, but I couldn't find it in the archives. Someday I'll learn how to use gprof. :( In any case, the call list seemed reasonable. It's currently doing O(n^2) calls to MemoryContextReset and deferredTriggerCheckState in InvokeEvents I don't see anything else that's at that kind of number of calls (50 million calls for a backend that's only done 10000 inserts stands out a bit). Going only from last statement seems to make it linear (I think my attempt is checking 1 too many trigger values, need to change that probably). From pgsql-hackers-owner@postgresql.org Fri Apr 18 10:51:38 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E0FA475F39 for ; Fri, 18 Apr 2003 10:51:37 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6A630475ECE for ; Fri, 18 Apr 2003 10:51:36 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3IEpeU6003991; Fri, 18 Apr 2003 10:51:40 -0400 (EDT) To: Stephan Szabo Cc: Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance In-reply-to: <20030418073753.B1912-100000@megazone23.bigpanda.com> References: <20030418073753.B1912-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Fri, 18 Apr 2003 07:47:15 -0700" Date: Fri, 18 Apr 2003 10:51:39 -0400 Message-ID: <3990.1050677499@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/693 X-Sequence-Number: 38183 Stephan Szabo writes: > Argh. I'm getting that state where gprof returns all 0s for times. I'm > pretty sure this has come up before along with how to get it to work, but > I couldn't find it in the archives. Someday I'll learn how to use gprof. :( You're on Linux? You need to compile postmaster.c with -DLINUX_PROFILE. But the call counts do sound pretty damning. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Apr 18 11:01:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E2B3F475E91 for ; Fri, 18 Apr 2003 11:01:24 -0400 (EDT) Received: from mail.cs.umass.edu (loki.cs.umass.edu [128.119.243.168]) by postgresql.org (Postfix) with ESMTP id ACEA6475458 for ; Fri, 18 Apr 2003 11:01:23 -0400 (EDT) Received: from phobos.cs.umass.edu (phobos.cs.umass.edu [128.119.243.161]) by mail.cs.umass.edu (8.12.6/8.12.5) with ESMTP id h3IF1Qjh025960 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Fri, 18 Apr 2003 11:01:26 -0400 Date: Fri, 18 Apr 2003 11:01:18 -0400 (EDT) From: Victor Danilchenko To: Nikolaus Dilger Cc: pgsql-performance@postgresql.org Subject: Re: Query speed problems In-Reply-To: <20030417182613.4395.h015.c001.wm@mail.dilger.cc.criticalpath.net> Message-ID: References: <20030417182613.4395.h015.c001.wm@mail.dilger.cc.criticalpath.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checked: This message probably not SPAM X-Spam-Score: -28.9, Required: 5 X-Spam-Tests: EMAIL_ATTRIBUTION, IN_REP_TO, REFERENCES, REPLY_WITH_QUOTES, USER_AGENT_PINE X-Scanned-By: MIMEDefang 2.30 (www . roaringpenguin . com / mimedefang) X-Spam-Status: No, hits=-35.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/169 X-Sequence-Number: 1675 On Thu, 17 Apr 2003, Nikolaus Dilger wrote: >Victor, > >What is the issue? You get sub second response time. The issue is that the query is a part of *user interface*, as I wrote in my original message; and there is a small number of such queries (about 3) that run per each user action. A second-long wait in *UI* is unacceptable -- people tend to find even third-of-a-second wait to be annoying. UI interactions should be so fast as to appear nearly instant. >Why waste your time trying to make it faster? Well, there's also the learning aspect of it -- this is my first major SQL project, and I am trying to understand as much as I can about under-the-surface stuff. Thanks to Peter Darley, I already have a fast solution -- now I simply want to understand more about the performance issues inherent in reverse-lookup subqueries. >If you have a query that runs serveral minutes or hours >then its worthwhile tuning. Or if your query gets >executed several thausend times a day. -- | Victor Danilchenko | Of course my password is the same as | | danilche@cs.umass.edu | my pet's name. My macaw's name was | | CSCF | 5-4231 | Q47pY!3, but I change it every 90 days. | From pgsql-hackers-owner@postgresql.org Fri Apr 18 11:13:07 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B60E7475FFF for ; Fri, 18 Apr 2003 11:13:05 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D84B4475458 for ; Fri, 18 Apr 2003 11:12:34 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id ADCA9D624; Fri, 18 Apr 2003 08:12:39 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9F44B5C02; Fri, 18 Apr 2003 08:12:39 -0700 (PDT) Date: Fri, 18 Apr 2003 08:12:39 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <3990.1050677499@sss.pgh.pa.us> Message-ID: <20030418080950.R2132-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-25.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/695 X-Sequence-Number: 38185 On Fri, 18 Apr 2003, Tom Lane wrote: > Stephan Szabo writes: > > Argh. I'm getting that state where gprof returns all 0s for times. I'm > > pretty sure this has come up before along with how to get it to work, but > > I couldn't find it in the archives. Someday I'll learn how to use gprof. :( > > You're on Linux? You need to compile postmaster.c with -DLINUX_PROFILE. Yep, thanks. :) > But the call counts do sound pretty damning. Yeah, but even with my hack last night it was still appreciably slower than immediate constraints. Comparing the call counts in that function for the immediate versus deferred(hacked) weren't giving me a good idea of where that time was going. From pgsql-performance-owner@postgresql.org Sat Apr 19 09:01:46 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 730B6475B85 for ; Sat, 19 Apr 2003 09:01:43 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id A7F6A4758C9 for ; Sat, 19 Apr 2003 09:01:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sat, 19 Apr 2003 06:01:46 -0700 Date: Sat, 19 Apr 2003 06:01:46 -0700 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030419130146.GI1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200304090918.45275.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <200304090918.45275.josh@agliodbs.com> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/170 X-Sequence-Number: 1676 Josh Berkus wrote: > Denis, > > > Are you saying the 7.4 'group by' trick would be faster than the simple > > select count(*)? That seems hard to believe, being that the request now has > > to fetch / sort the data. I must be missing something. > > No, I'm saying that the 7.4 hash-aggregate is faster than the same query was > under 7.2 or 7.3. Much faster. But it does little to speed up a raw > count(*). > > > The kind of requests that I am really interested in are: > > select count(*) from table where table.column like 'pattern%' > > > These seems to go much master on mysql (which I guess it not a MVCC > > database? or wasn't the Innobase supposed to make it so?), > > They did incorporate a lot of MVCC logic into InnoDB tables, yes. > Which means that if SELECT count(*) on an InnoDB table is just as > fast as a MyISAM table, then it is not accurate. This is not necessarily true. The trigger-based approach to tracking the current number of rows in a table might well be implemented internally, and that may actually be much faster than doing it using triggers (the performance losses you saw may well have been the result of PG's somewhat poor trigger performance, and not the result of the approach itself. It would be interesting to know how triggers effect the performance of other databases). -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Sat Apr 19 11:58:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5383F476182 for ; Sat, 19 Apr 2003 11:58:44 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8FB9C476128 for ; Sat, 19 Apr 2003 11:58:43 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3JFwmU6021956; Sat, 19 Apr 2003 11:58:48 -0400 (EDT) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <20030419130146.GI1847@filer> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> Comments: In-reply-to Kevin Brown message dated "Sat, 19 Apr 2003 06:01:46 -0700" Date: Sat, 19 Apr 2003 11:58:48 -0400 Message-ID: <21955.1050767928@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/171 X-Sequence-Number: 1677 Kevin Brown writes: > Josh Berkus wrote: >> They did incorporate a lot of MVCC logic into InnoDB tables, yes. >> Which means that if SELECT count(*) on an InnoDB table is just as >> fast as a MyISAM table, then it is not accurate. > This is not necessarily true. The trigger-based approach to tracking > the current number of rows in a table might well be implemented > internally, and that may actually be much faster than doing it using > triggers You missed the point of Josh's comment: in an MVCC system, the correct COUNT() varies depending on which transaction is asking. Therefore it is not possible for a centrally maintained row counter to give accurate results to everybody, no matter how cheap it is to maintain. (The cheapness can be disputed as well, since it creates a single point of contention for all inserts and deletes on the table. But that's a different topic.) regards, tom lane From pgsql-hackers-owner@postgresql.org Sat Apr 19 15:03:07 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D8757475F00 for ; Sat, 19 Apr 2003 15:03:06 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id D5F30475AA9 for ; Sat, 19 Apr 2003 15:03:01 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 4F5AFD60D; Sat, 19 Apr 2003 12:03:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 451555C03; Sat, 19 Apr 2003 12:03:02 -0700 (PDT) Date: Sat, 19 Apr 2003 12:03:02 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <20030418080950.R2132-100000@megazone23.bigpanda.com> Message-ID: <20030419114146.E18449-200000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-194152151-1050778982=:18449" X-Spam-Status: No, hits=-13.0 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/716 X-Sequence-Number: 38206 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-194152151-1050778982=:18449 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 18 Apr 2003, Stephan Szabo wrote: > On Fri, 18 Apr 2003, Tom Lane wrote: > > > But the call counts do sound pretty damning. > > Yeah, but even with my hack last night it was still appreciably slower > than immediate constraints. Comparing the call counts in that function > for the immediate versus deferred(hacked) weren't giving me a good idea of > where that time was going. This last was due to assert checking I think. AllocSetCheck was the big time waster on the hacked deferred case. Turning off assert checking I get: Median over 3 100000 inserts in one transaction (excepting the original code which took a really long time so I ran it once) from time psql ... No Fk 24.14s Immediate FK 42.80s Original Deferred FK 1862.06s Hacked Deferred FK 35.30s The hack was just the keeping around the list pointer from the last run through (see attached - passed simple fk tests and regression, but there might be problems I don't see). Looking at the code, I also wonder if we would get some gain by not allocating the per_tuple_context at the beginning but only when a non-deferred constraint is found since otherwise we're creating and destroying the context and possibly never using it. The cost would presumably be some boolean tests inside the inner loop. --0-194152151-1050778982=:18449 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="trigger.patch" Content-Transfer-Encoding: BASE64 Content-ID: <20030419120302.O18449@megazone23.bigpanda.com> Content-Description: Content-Disposition: attachment; filename="trigger.patch" KioqIHNyYy9iYWNrZW5kL2NvbW1hbmRzL3RyaWdnZXIuYwkyMDAzLTA0LTE5 IDEyOjQxOjI0LjAwMDAwMDAwMCAtMDcwMA0KLS0tIHNyYy9iYWNrZW5kL2Nv bW1hbmRzL3RyaWdnZXIuaGFjazEuYwkyMDAzLTA0LTE5IDEzOjQxOjE3LjAw MDAwMDAwMCAtMDcwMA0KKioqKioqKioqKioqKioqDQoqKiogMTYyNiwxNjM3 ICoqKioNCi0tLSAxNjI2LDE2NDMgLS0tLQ0KICAgKiBCZWNhdXNlIHRoaXMg Y2FuIGdyb3cgcHJldHR5IGxhcmdlLCB3ZSBkb24ndCB1c2Ugc2VwYXJhdGUg TGlzdCBub2RlcywNCiAgICogYnV0IGluc3RlYWQgdGhyZWFkIHRoZSBsaXN0 IHRocm91Z2ggdGhlIGR0ZV9uZXh0IGZpZWxkcyBvZiB0aGUgbWVtYmVyDQog ICAqIG5vZGVzLiAgU2F2ZXMganVzdCBhIGZldyBieXRlcyBwZXIgZW50cnks IGJ1dCB0aGF0IGFkZHMgdXAuDQorICAqIA0KKyAgKiBkZWZ0cmlnX2V2ZW50 c19pbW0gaG9sZHMgdGhlIHRhaWwgcG9pbnRlciBhcyBvZiB0aGUgbGFzdCAN CisgICogZGVmZXJyZWRUcmlnZ2VySW52b2tlRXZlbnRzIGNhbGwsIHNpbmNl IGdlbmVyYWxseSBpbW1lZGlhdGUgdHJpZ2dlcnMNCisgICogY2FuJ3QgZXhp c3QgYmVmb3JlIHRoaXMgcG9pbnQgKHNpbmNlIHRoZXkgc2hvdWxkIGFscmVh ZHkgaGF2ZSBiZWVuDQorICAqIGNhbGxlZCkgZXhjZXB0aW5nIFNFVCBDT05T VFJBSU5UUw0KICAgKg0KICAgKiBYWFggTmVlZCB0byBiZSBhYmxlIHRvIHNo b3ZlIHRoaXMgZGF0YSBvdXQgdG8gYSBmaWxlIGlmIGl0IGdyb3dzIHRvbw0K ICAgKgkgICBsYXJnZS4uLg0KICAgKiAtLS0tLS0tLS0tDQogICAqLw0KICBz dGF0aWMgRGVmZXJyZWRUcmlnZ2VyRXZlbnQgZGVmdHJpZ19ldmVudHM7DQor IHN0YXRpYyBEZWZlcnJlZFRyaWdnZXJFdmVudCBkZWZ0cmlnX2V2ZW50c19p bW07DQogIHN0YXRpYyBEZWZlcnJlZFRyaWdnZXJFdmVudCBkZWZ0cmlnX2V2 ZW50X3RhaWw7DQogIA0KICANCioqKioqKioqKioqKioqKg0KKioqIDE4NDQs MTg1MCAqKioqDQogIHN0YXRpYyB2b2lkDQogIGRlZmVycmVkVHJpZ2dlcklu dm9rZUV2ZW50cyhib29sIGltbWVkaWF0ZV9vbmx5KQ0KICB7DQohIAlEZWZl cnJlZFRyaWdnZXJFdmVudCBldmVudCwNCiAgCQkJCXByZXZfZXZlbnQgPSBO VUxMOw0KICAJTWVtb3J5Q29udGV4dCBwZXJfdHVwbGVfY29udGV4dDsNCiAg CVJlbGF0aW9uCXJlbCA9IE5VTEw7DQotLS0gMTg1MCwxODU2IC0tLS0NCiAg c3RhdGljIHZvaWQNCiAgZGVmZXJyZWRUcmlnZ2VySW52b2tlRXZlbnRzKGJv b2wgaW1tZWRpYXRlX29ubHkpDQogIHsNCiEgCURlZmVycmVkVHJpZ2dlckV2 ZW50IGV2ZW50ID0gTlVMTCwNCiAgCQkJCXByZXZfZXZlbnQgPSBOVUxMOw0K ICAJTWVtb3J5Q29udGV4dCBwZXJfdHVwbGVfY29udGV4dDsNCiAgCVJlbGF0 aW9uCXJlbCA9IE5VTEw7DQoqKioqKioqKioqKioqKioNCioqKiAxODY5LDE4 ODAgKioqKg0KICAJLyogTWFrZSBhIHBlci10dXBsZSBtZW1vcnkgY29udGV4 dCBmb3IgdHJpZ2dlciBmdW5jdGlvbiBjYWxscyAqLw0KICAJcGVyX3R1cGxl X2NvbnRleHQgPQ0KICAJCUFsbG9jU2V0Q29udGV4dENyZWF0ZShDdXJyZW50 TWVtb3J5Q29udGV4dCwNCiEgCQkJCQkJCSAgIkRlZmVycmVkVHJpZ2dlclR1 cGxlQ29udGV4dCIsDQohIAkJCQkJCQkgIEFMTE9DU0VUX0RFRkFVTFRfTUlO U0laRSwNCiEgCQkJCQkJCSAgQUxMT0NTRVRfREVGQVVMVF9JTklUU0laRSwN CiEgCQkJCQkJCSAgQUxMT0NTRVRfREVGQVVMVF9NQVhTSVpFKTsNCiAgDQot IAlldmVudCA9IGRlZnRyaWdfZXZlbnRzOw0KICAJd2hpbGUgKGV2ZW50ICE9 IE5VTEwpDQogIAl7DQogIAkJYm9vbAkJc3RpbGxfZGVmZXJyZWRfb25lcyA9 IGZhbHNlOw0KLS0tIDE4NzUsMTg5NyAtLS0tDQogIAkvKiBNYWtlIGEgcGVy LXR1cGxlIG1lbW9yeSBjb250ZXh0IGZvciB0cmlnZ2VyIGZ1bmN0aW9uIGNh bGxzICovDQogIAlwZXJfdHVwbGVfY29udGV4dCA9DQogIAkJQWxsb2NTZXRD b250ZXh0Q3JlYXRlKEN1cnJlbnRNZW1vcnlDb250ZXh0LA0KISAJCQkgICJE ZWZlcnJlZFRyaWdnZXJUdXBsZUNvbnRleHQiLA0KISAJCQkgIEFMTE9DU0VU X0RFRkFVTFRfTUlOU0laRSwNCiEgCQkJICBBTExPQ1NFVF9ERUZBVUxUX0lO SVRTSVpFLA0KISAJCQkgIEFMTE9DU0VUX0RFRkFVTFRfTUFYU0laRSk7DQoh IA0KISAJLyoNCiEgCSAqIElmIGltbWVkaWF0ZV9vbmx5IGlzIHRydWUsIHRo ZW4gdGhlIG9ubHkgZXZlbnRzIHRoYXQgY291bGQgaGF2ZSBmaXJlZA0KISAJ ICogYXJlIHRob3NlIHNpbmNlIGRlZnRyaWdfZXZlbnRzX2ltbS4gIA0KISAJ ICogVGhlIG9uZSBleGNlcHRpb24gdG8gb25seSBzaW5jZSBkZWZ0cmlnX2V2 ZW50c19pbW0gd291bGQgYmUgDQohIAkgKiBTRVQgQ09OU1RSQUlOVFMgLi4u IElNTUVESUFURSBzbyB3ZSBzZXQgaXQgdG8gTlVMTCBpbiB0aGVyZQ0KISAJ ICogYW5kIHRyZWF0IE5VTEwgYXMgYmVpbmcgZXF1aXZhbGVudCB0byB0aGUg ZW50aXJlIGxpc3QuDQohIAkgKi8NCiEgCWlmIChpbW1lZGlhdGVfb25seSkg DQohIAkJZXZlbnQgPSBkZWZ0cmlnX2V2ZW50c19pbW07DQohIAlpZiAoZXZl bnQgPT0gTlVMTCkNCiEgCQlldmVudCA9IGRlZnRyaWdfZXZlbnRzOw0KICAN CiAgCXdoaWxlIChldmVudCAhPSBOVUxMKQ0KICAJew0KICAJCWJvb2wJCXN0 aWxsX2RlZmVycmVkX29uZXMgPSBmYWxzZTsNCioqKioqKioqKioqKioqKg0K KioqIDE5OTMsMjAwNCAqKioqDQotLS0gMjAxMCwyMDI1IC0tLS0NCiAgCS8q IFVwZGF0ZSBsaXN0IHRhaWwgcG9pbnRlciBpbiBjYXNlIHdlIGp1c3QgZGVs ZXRlZCB0YWlsIGV2ZW50ICovDQogIAlkZWZ0cmlnX2V2ZW50X3RhaWwgPSBw cmV2X2V2ZW50Ow0KICANCisgCS8qIFNldCB0aGUgaW1tZWRpYXRlIGV2ZW50 IHBvaW50ZXIgdG8gdGhlIHRhaWwgKi8NCisgCWRlZnRyaWdfZXZlbnRzX2lt bSA9IHByZXZfZXZlbnQ7DQorIA0KICAJLyogUmVsZWFzZSB3b3JraW5nIHJl c291cmNlcyAqLw0KICAJaWYgKHJlbCkNCiAgCQloZWFwX2Nsb3NlKHJlbCwg Tm9Mb2NrKTsNCiAgCUZyZWVUcmlnZ2VyRGVzYyh0cmlnZGVzYyk7DQogIAlp ZiAoZmluZm8pDQogIAkJcGZyZWUoZmluZm8pOw0KKyANCiAgCU1lbW9yeUNv bnRleHREZWxldGUocGVyX3R1cGxlX2NvbnRleHQpOw0KICB9DQogIA0KKioq KioqKioqKioqKioqDQoqKiogMjI3NCwyMjc5ICoqKioNCi0tLSAyMjk1LDIz MDggLS0tLQ0KICAJfQ0KICANCiAgCS8qDQorIAkgKiBSZXNldCB0aGUgcG9p bnRlciBmb3IgdGhlIGltbWVkaWF0ZSBjb25zdHJhaW50cyB0byBOVUxMIChp ZQ0KKyAJICogdXNlIGJlZ2lubmluZyBvZiBsaXN0KS4gIFRoaXMgaXMgcmVh bGx5IG9ubHkgbmVjZXNzYXJ5IGZvcg0KKyAJICogZGVhbGluZyB3aGVuIHNl dHRpbmcgdG8gSU1NRURJQVRFLCBhbmQgY291bGQgcmVhbGx5IHBvaW50DQor IAkgKiB0aGUgZmlyc3QgY29uc3RyYWludCB3ZSBjaGFuZ2VkLCBidXQgZm9y IG5vdyB0aGlzIHdpbGwgZG8uDQorIAkgKi8NCisgCWRlZnRyaWdfZXZlbnRz X2ltbSA9IE5VTEw7DQorIA0KKyAJLyoNCiAgCSAqIFNRTDk5IHJlcXVpcmVz IHRoYXQgd2hlbiBhIGNvbnN0cmFpbnQgaXMgc2V0IHRvIElNTUVESUFURSwg YW55DQogIAkgKiBkZWZlcnJlZCBjaGVja3MgYWdhaW5zdCB0aGF0IGNvbnN0 cmFpbnQgbXVzdCBiZSBtYWRlIHdoZW4gdGhlIFNFVA0KICAJICogQ09OU1RS QUlOVFMgY29tbWFuZCBpcyBleGVjdXRlZCAtLSBpLmUuIHRoZSBlZmZlY3Rz IG9mIHRoZSBTRVQNCg== --0-194152151-1050778982=:18449-- From pgsql-performance-owner@postgresql.org Sat Apr 19 15:04:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17DB94758C9 for ; Sat, 19 Apr 2003 15:04:08 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id B0767475EE2 for ; Sat, 19 Apr 2003 15:03:36 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2975053; Sat, 19 Apr 2003 12:03:32 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Tom Lane , Kevin Brown Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Sat, 19 Apr 2003 12:03:18 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgresql.org References: <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> In-Reply-To: <21955.1050767928@sss.pgh.pa.us> MIME-Version: 1.0 Message-Id: <200304191203.18634.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-31.6 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/172 X-Sequence-Number: 1678 Kevin, Tom: > (The cheapness can be disputed as well, since it creates a single point > of contention for all inserts and deletes on the table. But that's a > different topic.) Actually, this was the problem with the trigger method of maintaining COUNT= =20 information in PostgreSQL. The statistics table itself becomes a=20 significant souce of delay, since if a table_A gets 10,000 rows updated tha= n=20 table_count_A must necessarily be updated 10,000 times ... creating a lot o= f=20 dead tuples and severely attenuating the table on disk until the next vacuu= m=20 ... resulting in Update #10,000 to table_count_A taking 100+ times as long = as=20 Update #1 does, due to the required random seek time on disk. I can personally think of two ways around this: In MySQL: store table_count_A as a non-MVCC table or global variable.=20=20 Drawback: the count would not be accurate, as you would see changes due to= =20 incomplete transactions and eventually the count would be knocked off=20 completely by an overload of multi-user activity. However, this does fit= =20 with MySQL's design philosophy of "Speed over accuracy", so I suspect that= =20 that's what they're doing. In PostgreSQL: a) Put table_count_A on superfast media like a RAM card so that random seek= s=20 after 10,000 updates do not become a significant delay; b) create an asynchronious table aggregates collector which would collect= =20 programmed statistics (like count(*) from table A) much in the same way tha= t=20 the planner statistics collector does. This would have the disadvantage of= =20 on being up to date when the database is idle, but the advantage of not=20 imposing any significant overhead on Updates. (Incidentally, I proposed this to one of my clients who complained about= =20 Postgres' slow aggregate performance, but they declined to fund the effort) --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Sat Apr 19 16:26:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6D410475AA9 for ; Sat, 19 Apr 2003 16:26:50 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 996404758C9 for ; Sat, 19 Apr 2003 16:26:49 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3JKQnU6023266; Sat, 19 Apr 2003 16:26:49 -0400 (EDT) To: Josh Berkus Cc: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <200304191203.18634.josh@agliodbs.com> References: <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <200304191203.18634.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Sat, 19 Apr 2003 12:03:18 -0700" Date: Sat, 19 Apr 2003 16:26:49 -0400 Message-ID: <23265.1050784009@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.1 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/173 X-Sequence-Number: 1679 Josh Berkus writes: > In PostgreSQL: > a) Put table_count_A on superfast media like a RAM card so that random seeks > after 10,000 updates do not become a significant delay; As long as we're talking ugly, here ;-) You could use a sequence to hold the aggregate counter. A sequence isn't transactional and so does not accumulate dead tuples. "setval()" and "select last_value" should have constant-time performance. regards, tom lane From pgsql-hackers-owner@postgresql.org Sat Apr 19 16:58:05 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 48E934758E6 for ; Sat, 19 Apr 2003 16:58:04 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A62FB4758C9 for ; Sat, 19 Apr 2003 16:58:03 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3JKw2U6023462; Sat, 19 Apr 2003 16:58:03 -0400 (EDT) To: Stephan Szabo Cc: Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance In-reply-to: <20030419114146.E18449-200000@megazone23.bigpanda.com> References: <20030419114146.E18449-200000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Sat, 19 Apr 2003 12:03:02 -0700" Date: Sat, 19 Apr 2003 16:58:02 -0400 Message-ID: <23461.1050785882@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/717 X-Sequence-Number: 38207 Stephan Szabo writes: > The hack was just the keeping around the list pointer from the last run > through (see attached - passed simple fk tests and regression, but there > might be problems I don't see). Shouldn't this patch update the comment in deferredTriggerInvokeEvents (c. line 1860 in cvs tip)? > Looking at the code, I also wonder if we > would get some gain by not allocating the per_tuple_context at the > beginning but only when a non-deferred constraint is found since otherwise > we're creating and destroying the context and possibly never using it. I doubt it's worth worrying over. Creation/destruction of a never-used memory context is pretty cheap, I think. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Apr 19 21:13:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DF5524758E6 for ; Sat, 19 Apr 2003 21:13:34 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id AD96A4758C9 for ; Sat, 19 Apr 2003 21:13:33 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sat, 19 Apr 2003 18:13:37 -0700 Date: Sat, 19 Apr 2003 18:13:37 -0700 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030420011336.GJ1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <21955.1050767928@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/174 X-Sequence-Number: 1680 Tom Lane wrote: > Kevin Brown writes: > > Josh Berkus wrote: > >> They did incorporate a lot of MVCC logic into InnoDB tables, yes. > >> Which means that if SELECT count(*) on an InnoDB table is just as > >> fast as a MyISAM table, then it is not accurate. > > > This is not necessarily true. The trigger-based approach to tracking > > the current number of rows in a table might well be implemented > > internally, and that may actually be much faster than doing it using > > triggers > > You missed the point of Josh's comment: in an MVCC system, the correct > COUNT() varies depending on which transaction is asking. Therefore it > is not possible for a centrally maintained row counter to give accurate > results to everybody, no matter how cheap it is to maintain. Hmm...true...but only if you really implement it as a faithful copy of the trigger-based method. Implementing it on the backend brings some advantages to the table, to wit: * The individual transactions don't need to update the externally-visible count on every insert or delete, they only need to update it at commit time. * The transaction can keep a count of the number of inserted and deleted tuples it generates (on a per-table basis) during the life of the transaction. The count value it returns to a client is the count value it reads from the table that stores the count value plus any differences that have been applied during the transaction. This is fast, because the backend handling the transaction can keep this difference value in its own private memory. * When a transaction commits, it only needs to apply the "diff value" it stores internally to the external count value. Contention on the count value is only an issue if the external count value is currently being written to by a transaction in the commit phase. But the only time a transaction will be interested in reading that value is when it's performing a count(*) operation or when it's committing inserts/deletes that happened on the table in question (and then only if the number of tuples inserted differs from the number deleted). So the total amount of contention should be relatively low. > (The cheapness can be disputed as well, since it creates a single point > of contention for all inserts and deletes on the table. But that's a > different topic.) That's true, but the single point of contention is only an issue at transaction commit time (unless you're implementing READ UNCOMMITTED), at least if you do something like what I described above. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Sat Apr 19 23:34:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4BBE7475EE2 for ; Sat, 19 Apr 2003 23:34:27 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 70A714758C9 for ; Sat, 19 Apr 2003 23:34:19 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3K3YOU6024736; Sat, 19 Apr 2003 23:34:24 -0400 (EDT) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <20030420011336.GJ1847@filer> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> Comments: In-reply-to Kevin Brown message dated "Sat, 19 Apr 2003 18:13:37 -0700" Date: Sat, 19 Apr 2003 23:34:24 -0400 Message-ID: <24735.1050809664@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/175 X-Sequence-Number: 1681 Kevin Brown writes: > Tom Lane wrote: >> You missed the point of Josh's comment: in an MVCC system, the correct >> COUNT() varies depending on which transaction is asking. Therefore it >> is not possible for a centrally maintained row counter to give accurate >> results to everybody, no matter how cheap it is to maintain. > Hmm...true...but only if you really implement it as a faithful copy of > the trigger-based method. > [ instead have transactions save up net deltas to apply at commit ] Good try, but it doesn't solve the problem. SERIALIZABLE transactions should not see deltas applied by any transaction that commits after they start. READ COMMITTED transactions can see such deltas --- but not deltas applied since the start of their current statement. (And there could be several different "current statements" with different snapshots in progress in a single READ COMMITTED transaction.) AFAICS, central-counter techniques could only work in an MVCC system if each transaction copies every counter in the system at each snapshot freeze point, in case it finds itself needing that counter value later on. This is a huge amount of mostly-useless overhead, and it makes the problem of lock contention for access to the counters several orders of magnitude worse than you'd first think. Of course you can dodge lots of this overhead if you're willing to accept approximate answers. But I don't believe that central counters are useful in an exact-MVCC-semantics system. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 20 02:28:54 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80203475EE2 for ; Sun, 20 Apr 2003 02:28:53 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id 9C7C54758C9 for ; Sun, 20 Apr 2003 02:28:52 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sat, 19 Apr 2003 23:28:52 -0700 Date: Sat, 19 Apr 2003 23:28:52 -0700 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030420062852.GK1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <24735.1050809664@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/176 X-Sequence-Number: 1682 Tom Lane wrote: > Kevin Brown writes: > > Tom Lane wrote: > >> You missed the point of Josh's comment: in an MVCC system, the correct > >> COUNT() varies depending on which transaction is asking. Therefore it > >> is not possible for a centrally maintained row counter to give accurate > >> results to everybody, no matter how cheap it is to maintain. > > > Hmm...true...but only if you really implement it as a faithful copy of > > the trigger-based method. > > [ instead have transactions save up net deltas to apply at commit ] > > Good try, but it doesn't solve the problem. SERIALIZABLE transactions > should not see deltas applied by any transaction that commits after > they start. READ COMMITTED transactions can see such deltas --- but not > deltas applied since the start of their current statement. (And there > could be several different "current statements" with different snapshots > in progress in a single READ COMMITTED transaction.) This is why I suspect the best way to manage this would be to manage the counter itself using the MVCC mechanism (that is, you treat the shared counter as a row in a table just like any other and, in fact, it might be most beneficial for it to actually be exactly that), which handles the visibility problem automatically. But I don't know how much contention there would be as a result. > Of course you can dodge lots of this overhead if you're willing to > accept approximate answers. But I don't believe that central counters > are useful in an exact-MVCC-semantics system. No, but an MVCC-managed counter would be useful in such a system, wouldn't it? Or am I missing something there, too (the deltas themselves would be managed as described, and would be applied as described)? So: how much contention would there be if the counter were managed in exactly the same way as any row of a table is managed? Because I'm not terribly familiar with how PG manages MVCC (pointers to documentation on it welcomed) I can't answer that question myself. -- Kevin Brown kevin@sysexperts.com From pgsql-hackers-owner@postgresql.org Sun Apr 20 02:56:57 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9F19047580B for ; Sun, 20 Apr 2003 02:56:56 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 265EE474E4F for ; Sun, 20 Apr 2003 02:56:56 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 83552D60D; Sat, 19 Apr 2003 23:56:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 790F45C03; Sat, 19 Apr 2003 23:56:56 -0700 (PDT) Date: Sat, 19 Apr 2003 23:56:56 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <23461.1050785882@sss.pgh.pa.us> Message-ID: <20030419235530.S23637-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/721 X-Sequence-Number: 38211 On Sat, 19 Apr 2003, Tom Lane wrote: > Stephan Szabo writes: > > The hack was just the keeping around the list pointer from the last run > > through (see attached - passed simple fk tests and regression, but there > > might be problems I don't see). > > Shouldn't this patch update the comment in deferredTriggerInvokeEvents > (c. line 1860 in cvs tip)? Probably, since the second part of that is basically what this is. I'll update and send updated patch tomorrow. > > Looking at the code, I also wonder if we > > would get some gain by not allocating the per_tuple_context at the > > beginning but only when a non-deferred constraint is found since otherwise > > we're creating and destroying the context and possibly never using it. > > I doubt it's worth worrying over. Creation/destruction of a never-used > memory context is pretty cheap, I think. Okay, sounds good enough for me. :) From pgsql-performance-owner@postgresql.org Sun Apr 20 06:07:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 66A76475D0F for ; Sun, 20 Apr 2003 06:07:49 -0400 (EDT) Received: from smtp.web.de (smtp01.web.de [217.72.192.180]) by postgresql.org (Postfix) with ESMTP id 9C8EC47580B for ; Sun, 20 Apr 2003 06:07:48 -0400 (EDT) Received: from p50818c34.dip0.t-ipconnect.de ([80.129.140.52] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 197Bji-0001Ux-00 for pgsql-performance@postgresql.org; Sun, 20 Apr 2003 12:07:50 +0200 Message-ID: <3EA27179.6010307@web.de> Date: Sun, 20 Apr 2003 12:07:53 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> In-Reply-To: <20030420062852.GK1847@filer> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_NJABL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/177 X-Sequence-Number: 1683 Kevin Brown wrote: > >No, but an MVCC-managed counter would be useful in such a system, >wouldn't it? Or am I missing something there, too (the deltas >themselves would be managed as described, and would be applied as >described)? > >So: how much contention would there be if the counter were managed in >exactly the same way as any row of a table is managed? Because I'm >not terribly familiar with how PG manages MVCC (pointers to >documentation on it welcomed) I can't answer that question myself. > > > It looks to me that a "row number -1" really would solve this problem. I think a row counter on each table would be even useful for some kind of auto-vacuum mechanism, that could be triggered if pg_class.reltuples deviates too far from the real row count. Observing this mailing list, missing or outdated statistics still seem to be a major source of performance degradation. We all know these 1000 row estimates from EXPLAIN, don't we? A default vacuum strategy for pgsql newbies should solve a lot of those problems, preventing a lot of "pgsql is slow" threads. Regards, Andreas From pgsql-performance-owner@postgresql.org Sun Apr 20 11:21:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26FD1476355 for ; Sun, 20 Apr 2003 11:21:29 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4C9A3476369 for ; Sun, 20 Apr 2003 11:21:28 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3KFLXU6026962; Sun, 20 Apr 2003 11:21:33 -0400 (EDT) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <20030420062852.GK1847@filer> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> Comments: In-reply-to Kevin Brown message dated "Sat, 19 Apr 2003 23:28:52 -0700" Date: Sun, 20 Apr 2003 11:21:32 -0400 Message-ID: <26961.1050852092@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/178 X-Sequence-Number: 1684 Kevin Brown writes: > This is why I suspect the best way to manage this would be to manage > the counter itself using the MVCC mechanism (that is, you treat the > shared counter as a row in a table just like any other and, in fact, > it might be most beneficial for it to actually be exactly that), which > handles the visibility problem automatically. But I don't know how > much contention there would be as a result. Hm. Contention probably wouldn't be the killer, since if transactions don't try to update the count until they are about to commit, they won't be holding the row lock for long. (You'd have to beware of deadlocks between transactions that need to update multiple counters, but that seems soluble.) What *would* be a problem is that such counter tables would accumulate huge numbers of dead rows very quickly, making it inefficient to find the live row. Josh already mentioned this as a problem with user-trigger-based counting. You could stanch the bleeding with sufficiently frequent vacuums, perhaps, but it just doesn't look very appealing. Ultimately what this comes down to is "how much overhead are we willing to load onto all other operations in order to make SELECT-COUNT(*)-with- no-WHERE-clause fast"? Postgres has made a set of design choices that favor the other operations. If you've designed an application that lives or dies by fast COUNT(*), perhaps you should choose another database. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 20 11:25:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BAFC7476315 for ; Sun, 20 Apr 2003 11:25:25 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 1D83A475FEE for ; Sun, 20 Apr 2003 11:25:25 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3KFPTU6027005; Sun, 20 Apr 2003 11:25:29 -0400 (EDT) To: Andreas Pflug Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <3EA27179.6010307@web.de> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> <3EA27179.6010307@web.de> Comments: In-reply-to Andreas Pflug message dated "Sun, 20 Apr 2003 12:07:53 +0200" Date: Sun, 20 Apr 2003 11:25:29 -0400 Message-ID: <27004.1050852329@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/179 X-Sequence-Number: 1685 Andreas Pflug writes: > I think a row counter on each table would be even useful for some kind > of auto-vacuum mechanism, that could be triggered if pg_class.reltuples > deviates too far from the real row count. It would be counting the wrong thing. auto-vacuum needs to know how many dead tuples are in a table, not how many live ones. Example: UPDATE doesn't change the live-tuple count (without this property, I don't think the sort of count maintenance Kevin is proposing could possibly be efficient enough to be interesting). But it does create a dead tuple that vacuum wants to know about. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 20 11:38:01 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26874475CA9 for ; Sun, 20 Apr 2003 11:38:00 -0400 (EDT) Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by postgresql.org (Postfix) with ESMTP id 6E62747580B for ; Sun, 20 Apr 2003 11:37:59 -0400 (EDT) Received: from p5081845f.dip0.t-ipconnect.de ([80.129.132.95] helo=web.de) by smtp.web.de with asmtp (TLSv1:RC4-MD5:128) (WEB.DE(Exim) 4.97 #53) id 197GtB-0001De-00; Sun, 20 Apr 2003 17:37:57 +0200 Message-ID: <3EA2BED5.9010707@web.de> Date: Sun, 20 Apr 2003 17:37:57 +0200 From: Andreas Pflug User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> <3EA27179.6010307@web.de> <27004.1050852329@sss.pgh.pa.us> In-Reply-To: <27004.1050852329@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-34.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,RCVD_IN_NJABL, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/180 X-Sequence-Number: 1686 Tom Lane wrote: >It would be counting the wrong thing. auto-vacuum needs to know how >many dead tuples are in a table, not how many live ones. Example: >UPDATE doesn't change the live-tuple count (without this property, >I don't think the sort of count maintenance Kevin is proposing could >possibly be efficient enough to be interesting). But it does create >a dead tuple that vacuum wants to know about. > > > I understand your point, but is this about VACUUM only or VACUUM ANALYZE too? People wouldn't bother about big databases if it's still fast (until the disk is full :-) Do dead tuples affect query planning? I thought the plan only cares about existing rows and their data patterns. So count(*), pg_stat_all_tables.n_tup_ins, .n_tup_upd and .n_tup_del all together can make a VACUUM ANALYZE necessary, right? Regards, Andreas From pgsql-hackers-owner@postgresql.org Sun Apr 20 12:04:12 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91361475CA9 for ; Sun, 20 Apr 2003 12:04:11 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 04EA647580B for ; Sun, 20 Apr 2003 12:04:07 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D5AE0D611; Sun, 20 Apr 2003 09:04:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C11865C03; Sun, 20 Apr 2003 09:04:10 -0700 (PDT) Date: Sun, 20 Apr 2003 09:04:10 -0700 (PDT) From: Stephan Szabo To: Tom Lane Cc: Kevin Brown , Subject: Re: [PERFORM] Foreign key performance In-Reply-To: <20030419235530.S23637-100000@megazone23.bigpanda.com> Message-ID: <20030420090304.F28973-200000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-176117628-1050854650=:28973" X-Spam-Status: No, hits=-13.0 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/723 X-Sequence-Number: 38213 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-176117628-1050854650=:28973 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 19 Apr 2003, Stephan Szabo wrote: > On Sat, 19 Apr 2003, Tom Lane wrote: > > > Stephan Szabo writes: > > > The hack was just the keeping around the list pointer from the last run > > > through (see attached - passed simple fk tests and regression, but there > > > might be problems I don't see). > > > > Shouldn't this patch update the comment in deferredTriggerInvokeEvents > > (c. line 1860 in cvs tip)? > > Probably, since the second part of that is basically what this is. I'll > update and send updated patch tomorrow. Okay, this changes the second paragraph of that comment. I left in the comment that's really similar next to where I actually do the selection of which start point to use. --0-176117628-1050854650=:28973 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="trigger.patch" Content-Transfer-Encoding: BASE64 Content-ID: <20030420090410.N28973@megazone23.bigpanda.com> Content-Description: Content-Disposition: attachment; filename="trigger.patch" SW5kZXg6IHNyYy9iYWNrZW5kL2NvbW1hbmRzL3RyaWdnZXIuYw0KPT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PQ0KUkNTIGZpbGU6IC9wcm9qZWN0cy9jdnNyb290 L3Bnc3FsLXNlcnZlci9zcmMvYmFja2VuZC9jb21tYW5kcy90cmlnZ2VyLmMs dg0KcmV0cmlldmluZyByZXZpc2lvbiAxLjE0Nw0KZGlmZiAtYyAtcjEuMTQ3 IHRyaWdnZXIuYw0KKioqIHNyYy9iYWNrZW5kL2NvbW1hbmRzL3RyaWdnZXIu YwkyMDAzLzAzLzMxIDIwOjQ3OjUxCTEuMTQ3DQotLS0gc3JjL2JhY2tlbmQv Y29tbWFuZHMvdHJpZ2dlci5jCTIwMDMvMDQvMjAgMTY6MDE6NTUNCioqKioq KioqKioqKioqKg0KKioqIDE2MjYsMTYzNyAqKioqDQotLS0gMTYyNiwxNjQz IC0tLS0NCiAgICogQmVjYXVzZSB0aGlzIGNhbiBncm93IHByZXR0eSBsYXJn ZSwgd2UgZG9uJ3QgdXNlIHNlcGFyYXRlIExpc3Qgbm9kZXMsDQogICAqIGJ1 dCBpbnN0ZWFkIHRocmVhZCB0aGUgbGlzdCB0aHJvdWdoIHRoZSBkdGVfbmV4 dCBmaWVsZHMgb2YgdGhlIG1lbWJlcg0KICAgKiBub2Rlcy4gIFNhdmVzIGp1 c3QgYSBmZXcgYnl0ZXMgcGVyIGVudHJ5LCBidXQgdGhhdCBhZGRzIHVwLg0K KyAgKiANCisgICogZGVmdHJpZ19ldmVudHNfaW1tIGhvbGRzIHRoZSB0YWls IHBvaW50ZXIgYXMgb2YgdGhlIGxhc3QgDQorICAqIGRlZmVycmVkVHJpZ2dl ckludm9rZUV2ZW50cyBjYWxsLCBzaW5jZSBnZW5lcmFsbHkgaW1tZWRpYXRl IHRyaWdnZXJzDQorICAqIGNhbid0IGV4aXN0IGJlZm9yZSB0aGlzIHBvaW50 IChzaW5jZSB0aGV5IHNob3VsZCBhbHJlYWR5IGhhdmUgYmVlbg0KKyAgKiBj YWxsZWQpIGV4Y2VwdGluZyBTRVQgQ09OU1RSQUlOVFMNCiAgICoNCiAgICog WFhYIE5lZWQgdG8gYmUgYWJsZSB0byBzaG92ZSB0aGlzIGRhdGEgb3V0IHRv IGEgZmlsZSBpZiBpdCBncm93cyB0b28NCiAgICoJICAgbGFyZ2UuLi4NCiAg ICogLS0tLS0tLS0tLQ0KICAgKi8NCiAgc3RhdGljIERlZmVycmVkVHJpZ2dl ckV2ZW50IGRlZnRyaWdfZXZlbnRzOw0KKyBzdGF0aWMgRGVmZXJyZWRUcmln Z2VyRXZlbnQgZGVmdHJpZ19ldmVudHNfaW1tOw0KICBzdGF0aWMgRGVmZXJy ZWRUcmlnZ2VyRXZlbnQgZGVmdHJpZ19ldmVudF90YWlsOw0KICANCiAgDQoq KioqKioqKioqKioqKioNCioqKiAxODQ0LDE4NTAgKioqKg0KICBzdGF0aWMg dm9pZA0KICBkZWZlcnJlZFRyaWdnZXJJbnZva2VFdmVudHMoYm9vbCBpbW1l ZGlhdGVfb25seSkNCiAgew0KISAJRGVmZXJyZWRUcmlnZ2VyRXZlbnQgZXZl bnQsDQogIAkJCQlwcmV2X2V2ZW50ID0gTlVMTDsNCiAgCU1lbW9yeUNvbnRl eHQgcGVyX3R1cGxlX2NvbnRleHQ7DQogIAlSZWxhdGlvbglyZWwgPSBOVUxM Ow0KLS0tIDE4NTAsMTg1NiAtLS0tDQogIHN0YXRpYyB2b2lkDQogIGRlZmVy cmVkVHJpZ2dlckludm9rZUV2ZW50cyhib29sIGltbWVkaWF0ZV9vbmx5KQ0K ICB7DQohIAlEZWZlcnJlZFRyaWdnZXJFdmVudCBldmVudCA9IE5VTEwsDQog IAkJCQlwcmV2X2V2ZW50ID0gTlVMTDsNCiAgCU1lbW9yeUNvbnRleHQgcGVy X3R1cGxlX2NvbnRleHQ7DQogIAlSZWxhdGlvbglyZWwgPSBOVUxMOw0KKioq KioqKioqKioqKioqDQoqKiogMTg1NywxODgwICoqKioNCiAgCSAqIGFyZSBn b2luZyB0byBkaXNjYXJkIHRoZSB3aG9sZSBldmVudCBxdWV1ZSBvbiByZXR1 cm4gYW55d2F5LCBzbyBubw0KICAJICogbmVlZCB0byBib3RoZXIgd2l0aCAi cmV0YWlsIiBwZnJlZSdzLg0KICAJICoNCiEgCSAqIEluIGEgc2NlbmFyaW8g d2l0aCBtYW55IGNvbW1hbmRzIGluIGEgdHJhbnNhY3Rpb24gYW5kIG1hbnkN CiEgCSAqIGRlZmVycmVkLXRvLWVuZC1vZi10cmFuc2FjdGlvbiB0cmlnZ2Vy cywgaXQgY291bGQgZ2V0IGFubm95aW5nIHRvDQohIAkgKiByZXNjYW4gYWxs IHRoZSBkZWZlcnJlZCB0cmlnZ2VycyBhdCBlYWNoIGNvbW1hbmQgZW5kLiBU byBzcGVlZCB0aGlzDQohIAkgKiB1cCwgd2UgY291bGQgcmVtZW1iZXIgdGhl IGFjdHVhbCBlbmQgb2YgdGhlIHF1ZXVlIGF0IEVuZFF1ZXJ5IGFuZA0KISAJ ICogZXhhbWluZSBvbmx5IGV2ZW50cyB0aGF0IGFyZSBuZXdlci4gT24gc3Rh dGUgY2hhbmdlcyB3ZSBzaW1wbHkNCiEgCSAqIHJlc2V0IHRoZSBzYXZlZCBw b3NpdGlvbiB0byB0aGUgYmVnaW5uaW5nIG9mIHRoZSBxdWV1ZSBhbmQgcHJv Y2Vzcw0KISAJICogYWxsIGV2ZW50cyBvbmNlIHdpdGggdGhlIG5ldyBzdGF0 ZXMuDQogIAkgKi8NCiAgDQogIAkvKiBNYWtlIGEgcGVyLXR1cGxlIG1lbW9y eSBjb250ZXh0IGZvciB0cmlnZ2VyIGZ1bmN0aW9uIGNhbGxzICovDQogIAlw ZXJfdHVwbGVfY29udGV4dCA9DQogIAkJQWxsb2NTZXRDb250ZXh0Q3JlYXRl KEN1cnJlbnRNZW1vcnlDb250ZXh0LA0KISAJCQkJCQkJICAiRGVmZXJyZWRU cmlnZ2VyVHVwbGVDb250ZXh0IiwNCiEgCQkJCQkJCSAgQUxMT0NTRVRfREVG QVVMVF9NSU5TSVpFLA0KISAJCQkJCQkJICBBTExPQ1NFVF9ERUZBVUxUX0lO SVRTSVpFLA0KISAJCQkJCQkJICBBTExPQ1NFVF9ERUZBVUxUX01BWFNJWkUp Ow0KICANCi0gCWV2ZW50ID0gZGVmdHJpZ19ldmVudHM7DQogIAl3aGlsZSAo ZXZlbnQgIT0gTlVMTCkNCiAgCXsNCiAgCQlib29sCQlzdGlsbF9kZWZlcnJl ZF9vbmVzID0gZmFsc2U7DQotLS0gMTg2MywxODk0IC0tLS0NCiAgCSAqIGFy ZSBnb2luZyB0byBkaXNjYXJkIHRoZSB3aG9sZSBldmVudCBxdWV1ZSBvbiBy ZXR1cm4gYW55d2F5LCBzbyBubw0KICAJICogbmVlZCB0byBib3RoZXIgd2l0 aCAicmV0YWlsIiBwZnJlZSdzLg0KICAJICoNCiEgCSAqIEluIGltbWVkaWF0 ZV9vbmx5IGlzIHRydWUsIHdlIG9ubHkgY2hlY2sgZnJvbSB0aGUgZW5kIG9m IHRoZSBxdWV1ZQ0KISAJICogYXQgdGhlIHByZXZpb3VzIEludm9rZUV2ZW50 cyBhbmQgZXhhbWluZSBuZXdlciBldmVudHMuIE9uIHN0YXRlIA0KISAJICog Y2hhbmdlcyB3ZSBzaW1wbHkgcmVzZXQgdGhlIHNhdmVkIHBvc2l0aW9uIHRv IHRoZSBiZWdpbm5pbmcgb2YgDQohIAkgKiB0aGUgcXVldWUgYW5kIHByb2Nl c3MgYWxsIGV2ZW50cyBvbmNlIHdpdGggdGhlIG5ldyBzdGF0ZXMuDQogIAkg Ki8NCiAgDQogIAkvKiBNYWtlIGEgcGVyLXR1cGxlIG1lbW9yeSBjb250ZXh0 IGZvciB0cmlnZ2VyIGZ1bmN0aW9uIGNhbGxzICovDQogIAlwZXJfdHVwbGVf Y29udGV4dCA9DQogIAkJQWxsb2NTZXRDb250ZXh0Q3JlYXRlKEN1cnJlbnRN ZW1vcnlDb250ZXh0LA0KISAJCQkgICJEZWZlcnJlZFRyaWdnZXJUdXBsZUNv bnRleHQiLA0KISAJCQkgIEFMTE9DU0VUX0RFRkFVTFRfTUlOU0laRSwNCiEg CQkJICBBTExPQ1NFVF9ERUZBVUxUX0lOSVRTSVpFLA0KISAJCQkgIEFMTE9D U0VUX0RFRkFVTFRfTUFYU0laRSk7DQohIA0KISAJLyoNCiEgCSAqIElmIGlt bWVkaWF0ZV9vbmx5IGlzIHRydWUsIHRoZW4gdGhlIG9ubHkgZXZlbnRzIHRo YXQgY291bGQgaGF2ZSBmaXJlZA0KISAJICogYXJlIHRob3NlIHNpbmNlIGRl ZnRyaWdfZXZlbnRzX2ltbS4gIA0KISAJICogVGhlIG9uZSBleGNlcHRpb24g dG8gb25seSBzaW5jZSBkZWZ0cmlnX2V2ZW50c19pbW0gd291bGQgYmUgDQoh IAkgKiBTRVQgQ09OU1RSQUlOVFMgLi4uIElNTUVESUFURSBzbyB3ZSBzZXQg aXQgdG8gTlVMTCBpbiB0aGVyZQ0KISAJICogYW5kIHRyZWF0IE5VTEwgYXMg YmVpbmcgZXF1aXZhbGVudCB0byB0aGUgZW50aXJlIGxpc3QuDQohIAkgKi8N CiEgCWlmIChpbW1lZGlhdGVfb25seSkgDQohIAkJZXZlbnQgPSBkZWZ0cmln X2V2ZW50c19pbW07DQohIAlpZiAoZXZlbnQgPT0gTlVMTCkNCiEgCQlldmVu dCA9IGRlZnRyaWdfZXZlbnRzOw0KICANCiAgCXdoaWxlIChldmVudCAhPSBO VUxMKQ0KICAJew0KICAJCWJvb2wJCXN0aWxsX2RlZmVycmVkX29uZXMgPSBm YWxzZTsNCioqKioqKioqKioqKioqKg0KKioqIDE5OTMsMjAwNCAqKioqDQot LS0gMjAwNywyMDIyIC0tLS0NCiAgCS8qIFVwZGF0ZSBsaXN0IHRhaWwgcG9p bnRlciBpbiBjYXNlIHdlIGp1c3QgZGVsZXRlZCB0YWlsIGV2ZW50ICovDQog IAlkZWZ0cmlnX2V2ZW50X3RhaWwgPSBwcmV2X2V2ZW50Ow0KICANCisgCS8q IFNldCB0aGUgaW1tZWRpYXRlIGV2ZW50IHBvaW50ZXIgdG8gdGhlIHRhaWwg Ki8NCisgCWRlZnRyaWdfZXZlbnRzX2ltbSA9IHByZXZfZXZlbnQ7DQorIA0K ICAJLyogUmVsZWFzZSB3b3JraW5nIHJlc291cmNlcyAqLw0KICAJaWYgKHJl bCkNCiAgCQloZWFwX2Nsb3NlKHJlbCwgTm9Mb2NrKTsNCiAgCUZyZWVUcmln Z2VyRGVzYyh0cmlnZGVzYyk7DQogIAlpZiAoZmluZm8pDQogIAkJcGZyZWUo ZmluZm8pOw0KKyANCiAgCU1lbW9yeUNvbnRleHREZWxldGUocGVyX3R1cGxl X2NvbnRleHQpOw0KICB9DQogIA0KKioqKioqKioqKioqKioqDQoqKiogMjI3 MiwyMjc3ICoqKioNCi0tLSAyMjkwLDIzMDMgLS0tLQ0KICANCiAgCQlNZW1v cnlDb250ZXh0U3dpdGNoVG8ob2xkY3h0KTsNCiAgCX0NCisgDQorIAkvKg0K KyAJICogUmVzZXQgdGhlIHBvaW50ZXIgZm9yIHRoZSBpbW1lZGlhdGUgY29u c3RyYWludHMgdG8gTlVMTCAoaWUNCisgCSAqIHVzZSBiZWdpbm5pbmcgb2Yg bGlzdCkuICBUaGlzIGlzIHJlYWxseSBvbmx5IG5lY2Vzc2FyeSBmb3INCisg CSAqIGRlYWxpbmcgd2hlbiBzZXR0aW5nIHRvIElNTUVESUFURSwgYW5kIGNv dWxkIHJlYWxseSBwb2ludA0KKyAJICogdGhlIGZpcnN0IGNvbnN0cmFpbnQg d2UgY2hhbmdlZCwgYnV0IGZvciBub3cgdGhpcyB3aWxsIGRvLg0KKyAJICov DQorIAlkZWZ0cmlnX2V2ZW50c19pbW0gPSBOVUxMOw0KICANCiAgCS8qDQog IAkgKiBTUUw5OSByZXF1aXJlcyB0aGF0IHdoZW4gYSBjb25zdHJhaW50IGlz IHNldCB0byBJTU1FRElBVEUsIGFueQ0K --0-176117628-1050854650=:28973-- From pgsql-performance-owner@postgresql.org Sun Apr 20 12:46:06 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 10ED7475FBA for ; Sun, 20 Apr 2003 12:46:05 -0400 (EDT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 4AD82475F1C for ; Sun, 20 Apr 2003 12:46:04 -0400 (EDT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 197HxC-0000yd-00 for ; Sun, 20 Apr 2003 12:46:10 -0400 Received: by dba2 (Postfix, from userid 1019) id E1636CF3A; Sun, 20 Apr 2003 12:46:09 -0400 (EDT) Date: Sun, 20 Apr 2003 12:46:09 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030420164609.GA30629@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> <26961.1050852092@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26961.1050852092@sss.pgh.pa.us> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/181 X-Sequence-Number: 1687 On Sun, Apr 20, 2003 at 11:21:32AM -0400, Tom Lane wrote: > favor the other operations. If you've designed an application that > lives or dies by fast COUNT(*), perhaps you should choose another > database. Or consider redesigning the application. The "no where clause" restriction sure smacks of poor database normalisation to me. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-hackers-owner@postgresql.org Sun Apr 20 13:09:29 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CEA9C475CA9 for ; Sun, 20 Apr 2003 13:09:28 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2BEB547580B for ; Sun, 20 Apr 2003 13:09:28 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3KH9OU6006997; Sun, 20 Apr 2003 13:09:24 -0400 (EDT) To: Stephan Szabo Cc: Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance In-reply-to: <20030420090304.F28973-200000@megazone23.bigpanda.com> References: <20030420090304.F28973-200000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Sun, 20 Apr 2003 09:04:10 -0700" Date: Sun, 20 Apr 2003 13:09:24 -0400 Message-ID: <6996.1050858564@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/727 X-Sequence-Number: 38217 Stephan Szabo writes: > Okay, this changes the second paragraph of that comment. I left in the > comment that's really similar next to where I actually do the selection of > which start point to use. This had a bit of a problem yet: the loop in deferredTriggerInvokeEvents expects 'prev_event' to point to the list entry just before 'event'. A nice byproduct of fixing that is we don't uselessly rescan the last list entry. I also tried to improve the comments a little. You can see what I actually applied at http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/trigger.c regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 20 14:09:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DA0C84763A4 for ; Sun, 20 Apr 2003 14:09:11 -0400 (EDT) Received: from www.music.mcgill.ca (improv.Music.McGill.CA [132.206.141.14]) by postgresql.org (Postfix) with ESMTP id 9DD83476366 for ; Sun, 20 Apr 2003 14:09:05 -0400 (EDT) Received: from localhost (knopke@localhost) by www.music.mcgill.ca (8.11.6/8.11.6) with ESMTP id h3KI95822015 for ; Sun, 20 Apr 2003 14:09:05 -0400 Date: Sun, 20 Apr 2003 14:09:05 -0400 (EDT) From: Ian Knopke To: pgsql-performance@postgresql.org Subject: problems Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-12.3 required=5.0 tests=BAYES_01,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/182 X-Sequence-Number: 1688 Hello, I'm not sure if this is really a problem. I'm working on a distributed web crawling system which uses several clients on different machines. Results are logged to a central Postgres system. When I start it, it works fine, but seems to slow down drastically after several hours/days. To test the database, I wrote a short Perl script which makes up random strings and inserts them, and writes the benchmark times to a logfile. Comparing the beginning and end times from the log, it seems to take the same amount of time to insert at the beginning of the process as after about twenty minutes. However, I also logged the input from vmstat, which shows the amount of memory available shrinking rapidly. Before running test program: total used free shared buffers cached Mem: 516136 120364 395772 0 4776 75884 -/+ buffers/cache: 39704 476432 Swap: 248996 0 248996 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 1 0 0 395768 4776 75888 0 0 124 27 124 236 13 2 86 0 The first 20 lines of vmstat output (3 seconds apart each, 512M total): procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 3 0 0 267676 5116 194136 0 0 74 143 123 825 32 4 64 0 3 0 0 266244 5116 195532 0 0 0 0 105 2343 85 15 0 0 1 0 0 264816 5120 196932 0 0 0 0 104 2182 89 11 0 0 2 0 0 263324 5120 198308 0 0 0 299 126 2299 90 10 0 0 1 0 0 261856 5120 199744 0 0 0 0 101 2482 92 8 0 0 1 0 0 260376 5124 201188 0 0 1 683 114 2484 93 7 0 0 2 0 0 259152 5124 202392 0 0 0 640 119 2336 91 9 0 0 3 0 0 257880 5128 203628 0 0 0 0 102 2414 86 14 0 0 2 0 0 256772 5128 204712 0 0 0 640 116 2378 92 8 0 0 Eventually the system moves to using swap and things really slow down. Interestingly, when I stop the program and shut down postgres, only some of the memory comes back. Here is the current state of my system with postgres shut down, after running the test: procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 0 252 63396 5468 373792 0 0 29 318 133 1131 37 5 58 0 I seem to be missing some memory. However, I might not understand the results from vmstat properly. Does anyone know what is going on or how I can solve this? Ian Knopke Test program: ############################################################# #!/usr/bin/perl -w ##test.pl - Program to test postgres performance use DBI; use Time::HiRes qw(gettimeofday); use IO::Socket; use IO::File; use Number::Format; my $str='abcdefghijklmnopqrstuvwxyz'; my @str=split('',$str); $SIG{INT}=\&int_stoproutine; open (LOGFILE,">testlog.txt") or die "Can't open logfile\n"; my $fmt=Number::Format->new(DECIMAL_DIGITS => 0); my $dbh=DBI->connect("DBI:Pg:dbname=inserttests",,) or die "Can't connect: $DBI::errstr\n"; my $counter=0; while(1) { my $starttime=gettimeofday(); print LOGFILE "COUNTER: $counter "; print LOGFILE "START: $starttime "; my $str=&genmystr(); print LOGFILE "STR: $str "; my $donetime=gettimeofday(); print LOGFILE "STRTIME: $donetime "; my $query_string="insert into tablea (tablea_term) values(\'$str\')"; $sth=$dbh->prepare($query_string); my $error_code=$sth->execute(); my $endtime=gettimeofday(); print LOGFILE "END: $endtime "; my $difftime=$endtime-$starttime; print LOGFILE "DIFF: $difftime\n"; $counter++; } close(LOGFILE); sub int_stoproutine { exit; } sub genmystr{ my $str=''; foreach(1 .. 8) { my $a=rand(25); my $b=$fmt->round($a); $str=$str.$str[$b]; } return $str; } -- From pgsql-performance-owner@postgresql.org Sun Apr 20 14:36:20 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1C993475A80 for ; Sun, 20 Apr 2003 14:36:20 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 42A4B47580B for ; Sun, 20 Apr 2003 14:36:19 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3KIaAU6010083; Sun, 20 Apr 2003 14:36:10 -0400 (EDT) To: Ian Knopke Cc: pgsql-performance@postgresql.org Subject: Re: problems In-reply-to: References: Comments: In-reply-to Ian Knopke message dated "Sun, 20 Apr 2003 14:09:05 -0400" Date: Sun, 20 Apr 2003 14:36:10 -0400 Message-ID: <10082.1050863770@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/183 X-Sequence-Number: 1689 Ian Knopke writes: > Comparing the beginning and end times from the log, it seems to take the > same amount of time to insert at the beginning of the process as after > about twenty minutes. However, I also logged the input from vmstat, which > shows the amount of memory available shrinking rapidly. AFAICT you are just showing us kernel disk cache expanding to fill unused memory. This is normal and not a cause for alarm. > Eventually the system moves to using swap and things really slow down. Disk cache can't cause swapping --- the kernel will just throw away cached pages when the memory is needed for something else. It could be that you have growth in the number of Postgres processes, or the sizes of individual processes, but vmstat isn't very helpful for determining that (good ol' top would be more useful). In any case you haven't actually shown us any data from the state where the system is slow, so it's a bit hard to conjecture about what's going on. Some other important information that you haven't let us in on is the platform and the Postgres version you're using. regards, tom lane From pgsql-hackers-owner@postgresql.org Sun Apr 20 20:09:33 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C802475A80 for ; Sun, 20 Apr 2003 20:09:31 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id DE3D147580B for ; Sun, 20 Apr 2003 20:09:30 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sun, 20 Apr 2003 17:09:34 -0700 Date: Sun, 20 Apr 2003 17:09:34 -0700 From: Kevin Brown To: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance Message-ID: <20030421000933.GP1833@filer> Mail-Followup-To: Kevin Brown , pgsql-hackers@postgresql.org References: <20030420090304.F28973-200000@megazone23.bigpanda.com> <6996.1050858564@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <6996.1050858564@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/730 X-Sequence-Number: 38220 Tom Lane wrote: > Stephan Szabo writes: > > Okay, this changes the second paragraph of that comment. I left in the > > comment that's really similar next to where I actually do the selection of > > which start point to use. > > This had a bit of a problem yet: the loop in deferredTriggerInvokeEvents > expects 'prev_event' to point to the list entry just before 'event'. > A nice byproduct of fixing that is we don't uselessly rescan the last list > entry. I also tried to improve the comments a little. You can see what > I actually applied at > > http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/backend/commands/trigger.c Any chance of backporting these changes to 7_3_STABLE (when you're satisfied they don't break anything)? Just looking at the CVS log for trigger.c, it appears there have been enough changes since then that it might not be easy to do (and since it's not necessarily a "bug fix" as such, it might not qualify for backporting to a stable version). Even if it's not something that can be put into another release of 7.3, it would certainly be useful to me. It might be useful to enough people to justify releasing it as a patch on -patches, if nothing else. I'd do it myself but I don't understand the trigger code at all (and if there's any documentation you can point me to that describes the various functions and supporting data structures in trigger.c, that would help a lot), and I'd rather not touch something like that until I understand it thoroughly. -- Kevin Brown kevin@sysexperts.com From pgsql-hackers-owner@postgresql.org Sun Apr 20 20:35:00 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AE2B7475A80 for ; Sun, 20 Apr 2003 20:34:58 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4E02C47580B for ; Sun, 20 Apr 2003 20:34:57 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3L0Z0U6021360; Sun, 20 Apr 2003 20:35:00 -0400 (EDT) To: Kevin Brown Cc: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance In-reply-to: <20030421000933.GP1833@filer> References: <20030420090304.F28973-200000@megazone23.bigpanda.com> <6996.1050858564@sss.pgh.pa.us> <20030421000933.GP1833@filer> Comments: In-reply-to Kevin Brown message dated "Sun, 20 Apr 2003 17:09:34 -0700" Date: Sun, 20 Apr 2003 20:35:00 -0400 Message-ID: <21359.1050885300@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/731 X-Sequence-Number: 38221 Kevin Brown writes: > Any chance of backporting these changes to 7_3_STABLE (when you're > satisfied they don't break anything)? Just looking at the CVS log for > trigger.c, it appears there have been enough changes since then that > it might not be easy to do (and since it's not necessarily a "bug fix" > as such, it might not qualify for backporting to a stable version). I'd be pretty hesitant to make such a change in the stable branch --- at least not without a lot of testing. If you and others want to provide such testing, go to it. The patch appears to apply cleanly enough to 7.3, but here's an adjusted patch if fuzz makes you nervous... regards, tom lane *** trigger.c~ Sun Apr 20 20:28:55 2003 --- trigger.c Sun Apr 20 20:29:13 2003 *************** *** 1461,1472 **** --- 1461,1478 ---- * Because this can grow pretty large, we don't use separate List nodes, * but instead thread the list through the dte_next fields of the member * nodes. Saves just a few bytes per entry, but that adds up. + * + * deftrig_events_imm holds the tail pointer as of the last + * deferredTriggerInvokeEvents call; we can use this to avoid rescanning + * entries unnecessarily. It is NULL if deferredTriggerInvokeEvents + * hasn't run since the last state change. * * XXX Need to be able to shove this data out to a file if it grows too * large... * ---------- */ static DeferredTriggerEvent deftrig_events; + static DeferredTriggerEvent deftrig_events_imm; static DeferredTriggerEvent deftrig_event_tail; *************** *** 1680,1686 **** deferredTriggerInvokeEvents(bool immediate_only) { DeferredTriggerEvent event, ! prev_event = NULL; MemoryContext per_tuple_context; Relation rel = NULL; TriggerDesc *trigdesc = NULL; --- 1686,1692 ---- deferredTriggerInvokeEvents(bool immediate_only) { DeferredTriggerEvent event, ! prev_event; MemoryContext per_tuple_context; Relation rel = NULL; TriggerDesc *trigdesc = NULL; *************** *** 1692,1704 **** * are going to discard the whole event queue on return anyway, so no * need to bother with "retail" pfree's. * ! * In a scenario with many commands in a transaction and many ! * deferred-to-end-of-transaction triggers, it could get annoying to ! * rescan all the deferred triggers at each command end. To speed this ! * up, we could remember the actual end of the queue at EndQuery and ! * examine only events that are newer. On state changes we simply ! * reset the saved position to the beginning of the queue and process ! * all events once with the new states. */ /* Make a per-tuple memory context for trigger function calls */ --- 1698,1709 ---- * are going to discard the whole event queue on return anyway, so no * need to bother with "retail" pfree's. * ! * If immediate_only is true, we need only scan from where the end of ! * the queue was at the previous deferredTriggerInvokeEvents call; ! * any non-deferred events before that point are already fired. ! * (But if the deferral state changes, we must reset the saved position ! * to the beginning of the queue, so as to process all events once with ! * the new states. See DeferredTriggerSetState.) */ /* Make a per-tuple memory context for trigger function calls */ *************** *** 1709,1715 **** ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); ! event = deftrig_events; while (event != NULL) { bool still_deferred_ones = false; --- 1714,1735 ---- ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); ! /* ! * If immediate_only is true, then the only events that could need firing ! * are those since deftrig_events_imm. (But if deftrig_events_imm is ! * NULL, we must scan the entire list.) ! */ ! if (immediate_only && deftrig_events_imm != NULL) ! { ! prev_event = deftrig_events_imm; ! event = prev_event->dte_next; ! } ! else ! { ! prev_event = NULL; ! event = deftrig_events; ! } ! while (event != NULL) { bool still_deferred_ones = false; *************** *** 1830,1835 **** --- 1850,1858 ---- /* Update list tail pointer in case we just deleted tail event */ deftrig_event_tail = prev_event; + /* Set the immediate event pointer for next time */ + deftrig_events_imm = prev_event; + /* Release working resources */ if (rel) heap_close(rel, NoLock); *************** *** 1917,1922 **** --- 1940,1946 ---- MemoryContextSwitchTo(oldcxt); deftrig_events = NULL; + deftrig_events_imm = NULL; deftrig_event_tail = NULL; } *************** *** 2146,2153 **** * CONSTRAINTS command applies retroactively. This happens "for free" * since we have already made the necessary modifications to the * constraints, and deferredTriggerEndQuery() is called by ! * finish_xact_command(). */ } --- 2170,2180 ---- * CONSTRAINTS command applies retroactively. This happens "for free" * since we have already made the necessary modifications to the * constraints, and deferredTriggerEndQuery() is called by ! * finish_xact_command(). But we must reset deferredTriggerInvokeEvents' ! * tail pointer to make it rescan the entire list, in case some deferred ! * events are now immediately invokable. */ + deftrig_events_imm = NULL; } From pgsql-performance-owner@postgresql.org Sun Apr 20 20:46:30 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4C005475A80 for ; Sun, 20 Apr 2003 20:46:28 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id 4141347580B for ; Sun, 20 Apr 2003 20:46:27 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Sun, 20 Apr 2003 17:46:30 -0700 Date: Sun, 20 Apr 2003 17:46:30 -0700 From: Kevin Brown To: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030421004630.GL1847@filer> Mail-Followup-To: Kevin Brown , pgsql-performance@postgresql.org References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> <26961.1050852092@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <26961.1050852092@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/184 X-Sequence-Number: 1690 Tom Lane wrote: > Kevin Brown writes: > > This is why I suspect the best way to manage this would be to manage > > the counter itself using the MVCC mechanism (that is, you treat the > > shared counter as a row in a table just like any other and, in fact, > > it might be most beneficial for it to actually be exactly that), which > > handles the visibility problem automatically. But I don't know how > > much contention there would be as a result. > > Hm. Contention probably wouldn't be the killer, since if transactions > don't try to update the count until they are about to commit, they won't > be holding the row lock for long. (You'd have to beware of deadlocks > between transactions that need to update multiple counters, but that > seems soluble.) What *would* be a problem is that such counter tables > would accumulate huge numbers of dead rows very quickly, making it > inefficient to find the live row. But that inefficiency is a problem for *all* oft-updated tables, is it not? I know that you'll end up with an additional n tuples per transaction (where n is the average number of tables inserted into or deleted from per transaction), so this isn't an insignificant problem, but it's one faced by any application that often updates a small table. Causing a transaction which is already doing inserts/deletes to take the hit of doing one additional update doesn't seem to me to be a particularly large sacrifice, especially since the table it's updating (the one that contains the counts) is likely to be cached in its entirety. The chances are reasonable that the other activity the transaction is performing will dwarf the additional effort that maintaining the count demands. > Josh already mentioned this as a problem with user-trigger-based > counting. Right, but the trigger based mechanism probably magnifies the issue by orders of magnitude, and thus can't necessarily be used as an argument against an internally-implemented method. > You could stanch the bleeding with sufficiently frequent vacuums, > perhaps, but it just doesn't look very appealing. I would say this is more a strong argument for automatic VACUUM management than against count management, because what you say here is true of any oft-updated, oft-referenced table. > Ultimately what this comes down to is "how much overhead are we willing > to load onto all other operations in order to make SELECT-COUNT(*)-with- > no-WHERE-clause fast"? Postgres has made a set of design choices that > favor the other operations. If you've designed an application that > lives or dies by fast COUNT(*), perhaps you should choose another > database. Or perhaps a mechanism similar to the one being discussed should be implemented and controlled with a GUC variable, so instead of forcing someone to choose another database you force them to choose between the performance tradeoffs involved. We already give DBAs such choices elsewhere, e.g. pg_stat_activity. The real question in all this is whether or not fast COUNT(*) operations are needed often enough to even justify implementing a mechanism to make them possible in PG. The question of getting fast answers from COUNT(*) comes up often enough to be a FAQ, and that suggests that there's enough demand for the feature that it may be worth implementing just to shut those asking for it up. :-) Personally, I'd rather see such development effort go towards more beneficial improvements, such as replication, 2PC, SQL/MED, etc. (or even improving the efficiency of MVCC, since it was mentioned here as a problem! :-). I consider COUNT(*) without a WHERE clause to be a corner case, despite the frequency of questions about it. But I don't think we should reject a patch to implement fast COUNT(*) just because it represents a performance tradeoff, at least if it's GUC-controlled. -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Sun Apr 20 21:53:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DC17D476315 for ; Sun, 20 Apr 2003 21:53:20 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 16495475A80 for ; Sun, 20 Apr 2003 21:53:17 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3L1rLU6021713; Sun, 20 Apr 2003 21:53:21 -0400 (EDT) To: Kevin Brown Cc: pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used In-reply-to: <20030421004630.GL1847@filer> References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> <20030420062852.GK1847@filer> <26961.1050852092@sss.pgh.pa.us> <20030421004630.GL1847@filer> Comments: In-reply-to Kevin Brown message dated "Sun, 20 Apr 2003 17:46:30 -0700" Date: Sun, 20 Apr 2003 21:53:20 -0400 Message-ID: <21712.1050890000@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/185 X-Sequence-Number: 1691 Kevin Brown writes: > Personally, I'd rather see such development effort go towards more > beneficial improvements, such as replication, 2PC, SQL/MED, etc. (or > even improving the efficiency of MVCC, since it was mentioned here as > a problem! :-). I consider COUNT(*) without a WHERE clause to be a > corner case, despite the frequency of questions about it. Exactly. > But I don't > think we should reject a patch to implement fast COUNT(*) just because > it represents a performance tradeoff, at least if it's GUC-controlled. Well, this is moot since I see no one offering to provide such a patch. But performance tradeoffs are only one of the costs involved. I suspect any such mechanism would be invasive enough to represent a nontrivial ongoing maintenance cost, whether anyone uses it or not. The extent to which it munges core functionality would have to be a factor in deciding whether to accept it. It'd take lots more thought than we've expended in this thread to get an accurate handle on just what would be involved... (BTW, if anyone actually is thinking about this, please make it a per-table option not a global GUC option.) regards, tom lane From pgsql-performance-owner@postgresql.org Mon Apr 21 12:15:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EBFF64758C9 for ; Mon, 21 Apr 2003 12:15:13 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 63785474E42 for ; Mon, 21 Apr 2003 12:15:11 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2977665; Mon, 21 Apr 2003 09:15:13 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Mon, 21 Apr 2003 09:14:43 -0700 User-Agent: KMail/1.4.3 References: <26961.1050852092@sss.pgh.pa.us> <20030421004630.GL1847@filer> In-Reply-To: <20030421004630.GL1847@filer> MIME-Version: 1.0 Message-Id: <200304210914.43552.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.2 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,QUOTE_TWICE_1, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/186 X-Sequence-Number: 1692 Kevin, > > Josh already mentioned this as a problem with user-trigger-based > > counting. > > Right, but the trigger based mechanism probably magnifies the issue by > orders of magnitude, and thus can't necessarily be used as an argument > against an internally-implemented method. I'm not sure about that, Kevin. The production trigger test was written i= n C=20 (by Joe Conway), using some of the best memory/efficiency management he cou= ld=20 devise. I could buy that the trigger mechanism adds a certain fixed=20 overhead to the process, but not the contention that we were seeing ...=20 especially not the geometric progression of inefficiency as the transaction= =20 count went up. We'll talk about this offlist; I may be able to get the=20 client to authorize letting you examine the database. For further detail, our setup was sort of a "destruction test"; including: 1) a slightly underpowered server running too many processes; 2) a very high disk contention environment, with multiple applications=20 fighting for I/O. 3) running COUNT(*), GROUP BY x on a table with 1.4 million rows, which was= =20 being updated in batches of 10,000 rows to 40,000 rows every few minutes. As I said before, the overhead for c-trigger based accounting, within the M= VCC=20 framework, was quite tolerable with small update batches, only 9-11% penalt= y=20 to the updates overall for batches of 100-300 updates. However, as we=20 increased the application activity, the update penalty increased, up to=20 40-45% with the full production load. It's not hard to figure out why; like most user's servers, the aggregate=20 caching table was on the same disk as the table(s) being updated. The=20 resut was a huge amount of disk-head-skipping between the updated table and= =20 the aggregate caching table every time a commit hit the database, with rand= om=20 seek times increasing the longer the time since the last VACUUM. Now, on a better server with these tables on fast RAID or on different=20 spindles, I expect the result would be somewhat better. However, I also= =20 suspect that many of the users who complain the loudest about slow count(*)= =20 are operating in single-spindle environments. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Apr 22 04:23:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 261404763A8 for ; Tue, 22 Apr 2003 04:23:39 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id DB2664763AF for ; Tue, 22 Apr 2003 04:23:37 -0400 (EDT) Received: (qmail 37985 invoked by uid 1001); 22 Apr 2003 08:23:39 -0000 Date: Tue, 22 Apr 2003 03:23:39 -0500 From: "Jim C. Nasby" To: Josh Berkus Cc: Tom Lane , Kevin Brown , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Message-ID: <20030422032339.A37876@flake.decibel.org> Reply-To: jim@nasby.net References: <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <200304191203.18634.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200304191203.18634.josh@agliodbs.com>; from josh@agliodbs.com on Sat, Apr 19, 2003 at 12:03:18PM -0700 X-Operating-System: FreeBSD 4.7-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-39.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/187 X-Sequence-Number: 1693 On Sat, Apr 19, 2003 at 12:03:18PM -0700, Josh Berkus wrote: > Kevin, Tom: > > > (The cheapness can be disputed as well, since it creates a single point > > of contention for all inserts and deletes on the table. But that's a > > different topic.) > > Actually, this was the problem with the trigger method of maintaining COUNT > information in PostgreSQL. The statistics table itself becomes a > significant souce of delay, since if a table_A gets 10,000 rows updated than > table_count_A must necessarily be updated 10,000 times ... creating a lot of > dead tuples and severely attenuating the table on disk until the next vacuum > ... resulting in Update #10,000 to table_count_A taking 100+ times as long as > Update #1 does, due to the required random seek time on disk. Once statement level triggers are implimented, the performance would probably be fine, assuming your update was a single statement. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue Apr 22 04:30:58 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A54C3475EFD for ; Tue, 22 Apr 2003 04:30:57 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 8BE19475EEE for ; Tue, 22 Apr 2003 04:30:56 -0400 (EDT) Received: (qmail 38845 invoked by uid 1001); 22 Apr 2003 08:30:58 -0000 Date: Tue, 22 Apr 2003 03:30:58 -0500 From: "Jim C. Nasby" To: "scott.marlowe" Cc: Matthew Nuzum , Pgsql-Performance Subject: Re: choosing the right platform Message-ID: <20030422033058.B37876@flake.decibel.org> Reply-To: jim@nasby.net References: <20030409185843.X31861@flake.decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from scott.marlowe@ihs.com on Thu, Apr 10, 2003 at 10:42:35AM -0600 X-Operating-System: FreeBSD 4.7-RELEASE-p3 i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/188 X-Sequence-Number: 1694 On Thu, Apr 10, 2003 at 10:42:35AM -0600, scott.marlowe wrote: > The difference between SIZE and SHARE is the delta, which is only > something like 3 or 4 megs for the initial select * from logs, but the > second one is only 1 meg. On average, the actual increase in memory usage > for postgresql isn't that great, usually about 1 meg. > > Running out of memory isn't really a problem with connections<=200 and 1 > gig of ram, as long as sort_mem isn't too high. I/O contention is the > killer at that point, as is CPU load. Except you should consider what you could be doing with that 200M, ie: caching data. Even something as small as 1M per connection starts to add up. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Tue Apr 22 04:33:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6D30E4763BE for ; Tue, 22 Apr 2003 04:33:32 -0400 (EDT) Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id 4B9934763B6 for ; Tue, 22 Apr 2003 04:33:30 -0400 (EDT) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6p2/8.11.6) id h3M8XUc02874 for pgsql-performance@postgresql.org; Tue, 22 Apr 2003 16:33:30 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6p2/8.9.3) with SMTP id h3M8XQJ02649; Tue, 22 Apr 2003 16:33:26 +0800 (WST) Message-ID: <024001c308a9$d8bd0f70$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: , "Josh Berkus" Cc: "Tom Lane" , "Kevin Brown" , References: <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <200304191203.18634.josh@agliodbs.com> <20030422032339.A37876@flake.decibel.org> Subject: Re: [SQL] Yet Another (Simple) Case of Index not used Date: Tue, 22 Apr 2003 16:33:27 +0800 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-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Spam-Status: No, hits=-12.8 required=5.0 tests=BAYES_20,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/189 X-Sequence-Number: 1695 > Once statement level triggers are implimented, the performance would > probably be fine, assuming your update was a single statement. Statement triggers _are_ implemented in CVS. Chris From pgsql-hackers-owner@postgresql.org Tue Apr 22 07:44:59 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EAF68475E14 for ; Tue, 22 Apr 2003 07:44:58 -0400 (EDT) Received: from filer (12-234-86-219.client.attbi.com [12.234.86.219]) by postgresql.org (Postfix) with ESMTP id 2E50C474E42 for ; Tue, 22 Apr 2003 07:44:27 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) (uid 1000) by filer with local; Tue, 22 Apr 2003 04:44:30 -0700 Date: Tue, 22 Apr 2003 04:44:30 -0700 From: Kevin Brown To: pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance Message-ID: <20030422114429.GQ1833@filer> Mail-Followup-To: Kevin Brown , pgsql-hackers@postgresql.org References: <20030420090304.F28973-200000@megazone23.bigpanda.com> <6996.1050858564@sss.pgh.pa.us> <20030421000933.GP1833@filer> <21359.1050885300@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <21359.1050885300@sss.pgh.pa.us> User-Agent: Mutt/1.4i Organization: Frobozzco International X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/774 X-Sequence-Number: 38264 Tom Lane wrote: > Kevin Brown writes: > > Any chance of backporting these changes to 7_3_STABLE (when you're > > satisfied they don't break anything)? Just looking at the CVS log for > > trigger.c, it appears there have been enough changes since then that > > it might not be easy to do (and since it's not necessarily a "bug fix" > > as such, it might not qualify for backporting to a stable version). > > I'd be pretty hesitant to make such a change in the stable branch --- > at least not without a lot of testing. If you and others want to > provide such testing, go to it. The patch appears to apply cleanly > enough to 7.3, but here's an adjusted patch if fuzz makes you > nervous... Thanks, Tom. I've applied the patch to my server and it has so far passed the few tests I've thrown at it so far (it has detected foreign key violations in both immediate and deferred trigger mode). And just so you know, it performs FAR better than the pre-patched version does -- in the overall transaction I'm doing, I see very little difference now between deferred triggers and no triggers! -- Kevin Brown kevin@sysexperts.com From pgsql-performance-owner@postgresql.org Tue Apr 22 08:11:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9965E47638C for ; Tue, 22 Apr 2003 08:11:50 -0400 (EDT) Received: from mail2.mediadesign.nl (md2.mediadesign.nl [212.19.205.67]) by postgresql.org (Postfix) with SMTP id 5126A476373 for ; Tue, 22 Apr 2003 08:11:49 -0400 (EDT) Received: (qmail 28210 invoked by uid 666); 22 Apr 2003 12:11:50 -0000 Date: Tue, 22 Apr 2003 14:11:50 +0200 From: Vincent van Leeuwen To: pgsql-performance@postgresql.org Subject: Re: the RAID question, again Message-ID: <20030422121150.GU1836@md2.mediadesign.nl> Mail-Followup-To: pgsql-performance@postgresql.org References: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> User-Agent: Mutt/1.3.28i X-Spam-Status: No, hits=-38.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/190 X-Sequence-Number: 1696 On 2003-04-16 19:32:54 -0700, Nikolaus Dilger wrote: > One improvement area may be to put all 6 disks into a > RAID 10 group. That way you have more I/O bandwith. A concern I have about that setup is that a large WAL write will have to wait for 6 spindles to write the data before returning instead of 2 spindles. But as you say it does create way more I/O bandwidth. I think I'll just test that when the box is here instead of speculating further :) > One watchout is that the main memory of your machine > may be better than the one of your RAID controller. > The RAID controller has Integrated 128MB PC133 ECC > SDRAM. You did not state what kind of memory your > server has. > On 2003-04-16 20:20:50 -0700, Josh Berkus wrote: > Nickolaus has a good point. With a high-end Linux server, and a medium-end > RAID card, it's sometimes faster to use Linux software RAID than harware > raid. Not all the time, though. I've heard rumors that software raid performs poor when stacking raid layers (raid 0 on raid 1). Not sure if that's still true though. My own experiences with linux software raid (raid 5 on a low-cost fileserver for personal use) are very good (especially in the reliability department, I've recovered from two-disk failures due to controllers hanging up with only a few percent data loss), although I've never been overly concerned with performance on that setup so haven't really tested that. But if this controller is medium-end, could anyone recommend a high-end RAID card that has excellent linux support? One of the things I especially like about ICP Vortex products is the official linux support and the excellent software utility for monitoring and (re)configuring the raid arrays. Comes in handy when replacing hot-spares and rebuilding failed arrays while keeping the box running :) Vincent van Leeuwen Media Design - http://www.mediadesign.nl/ From pgsql-performance-owner@postgresql.org Tue Apr 22 13:19:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 232054758C9 for ; Tue, 22 Apr 2003 13:19:40 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 414D5474E42 for ; Tue, 22 Apr 2003 13:19:39 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2980227; Tue, 22 Apr 2003 10:19:35 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Vincent van Leeuwen , pgsql-performance@postgresql.org Subject: Re: the RAID question, again Date: Tue, 22 Apr 2003 10:18:57 -0700 User-Agent: KMail/1.4.3 References: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> <20030422121150.GU1836@md2.mediadesign.nl> In-Reply-To: <20030422121150.GU1836@md2.mediadesign.nl> MIME-Version: 1.0 Message-Id: <200304221018.58000.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/191 X-Sequence-Number: 1697 Vincent, > But if this controller is medium-end, could anyone recommend a high-end > RAID card that has excellent linux support? One of the things I especially > like about ICP Vortex products is the official linux support and the > excellent software utility for monitoring and (re)configuring the raid > arrays. Comes in handy when replacing hot-spares and rebuilding failed > arrays while keeping the box running :) No, just negative advice. Mylex support is dead until someone steps into t= he=20 shoes of the late developer of that driver. Adaptec is only paying their= =20 linux guy to do Red Hat support for their new RAID cards, so you're SOL wit= h=20 other distributions. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Apr 22 13:34:57 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 661424763B1 for ; Tue, 22 Apr 2003 13:34:56 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 7F420476374 for ; Tue, 22 Apr 2003 13:34:54 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3MHYege000211; Tue, 22 Apr 2003 11:34:40 -0600 (MDT) Date: Tue, 22 Apr 2003 11:29:07 -0600 (MDT) From: "scott.marlowe" To: Vincent van Leeuwen Cc: Subject: Re: the RAID question, again In-Reply-To: <20030422121150.GU1836@md2.mediadesign.nl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-22.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/192 X-Sequence-Number: 1698 On Tue, 22 Apr 2003, Vincent van Leeuwen wrote: > On 2003-04-16 19:32:54 -0700, Nikolaus Dilger wrote: > > One improvement area may be to put all 6 disks into a > > RAID 10 group. That way you have more I/O bandwith. > > A concern I have about that setup is that a large WAL write will have to wait > for 6 spindles to write the data before returning instead of 2 spindles. But > as you say it does create way more I/O bandwidth. I think I'll just test that > when the box is here instead of speculating further :) Not in a RAID 10. Assuming the setup is: RAID0-0: disk0, disk1, disk2 RAID0-1: disk3, disk4, disk5 RAID1-0: RAID0-0, RAID0-1 Then a write would only have to wait on two disks. Assuming the physical setup is one SCSI channel for RAID0-0 and one for RAID0-1, then both drives can write at the same time and your write performance is virtually identical to a single drive. > On 2003-04-16 20:20:50 -0700, Josh Berkus wrote: > > Nickolaus has a good point. With a high-end Linux server, and a medium-end > > RAID card, it's sometimes faster to use Linux software RAID than harware > > raid. Not all the time, though. > > I've heard rumors that software raid performs poor when stacking raid layers > (raid 0 on raid 1). Not sure if that's still true though. I tested it and was probably the one spreading the rumors. I was testing on Linux kernels 2.4.9 at the time on a Dual PPro - 200 with 256 Meg RAM and 6 Ultra Wide 4 gig SCSI drives at 10krpm. I've also tested other setups. My experience was that RAID5 and RAID1 were no faster on top of RAID0 then on bare drives. note that I didn't test for massive parallel performance, which would probably have better performance with the extra platters. I was testing something like 4 to 10 simo connects with pgbench and my own queries, some large, some small. > My own experiences > with linux software raid (raid 5 on a low-cost fileserver for personal use) > are very good (especially in the reliability department, I've recovered from > two-disk failures due to controllers hanging up with only a few percent data > loss), although I've never been overly concerned with performance on that > setup so haven't really tested that. My experience with Linux RAID is similar to yours. It's always been rock solid reliable, and acutally seems more intuitive to me now than any of the hardware RAID cards I've played with. Plus you can FORCE it to do what you want, whereas many cards refuse to do what you want. for really fast RAID, look at external RAID enclosures, that take x drives and make them look like one great big drive. Good speed and easy to manage, and to Linux it's just a big drive, so you don't need any special drivers for it. From pgsql-performance-owner@postgresql.org Tue Apr 22 13:45:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 67B644758C9 for ; Tue, 22 Apr 2003 13:45:26 -0400 (EDT) Received: from isis.pcis.net (cr.pcis.net [207.18.226.3]) by postgresql.org (Postfix) with ESMTP id 85CAE474E42 for ; Tue, 22 Apr 2003 13:44:55 -0400 (EDT) Received: from lyric.ofsloans.com (unverified [209.180.142.225]) by isis.pcis.net (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Tue, 22 Apr 2003 12:45:03 -0500 Subject: Re: the RAID question, again From: Will LaShell To: Josh Berkus Cc: Vincent van Leeuwen , pgsql-performance@postgresql.org In-Reply-To: <200304221018.58000.josh@agliodbs.com> References: <20030416193256.25788.h006.c001.wm@mail.dilger.cc.criticalpath.net> <20030422121150.GU1836@md2.mediadesign.nl> <200304221018.58000.josh@agliodbs.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-QFyN62ZClt2Ov0lS1CtF" X-Mailer: Ximian Evolution 1.0.8 (1.0.8-10) Date: 22 Apr 2003 10:44:48 -0700 Message-Id: <1051033494.21231.11.camel@lyric.ofsloans.com> Mime-Version: 1.0 X-Spam-Status: No, hits=-45.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/193 X-Sequence-Number: 1699 --=-QFyN62ZClt2Ov0lS1CtF Content-Type: text/plain Content-Transfer-Encoding: quoted-printable We use LSI Megaraid cards for all of our servers. Their older cards are a bit dated now, but the new Elite 1650 is a pretty nice card. The Adaptec cards are pretty hot, but as Josh has pointed out their reference driver is for RedHat. Granted, that doesn't bother us here at OFS because that's all we use on machine but to each their own. Sincerely, Will LaShell On Tue, 2003-04-22 at 10:18, Josh Berkus wrote: > Vincent, >=20 > > But if this controller is medium-end, could anyone recommend a high-end > > RAID card that has excellent linux support? One of the things I especia= lly > > like about ICP Vortex products is the official linux support and the > > excellent software utility for monitoring and (re)configuring the raid > > arrays. Comes in handy when replacing hot-spares and rebuilding failed > > arrays while keeping the box running :) >=20 > No, just negative advice. Mylex support is dead until someone steps into= the=20 > shoes of the late developer of that driver. Adaptec is only paying thei= r=20 > linux guy to do Red Hat support for their new RAID cards, so you're SOL w= ith=20 > other distributions. >=20 > --=20 > Josh Berkus > Aglio Database Solutions > San Francisco >=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) --=-QFyN62ZClt2Ov0lS1CtF 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+pX+QZr3R5kgOZd0RAtLiAJwLZuD5ggeFAS0YLIrQdtRuzFQUrgCdFVvj q6ggTUJqVGF7iDCOhI5/nAM= =BfdI -----END PGP SIGNATURE----- --=-QFyN62ZClt2Ov0lS1CtF-- From pgsql-performance-owner@postgresql.org Wed Apr 23 12:34:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 87E09475F16 for ; Wed, 23 Apr 2003 12:34:24 -0400 (EDT) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by postgresql.org (Postfix) with ESMTP id CC4A3474E42 for ; Wed, 23 Apr 2003 12:34:20 -0400 (EDT) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id C331E138413; Wed, 23 Apr 2003 12:34: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 198NAN-0008NS-00; Wed, 23 Apr 2003 12:32:15 -0400 To: Tom Lane Cc: Kevin Brown , pgsql-performance@postgresql.org Subject: Re: [SQL] Yet Another (Simple) Case of Index not used References: <200304090918.45275.josh@agliodbs.com> <20030419130146.GI1847@filer> <21955.1050767928@sss.pgh.pa.us> <20030420011336.GJ1847@filer> <24735.1050809664@sss.pgh.pa.us> In-Reply-To: <24735.1050809664@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 23 Apr 2003 12:32:09 -0400 Message-ID: <87adeh2n06.fsf@stark.dyndns.tv> Lines: 17 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/194 X-Sequence-Number: 1700 Tom Lane writes: > AFAICS, central-counter techniques could only work in an MVCC system > if each transaction copies every counter in the system at each snapshot > freeze point, in case it finds itself needing that counter value later > on. This is a huge amount of mostly-useless overhead, and it makes the > problem of lock contention for access to the counters several orders of > magnitude worse than you'd first think. Well, one option would be to do it in a lazy way. If you do an update on a table with cached aggregate data just throw the data out. This way you get to cache data on infrequently updated tables and get only a very small penalty on frequently updated tables. -- greg From pgsql-performance-owner@postgresql.org Wed Apr 23 13:58:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7AF36476478 for ; Wed, 23 Apr 2003 13:55:45 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 54D7B476407 for ; Wed, 23 Apr 2003 13:53:57 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3NHrti3019870 for ; Wed, 23 Apr 2003 19:53:55 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3NHrtVo025025; Wed, 23 Apr 2003 19:53:55 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3NHrt50025024; Wed, 23 Apr 2003 19:53:55 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f To: pgsql-performance@postgresql.org From: Frederic Jolliton Subject: Important speed difference between a query and a function with the same query Date: Wed, 23 Apr 2003 19:53:55 +0200 Message-ID: <8665p56qx8.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-14.3 required=5.0 tests=BAYES_01,USER_AGENT_GNUS_UA,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/195 X-Sequence-Number: 1701 Hi, (PostgreSQL 7.3.2 on i386-portbld-freebsd4.7, compiled by GCC 2.95.4) I've a curious performance problem with a function returning set of rows. The query alone is very fast, but not when called from the function. To "emulate" a parametred view=B9, I created a function as follow: CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info AS '...' <- here the query show below, where 'LIMIT $1' is used instead= of 'LIMIT 10' LANGUAGE sql; The table table1 have 330K rows, and table2 have 3K rows. When I run the following query (prefixed with SELECT * to try to get the same behavior that the second query), I obtain very good time. database=3D# SELECT * FROM ( (SELECT a.field1,a.field2,a.field3,b.field3,b.field4,a.field5 FROM table1 AS a, table1 AS b WHERE a.field6=3Db.field4 ORDER BY a.field6 DESC LIMIT 10) UNION (SELECT a.field1,a.field2,b.field3,a.field3,a.field4,b.field5 FROM table2 AS a, table1 AS b WHERE a.field4=3Db.field6 ORDER BY a.field4 DESC LIMIT 10) ORDER BY field4 DESC LIMIT 10 ) AS type_get_info; [...] (10 rows) Time: 185.86 ms But, when I run the function (with 10 as parameter, but even 1 is slow) I get poor time: database=3D# SELECT * FROM get_info(10); [...] (10 rows) Time: 32782.26 ms database=3D#=20 (even after a VACUUM FULL ANALYZE, and REINDEX of indexes used in the queries) What is curious is that I remember that the function was fast at a time.. What is the difference between the two case ? [1] Is there another solution to this 'hack' ? I can't simply create a view and use 'LIMIT 10' because intermediate SELECT have be limited too (to avoid UNION with 300K rows where only the first 10 are of interest to me.) --=20 Fr=E9d=E9ric Jolliton From pgsql-performance-owner@postgresql.org Thu Apr 24 11:47:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C1256476373 for ; Thu, 24 Apr 2003 11:47:51 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 90496476368 for ; Thu, 24 Apr 2003 11:47:48 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3OFlri3021850 for ; Thu, 24 Apr 2003 17:47:53 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3OFlrw7006919 for ; Thu, 24 Apr 2003 17:47:53 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3OFlriH006918; Thu, 24 Apr 2003 17:47:53 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f To: pgsql-performance@postgresql.org From: Frederic Jolliton Subject: Re: Important speed difference between a query and a Date: Thu, 24 Apr 2003 17:47:53 +0200 In-Reply-To: <8665p56qx8.fsf@mau.localdomain> (Frederic Jolliton's message of "Wed, 23 Apr 2003 19:53:55 +0200") Message-ID: <86el3rsxqu.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 References: <8665p56qx8.fsf@mau.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.9 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/196 X-Sequence-Number: 1702 > (PostgreSQL 7.3.2 on i386-portbld-freebsd4.7, compiled by GCC 2.95.4) > > I've a curious performance problem with a function returning set of > rows. The query alone is very fast, but not when called from the > function. > > To "emulate" a parametred view, I created a function as follow: > > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > AS '...' <- here the query show below, where 'LIMIT $1' is used inste= ad of 'LIMIT 10' > LANGUAGE sql; Setting enable_seqscan to off give same result speed between the query and the function ! So, the query in the function is not using index but the exact same query alone does ! Is there an explanation ? --=20 Fr=E9d=E9ric Jolliton From pgsql-performance-owner@postgresql.org Thu Apr 24 11:57:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 50478475E9D for ; Thu, 24 Apr 2003 11:57:02 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 79FB0474E42 for ; Thu, 24 Apr 2003 11:57:01 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3OFuuU6014132; Thu, 24 Apr 2003 11:56:56 -0400 (EDT) To: Frederic Jolliton Cc: pgsql-performance@postgresql.org Subject: Re: Important speed difference between a query and a In-reply-to: <86el3rsxqu.fsf@mau.localdomain> References: <8665p56qx8.fsf@mau.localdomain> <86el3rsxqu.fsf@mau.localdomain> Comments: In-reply-to Frederic Jolliton message dated "Thu, 24 Apr 2003 17:47:53 +0200" Date: Thu, 24 Apr 2003 11:56:56 -0400 Message-ID: <14131.1051199816@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/197 X-Sequence-Number: 1703 Frederic Jolliton writes: >> To "emulate" a parametred view, I created a function as follow: >> >> CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info >> AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' >> LANGUAGE sql; > So, the query in the function is not using index but the exact same > query alone does ! But it's not the same query, is it? With "LIMIT $1" the planner can't know what the limit value is exactly, so it has to generate a plan that won't be too unreasonable for either a small or a large limit. regards, tom lane From pgsql-performance-owner@postgresql.org Thu Apr 24 11:57:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 21055476368 for ; Thu, 24 Apr 2003 11:57:13 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id E67A9476361 for ; Thu, 24 Apr 2003 11:57:08 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D0753D618; Thu, 24 Apr 2003 08:57:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C5EE15C0A; Thu, 24 Apr 2003 08:57:13 -0700 (PDT) Date: Thu, 24 Apr 2003 08:57:13 -0700 (PDT) From: Stephan Szabo To: Frederic Jolliton Cc: Subject: Re: Important speed difference between a query and a In-Reply-To: <86el3rsxqu.fsf@mau.localdomain> Message-ID: <20030424085451.P1362-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/198 X-Sequence-Number: 1704 On Thu, 24 Apr 2003, Frederic Jolliton wrote: > > (PostgreSQL 7.3.2 on i386-portbld-freebsd4.7, compiled by GCC 2.95.4) > > > > I've a curious performance problem with a function returning set of > > rows. The query alone is very fast, but not when called from the > > function. > > > > To "emulate" a parametred view, I created a function as follow: > > > > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > > AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' > > LANGUAGE sql; > > Setting enable_seqscan to off give same result speed between the query > and the function ! > > So, the query in the function is not using index but the exact same > query alone does ! > > Is there an explanation ? My guess is that limit $1 is assuming a larger number of rows when planning the queries, large enough that it expects seqscan to be better (assuming the limit is what it expects). It's probably not going to plan that query each time the function is called so it's not going to know whether you're calling with a small number (index scan may be better) or a large number (seq scan may be better). For example, if you sent 100000, the index scan might be a loser. Perhaps plpgsql with EXECUTE would work better for that, although it's likely to have some general overhead. From pgsql-performance-owner@postgresql.org Thu Apr 24 12:33:32 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C63C7475E9D for ; Thu, 24 Apr 2003 12:33:31 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 93E13474E42 for ; Thu, 24 Apr 2003 12:33:30 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3OGXZi3023100 for ; Thu, 24 Apr 2003 18:33:35 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3OGXZw7007268 for ; Thu, 24 Apr 2003 18:33:35 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3OGXZGP007267; Thu, 24 Apr 2003 18:33:35 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f To: pgsql-performance@postgresql.org From: Frederic Jolliton Subject: Re: Important speed difference between a query and a Date: Thu, 24 Apr 2003 18:33:35 +0200 In-Reply-To: <14131.1051199816@sss.pgh.pa.us> (Tom Lane's message of "Thu, 24 Apr 2003 11:56:56 -0400") Message-ID: <86bryvsvmo.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 References: <8665p56qx8.fsf@mau.localdomain> <86el3rsxqu.fsf@mau.localdomain> <14131.1051199816@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-40.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA, X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/199 X-Sequence-Number: 1705 > Frederic Jolliton writes: >>> To "emulate" a parametred view, I created a function as follow: >>> >>> CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info >>> AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' >>> LANGUAGE sql; > >> So, the query in the function is not using index but the exact same >> query alone does ! Tom Lane writes: > But it's not the same query, is it? With "LIMIT $1" the planner can't > know what the limit value is exactly, so it has to generate a plan that > won't be too unreasonable for either a small or a large limit. Ok. So the query is optimized once and not each time.. I understand now. But, since I "know" better that PostgreSQL that query must use index in most of case, can I force in some manner the function when declaring it to take this in account ? I suppose (not tested) that setting enable_seqscan just before will probably do it, but what about dump/restore of the database when recreating the function and keep this "fix" automatically ? From pgsql-performance-owner@postgresql.org Thu Apr 24 12:41:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 86EF3476387 for ; Thu, 24 Apr 2003 12:41:45 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 39B4447637F for ; Thu, 24 Apr 2003 12:41:44 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3OGfni3023327 for ; Thu, 24 Apr 2003 18:41:49 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3OGfnw7007302 for ; Thu, 24 Apr 2003 18:41:49 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3OGfnvr007301; Thu, 24 Apr 2003 18:41:49 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f From: Frederic Jolliton To: Subject: Re: Important speed difference between a query and a Date: Thu, 24 Apr 2003 18:41:49 +0200 In-Reply-To: <20030424085451.P1362-100000@megazone23.bigpanda.com> (Stephan Szabo's message of "Thu, 24 Apr 2003 08:57:13 -0700 (PDT)") Message-ID: <868ytzsv8y.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 References: <20030424085451.P1362-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-40.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA, X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/200 X-Sequence-Number: 1706 > On Thu, 24 Apr 2003, Frederic Jolliton wrote: >> > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info >> > AS '...' <- here the query show below, where 'LIMIT $1' is used in= stead of 'LIMIT 10' >> > LANGUAGE sql; >> >> Setting enable_seqscan to off give same result speed between the query >> and the function ! >> >> So, the query in the function is not using index but the exact same >> query alone does ! >> >> Is there an explanation ? Stephan Szabo writes: > My guess is that limit $1 is assuming a larger number of rows when > planning the queries, large enough that it expects seqscan to be > better (assuming the limit is what it expects). It's probably not > going to plan that query each time the function is called so it's > not going to know whether you're calling with a small number (index > scan may be better) or a large number (seq scan may be better). For > example, if you sent 100000, the index scan might be a loser. > > Perhaps plpgsql with EXECUTE would work better for that, although > it's likely to have some general overhead. The server is rather fast, and the query return 10 to 50 rows in most case. So, this is probably a solution, even if it's not very clean. (Well, I have to find an example to RETURN the result of EXECUTE..) But, what I don't understand is why enable_seqscan change something if the query is already planed. --=20 Fr=E9d=E9ric Jolliton From pgsql-performance-owner@postgresql.org Thu Apr 24 13:28:12 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 462CD474E42 for ; Thu, 24 Apr 2003 13:28:11 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id CD877476083 for ; Thu, 24 Apr 2003 13:28:08 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 91A41D618; Thu, 24 Apr 2003 10:28:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 875255C0A; Thu, 24 Apr 2003 10:28:08 -0700 (PDT) Date: Thu, 24 Apr 2003 10:28:08 -0700 (PDT) From: Stephan Szabo To: Frederic Jolliton Cc: Subject: Re: Important speed difference between a query and a In-Reply-To: <868ytzsv8y.fsf@mau.localdomain> Message-ID: <20030424101802.M2131-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/201 X-Sequence-Number: 1707 On Thu, 24 Apr 2003, Frederic Jolliton wrote: > > On Thu, 24 Apr 2003, Frederic Jolliton wrote: > > Perhaps plpgsql with EXECUTE would work better for that, although > > it's likely to have some general overhead. > > The server is rather fast, and the query return 10 to 50 rows in most > case. So, this is probably a solution, even if it's not very > clean. (Well, I have to find an example to RETURN the result of > EXECUTE..) Check out http://techdocs.postgresql.org/guides/SetReturningFunctions specifically the GetRows() function for an example of using for in execute with set returning functions. From pgsql-performance-owner@postgresql.org Thu Apr 24 13:40:21 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4961C476384 for ; Thu, 24 Apr 2003 13:40:20 -0400 (EDT) Received: from tux.tuxee.net (tuxee.net [62.212.110.244]) by postgresql.org (Postfix) with ESMTP id 08C92476387 for ; Thu, 24 Apr 2003 13:40:18 -0400 (EDT) Received: from mau.localdomain (mau.localdomain [192.168.1.10]) by tux.tuxee.net (8.12.9/8.12.9) with ESMTP id h3OHeHi3024945 for ; Thu, 24 Apr 2003 19:40:17 +0200 Received: from mau.localdomain (localhost [127.0.0.1]) by mau.localdomain (8.12.8/8.12.6) with ESMTP id h3OHeHw7007694 for ; Thu, 24 Apr 2003 19:40:17 +0200 Received: (from fred@localhost) by mau.localdomain (8.12.8/8.12.8/Submit) id h3OHeHqh007693; Thu, 24 Apr 2003 19:40:17 +0200 X-Authentication-Warning: mau.localdomain: fred set sender to fred@jolliton.com using -f To: From: Frederic Jolliton Subject: Re: Important speed difference between a query and a Date: Thu, 24 Apr 2003 19:40:17 +0200 In-Reply-To: <20030424101802.M2131-100000@megazone23.bigpanda.com> (Stephan Szabo's message of "Thu, 24 Apr 2003 10:28:08 -0700 (PDT)") Message-ID: <863ck7ssji.fsf@mau.localdomain> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.3 References: <20030424101802.M2131-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-40.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA, X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/202 X-Sequence-Number: 1708 > On Thu, 24 Apr 2003, Frederic Jolliton wrote: [...] >> The server is rather fast, and the query return 10 to 50 rows in >> most case. So, this is probably a solution, even if it's not very >> clean. (Well, I have to find an example to RETURN the result of >> EXECUTE..) Stephan Szabo writes: > Check out > http://techdocs.postgresql.org/guides/SetReturningFunctions > > specifically the GetRows() function for an example of using for in > execute with set returning functions. Oh right. Thanks you for pointing out this. --=20 Fr=E9d=E9ric Jolliton From pgsql-performance-owner@postgresql.org Thu Apr 24 19:38:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 29063475458 for ; Thu, 24 Apr 2003 19:38:16 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 22B3C474E42 for ; Thu, 24 Apr 2003 19:38:15 -0400 (EDT) Received: (qmail 70507 invoked by uid 1001); 24 Apr 2003 23:38:17 -0000 Date: Thu, 24 Apr 2003 18:38:17 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: More tablescanning fun Message-ID: <20030424183817.A66185@flake.decibel.org> Reply-To: jim@nasby.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-13.5 required=5.0 tests=BAYES_01,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/203 X-Sequence-Number: 1709 On this table project_id | integer | not null id | integer | not null date | date | not null team_id | integer | not null work_units | bigint | not null Indexes: email_contrib_pkey primary key btree (project_id, id, date) with this breakdown of data project_id | count ------------+---------- 5 | 56427141 8 | 1058843 24 | 361595 25 | 4092575 205 | 58512516 Any kind of operation on an entire project wants to tablescan, even though it's going to take way longer. explain analyze select sum(work_units) from email_contrib where project_id=8; Index scan 126, 56, 55 seconds Seq. scan 1517, 850, 897 seconds It seems like the metrics used for the cost of index scanning v. table scanning on large tables need to be revisited. It might be such a huge difference in this case because the table is essentially clustered on the primary key. I can test this by doing an aggregate for, say, a specific team_id, which would be pretty well spread across the entire table, but that'll have to wait a bit. Anyone have any thoughts on this? Also, is there a TODO to impliment real clustered indexes? Doing stuff by project_id on this table in sybase was very efficient, because there was a real clustered index on the PK. By clustered index, I mean an index where the leaf nodes of the B-tree were the actual table rows. This means the only overhead in going through the index is scanning the branches, which in this case would be pretty light-weight. Is this something that I should be using some PGSQL-specific feature for, like inheritance? I've been really happy so far with PGSQL (comming from Sybase and DB2), but it seems there's still some pretty big performance issues that want to be addressed (or I should say performance issues that hurt really big when you hit them :) ). -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Thu Apr 24 19:58:31 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D845C475458 for ; Thu, 24 Apr 2003 19:58:29 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2874D474E42 for ; Thu, 24 Apr 2003 19:58:29 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3ONwUU6003661; Thu, 24 Apr 2003 19:58:31 -0400 (EDT) To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: More tablescanning fun In-reply-to: <20030424183817.A66185@flake.decibel.org> References: <20030424183817.A66185@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Thu, 24 Apr 2003 18:38:17 -0500" Date: Thu, 24 Apr 2003 19:58:30 -0400 Message-ID: <3660.1051228710@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/204 X-Sequence-Number: 1710 "Jim C. Nasby" writes: > It seems like the metrics used for the cost of index scanning v. table > scanning on large tables need to be revisited. It might be such a huge > difference in this case because the table is essentially clustered on > the primary key. Probably. What does the correlation figure in pg_stats show as? There's been some previous debate about the equation used to correct for correlation, which is certainly bogus (I picked it more or less out of the air ;-)). But so far no one has proposed a replacement equation with any better foundation ... take a look in src/backend/optimizer/path/costsize.c if you want to get involved. > Also, is there a TODO to impliment > real clustered indexes? No. It's not apparent to me how you could do that without abandoning MVCC, which we're not likely to do. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Apr 25 00:59:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0073D4758E6 for ; Fri, 25 Apr 2003 00:59:26 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id DB450474E42 for ; Fri, 25 Apr 2003 00:59:24 -0400 (EDT) Received: (qmail 85793 invoked by uid 1001); 25 Apr 2003 04:59:24 -0000 Date: Thu, 24 Apr 2003 23:59:24 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: More tablescanning fun Message-ID: <20030424235924.B66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <3660.1051228710@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Thu, Apr 24, 2003 at 07:58:30PM -0400 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-40.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REFERENCES,REPLY_WITH_QUOTES, SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/205 X-Sequence-Number: 1711 On Thu, Apr 24, 2003 at 07:58:30PM -0400, Tom Lane wrote: > "Jim C. Nasby" writes: > > It seems like the metrics used for the cost of index scanning v. table > > scanning on large tables need to be revisited. It might be such a huge > > difference in this case because the table is essentially clustered on > > the primary key. > > Probably. What does the correlation figure in pg_stats show as? stats=# select attname, correlation from pg_stats where tablename='email_contrib'; attname | correlation ------------+------------- project_id | 1 id | 0.449204 date | 0.271775 team_id | 0.165588 work_units | 0.0697928 > There's been some previous debate about the equation used to correct > for correlation, which is certainly bogus (I picked it more or less > out of the air ;-)). But so far no one has proposed a replacement > equation with any better foundation ... take a look in > src/backend/optimizer/path/costsize.c if you want to get involved. Are you reffering to the PF formula? > > Also, is there a TODO to impliment > > real clustered indexes? > > No. It's not apparent to me how you could do that without abandoning > MVCC, which we're not likely to do. Hmm... does MVCC mandate inserts go at the end? My understanding is that each tuple indicates it's insert/last modified time; if this is the case, why would a true clustered index break mvcc? I guess an update that moves the tuple would be tricky, but I'm guesing there's some kind of magic that could happen there... worst case would be adding an 'expired' timestamp. On the other hand, it might be possible to get the advantages of a clustered index without doing a *true* clustered index. The real point is to be able to use indexes; I've heard things like 'if you need to access more than 10% of a table then using an index would be disasterous', and that's not good... that number should really be over 50% for most reasonable ratios of fields indexed to fields in table (of course field size plays a factor). -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri Apr 25 01:23:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5E1834758E6 for ; Fri, 25 Apr 2003 01:23:18 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 60938474E42 for ; Fri, 25 Apr 2003 01:23:13 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3P5NAU6013550; Fri, 25 Apr 2003 01:23:10 -0400 (EDT) To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: More tablescanning fun In-reply-to: <20030424235924.B66185@flake.decibel.org> References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Thu, 24 Apr 2003 23:59:24 -0500" Date: Fri, 25 Apr 2003 01:23:10 -0400 Message-ID: <13549.1051248190@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/206 X-Sequence-Number: 1712 "Jim C. Nasby" writes: > On Thu, Apr 24, 2003 at 07:58:30PM -0400, Tom Lane wrote: >> There's been some previous debate about the equation used to correct >> for correlation, which is certainly bogus (I picked it more or less >> out of the air ;-)). But so far no one has proposed a replacement >> equation with any better foundation ... take a look in >> src/backend/optimizer/path/costsize.c if you want to get involved. > Are you reffering to the PF formula? The PF formula is good as far as I know, but it assumes an uncorrelated table order. The debate is how to correct it for nonzero correlation. Specifically, this bit: * When the index ordering is exactly correlated with the table ordering * (just after a CLUSTER, for example), the number of pages fetched should * be just sT. What's more, these will be sequential fetches, not the * random fetches that occur in the uncorrelated case. So, depending on * the extent of correlation, we should estimate the actual I/O cost * somewhere between s * T * 1.0 and PF * random_cost. We currently * interpolate linearly between these two endpoints based on the * correlation squared (XXX is that appropriate?). I believe the endpoints s*T and PF*random_cost, I think, but the curve between them is anyone's guess. It's also quite possible that the correlation stat that we currently compute is inadequate to model what's going on. >> No. It's not apparent to me how you could do that without abandoning >> MVCC, which we're not likely to do. > Hmm... does MVCC mandate inserts go at the end? Anywhere that there's free space. The point is that you can't promise updates will fit on the same page as the original tuple. So whatever desirable physical ordering you may have started with will surely degrade over time. > On the other hand, it might be possible to get the advantages of a > clustered index without doing a *true* clustered index. The real point > is to be able to use indexes; I've heard things like 'if you need to > access more than 10% of a table then using an index would be > disasterous', and that's not good... that number should really be over > 50% for most reasonable ratios of fields indexed to fields in table (of > course field size plays a factor). If you have to read 50% of a table, you certainly should be doing a linear scan. There will be hardly any pages you can skip (unless the table is improbably well clustered), and the extra I/O needed to read the index will buy you nothing. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Apr 25 03:01:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9F26D4761C0 for ; Fri, 25 Apr 2003 03:01:43 -0400 (EDT) Received: from fuji.krosing.net (unknown [194.204.44.118]) by postgresql.org (Postfix) with ESMTP id 4DAD0476182 for ; Fri, 25 Apr 2003 03:01:42 -0400 (EDT) Received: from fuji.krosing.net (lo [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h3P71WmG003399; Fri, 25 Apr 2003 10:01:32 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h3P71V5T003397; Fri, 25 Apr 2003 10:01:31 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: Important speed difference between a query and a From: Hannu Krosing To: Frederic Jolliton Cc: pgsql-performance@postgresql.org In-Reply-To: <86bryvsvmo.fsf@mau.localdomain> References: <8665p56qx8.fsf@mau.localdomain> <86el3rsxqu.fsf@mau.localdomain> <14131.1051199816@sss.pgh.pa.us> <86bryvsvmo.fsf@mau.localdomain> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1051254090.2997.3.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 25 Apr 2003 10:01:31 +0300 X-Spam-Status: No, hits=-33.7 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/207 X-Sequence-Number: 1713 Frederic Jolliton kirjutas N, 24.04.2003 kell 19:33: > > Frederic Jolliton writes: > >>> To "emulate" a parametred view, I created a function as follow: > >>> > >>> CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > >>> AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' > >>> LANGUAGE sql; > > > >> So, the query in the function is not using index but the exact same > >> query alone does ! > > Tom Lane writes: > > But it's not the same query, is it? With "LIMIT $1" the planner can't > > know what the limit value is exactly, so it has to generate a plan that > > won't be too unreasonable for either a small or a large limit. > > Ok. So the query is optimized once and not each time.. I understand > now. > > But, since I "know" better that PostgreSQL that query must use index > in most of case, can I force in some manner the function when > declaring it to take this in account ? You could define two functions - one for small sets with constant LIMITs (maybe 50) in UNION parts, and another with $1. Then use accordingly. > I suppose (not tested) that > setting enable_seqscan just before will probably do it, but what about > dump/restore of the database when recreating the function and keep > this "fix" automatically ? ------------- Hannu From pgsql-performance-owner@postgresql.org Fri Apr 25 10:38:04 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5075B4762F1 for ; Fri, 25 Apr 2003 10:38:03 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id A380F4762CF for ; Fri, 25 Apr 2003 10:37:58 -0400 (EDT) Received: (qmail 8589 invoked by uid 1001); 25 Apr 2003 14:38:01 -0000 Date: Fri, 25 Apr 2003 09:38:01 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: More tablescanning fun Message-ID: <20030425093800.C66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <13549.1051248190@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <13549.1051248190@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Fri, Apr 25, 2003 at 01:23:10AM -0400 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-39.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REFERENCES,REPLY_WITH_QUOTES, SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/208 X-Sequence-Number: 1714 On Fri, Apr 25, 2003 at 01:23:10AM -0400, Tom Lane wrote: > I believe the endpoints s*T and PF*random_cost, I think, but the curve > between them is anyone's guess. It's also quite possible that the > correlation stat that we currently compute is inadequate to model what's > going on. In this case, the interpolation can't be at fault, because correlation is 1 (unless the interpolation is backwards, but that doesn't appear to be the case). One possibility is that IndexSelectivity isn't taking most_common_(vals|freqs) into account. Looking at this from an idea case, most (or all) of this query should be retrieved by simply incrementing through both the index and the tuples at the same time. We should end up pulling 0.7% of the index and raw pages combined. Analyze thinks that using the index will be about 50% more expensive, though. (3258557 v. 2274866) A thought that comes to mind here is that it would be incredible if pgsql could take metrics of how long things actually take on a live system and incorporate them... basically learning as it goes. A first step in this case would be to keep tabs on how close real page-read counts come to what the optimizer predicted, and storing that for later analysis. This would make it easier for you to verify your linear correlation assumption, for example (it'd also make it easier to validate the PF formula). > >> No. It's not apparent to me how you could do that without abandoning > >> MVCC, which we're not likely to do. > > > Hmm... does MVCC mandate inserts go at the end? > > Anywhere that there's free space. The point is that you can't promise > updates will fit on the same page as the original tuple. So whatever > desirable physical ordering you may have started with will surely > degrade over time. Yes, updates are the tricky part to clustered indexes, and MVCC might make it harder. What Sybase 11 (which only supports page locking) does is see if the update moves the tuple off it's current page. If it doesn't, it just shuffles the page around as needed and goes on with business. If it needs to move, it grabs (and locks) the page it needs to move to, inserts it on that page (possibly incurring a page split), and deletes it from the old page. My guess is that with MVCC, you can't simply delete the old tuple... you'd have to leave some kind of 'bread crumb' behind for older transactions to see (though, I guess this would already have to be happening somehow). The reason to do this in this case is well worth it though... we end up with one table (simplifies code) that should essentially act as if it was multiple (5 in this case) tables, so performance should still be very good. > > On the other hand, it might be possible to get the advantages of a > > clustered index without doing a *true* clustered index. The real point > > is to be able to use indexes; I've heard things like 'if you need to > > access more than 10% of a table then using an index would be > > disasterous', and that's not good... that number should really be over > > 50% for most reasonable ratios of fields indexed to fields in table (of > > course field size plays a factor). > > If you have to read 50% of a table, you certainly should be doing a > linear scan. There will be hardly any pages you can skip (unless the > table is improbably well clustered), and the extra I/O needed to read > the index will buy you nothing. Yes, and it's that 'improbably well clustered' case that I have here. :) But even if you're only 25% clustered, I think you'll still see a huge gain on a very large table, especially if the index tuples are substantially smaller than the raw tuples (which they normally should be). -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri Apr 25 11:09:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7794D475F16 for ; Fri, 25 Apr 2003 11:09:06 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 99B9D47636C for ; Fri, 25 Apr 2003 11:09:00 -0400 (EDT) Received: (qmail 9776 invoked by uid 1001); 25 Apr 2003 15:09:05 -0000 Date: Fri, 25 Apr 2003 10:09:05 -0500 From: "Jim C. Nasby" To: Frederic Jolliton Cc: pgsql-performance@postgresql.org Subject: Re: Important speed difference between a query and a function with the same query Message-ID: <20030425100905.D66185@flake.decibel.org> Reply-To: jim@nasby.net References: <8665p56qx8.fsf@mau.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <8665p56qx8.fsf@mau.localdomain>; from fred-pg@jolliton.com on Wed, Apr 23, 2003 at 07:53:55PM +0200 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/209 X-Sequence-Number: 1715 On Wed, Apr 23, 2003 at 07:53:55PM +0200, Frederic Jolliton wrote: > CREATE FUNCTION get_info (integer) RETURNS SETOF type_get_info > AS '...' <- here the query show below, where 'LIMIT $1' is used instead of 'LIMIT 10' > LANGUAGE sql; You should probably define the function to be STABLE. LANGUAGE sql STABLE; See http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=sql-createfunction.html for more info. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Fri Apr 25 12:28:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0DAAB475E77 for ; Fri, 25 Apr 2003 12:28:35 -0400 (EDT) Received: from fuji.krosing.net (sein.itera.ee [194.126.109.126]) by postgresql.org (Postfix) with ESMTP id 0C922474E42 for ; Fri, 25 Apr 2003 12:28:34 -0400 (EDT) Received: from fuji.krosing.net (lo [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h3PGSIJ0002719; Fri, 25 Apr 2003 19:28:18 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h3PGS6Ss002717; Fri, 25 Apr 2003 19:28:06 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: More tablescanning fun From: Hannu Krosing To: jim@nasby.net Cc: Tom Lane , pgsql-performance@postgresql.org In-Reply-To: <20030424235924.B66185@flake.decibel.org> References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1051288086.1765.95.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 25 Apr 2003 19:28:06 +0300 X-Spam-Status: No, hits=-32.9 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/210 X-Sequence-Number: 1716 Jim C. Nasby kirjutas R, 25.04.2003 kell 07:59: > > > Also, is there a TODO to impliment > > > real clustered indexes? > > > > No. It's not apparent to me how you could do that without abandoning > > MVCC, which we're not likely to do. > > Hmm... does MVCC mandate inserts go at the end? I have been pondering if keeping pages half-empty (or even 70% empty) could solve both clustering problems and longish updates for much data. If we could place the copy in the same page than original, most big updates would be possible by one sweep of disk heads and also clustering order would be easier to keep if pages were kept intentionally half empty. So "VACUUM FULL 65% EMPTY;" could make sense ? ------------- Hannu From pgsql-performance-owner@postgresql.org Fri Apr 25 12:56:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 88270475E77 for ; Fri, 25 Apr 2003 12:56:08 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 70615474E42 for ; Fri, 25 Apr 2003 12:56:07 -0400 (EDT) Received: (qmail 13733 invoked by uid 1001); 25 Apr 2003 16:56:13 -0000 Date: Fri, 25 Apr 2003 11:56:13 -0500 From: "Jim C. Nasby" To: Hannu Krosing Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: More tablescanning fun Message-ID: <20030425115613.E66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <1051288086.1765.95.camel@fuji.krosing.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <1051288086.1765.95.camel@fuji.krosing.net>; from hannu@tm.ee on Fri, Apr 25, 2003 at 07:28:06PM +0300 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/211 X-Sequence-Number: 1717 On Fri, Apr 25, 2003 at 07:28:06PM +0300, Hannu Krosing wrote: > I have been pondering if keeping pages half-empty (or even 70% empty) > could solve both clustering problems and longish updates for much data. > > If we could place the copy in the same page than original, most big > updates would be possible by one sweep of disk heads and also clustering > order would be easier to keep if pages were kept intentionally half > empty. > > So "VACUUM FULL 65% EMPTY;" could make sense ? That's actually a recommended practice, at least for sybase when you're using a clustered index, depending on what you're using it for. If you cluster a table in such a way that inserts will happen across the entire table, you'll actually end up with a fillratio (amount of data v. empty space on a page) of 75% over time, because of page splits. When sybase goes to insert, if it can't find room on the page it needs to insert into (keep in mind this is a clustered table, so a given row *must* go into a given position), it will split that single page into two pages, each of which will then have a fillratio of 50%. Of course they'll eventually approach 100%, so the average fill ratio across all pages for the table would be 75%. I'm not familiar enough with pgsql's guts to know how big an impact updates across pages are, or if they even happen often at all. If you're not maintaining a clustered table, couldn't all updates just occur in-place? Or are you thinking of the case where you have a lot of variable-length stuff? -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-hackers-owner@postgresql.org Fri Apr 25 15:53:27 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4033F47630C for ; Fri, 25 Apr 2003 15:53:25 -0400 (EDT) Received: from europa.janwieck.net (h00045a2e4e7c.ne.client2.attbi.com [24.131.181.55]) by postgresql.org (Postfix) with ESMTP id 729FC4763D8 for ; Fri, 25 Apr 2003 15:53:19 -0400 (EDT) Received: from Yahoo.com (wieck@dhcpclnt00.janwieck.net [192.168.192.100]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id h3PJqba24259; Fri, 25 Apr 2003 15:52:38 -0400 Message-ID: <3EA991F0.A201AC38@Yahoo.com> Date: Fri, 25 Apr 2003 15:52:16 -0400 From: Jan Wieck Organization: Home X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en,ru MIME-Version: 1.0 To: Stephan Szabo Cc: Tom Lane , Kevin Brown , pgsql-hackers@postgresql.org Subject: Re: [PERFORM] Foreign key performance References: <20030418073753.B1912-100000@megazone23.bigpanda.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/905 X-Sequence-Number: 38395 Stephan Szabo wrote: > > [Not sure this really is relevant for -performance at this point] > > On Thu, 17 Apr 2003, Stephan Szabo wrote: > > > On Fri, 18 Apr 2003, Tom Lane wrote: > > > > > Stephan Szabo writes: > > > > It appears (from some not terribly scientific experiments - see below) > > > > that it's likely to be related to managing the deferred trigger queue > > > > given that in my case at least running the constraints non-deferred was > > > > negligible in comparison. > > > > > > At one time the deferred-trigger queue had an O(N^2) behavioral problem > > > for large N = number of pending trigger events. But I thought we'd > > > fixed that. What's the test case exactly? Can you get a profile with > > > gprof? > > > > I'm going to tomorrow hopefully - but it looks to me that we fixed one, but > > Argh. I'm getting that state where gprof returns all 0s for times. I'm > pretty sure this has come up before along with how to get it to work, but > I couldn't find it in the archives. Someday I'll learn how to use gprof. :( You have to save and restore the timers around the fork() under Linux. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # From pgsql-performance-owner@postgresql.org Fri Apr 25 16:10:52 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 28063476375 for ; Fri, 25 Apr 2003 16:10:51 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 2F597476350 for ; Fri, 25 Apr 2003 16:10:50 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3PKAlU6029561; Fri, 25 Apr 2003 16:10:49 -0400 (EDT) To: Hannu Krosing Cc: jim@nasby.net, pgsql-performance@postgresql.org Subject: Re: More tablescanning fun In-reply-to: <1051288086.1765.95.camel@fuji.krosing.net> References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <1051288086.1765.95.camel@fuji.krosing.net> Comments: In-reply-to Hannu Krosing message dated "25 Apr 2003 19:28:06 +0300" Date: Fri, 25 Apr 2003 16:10:47 -0400 Message-ID: <29560.1051301447@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/212 X-Sequence-Number: 1718 Hannu Krosing writes: > I have been pondering if keeping pages half-empty (or even 70% empty) > could solve both clustering problems and longish updates for much data. You could achieve that pretty easily if you simply don't ever VACUUM FULL ;-) UPDATE has always (AFAIR) attempted to place the new version on the same page as the old, moving it elsewhere only if it doesn't fit. So that part of the logic is already there. > So "VACUUM FULL 65% EMPTY;" could make sense ? Not so much that, as a parameter to CLUSTER telling it to fill pages only x% full. regards, tom lane From pgsql-performance-owner@postgresql.org Fri Apr 25 18:33:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 708B6475C3D for ; Fri, 25 Apr 2003 18:33:12 -0400 (EDT) Received: from hotmail.com (f42.law12.hotmail.com [64.4.19.42]) by postgresql.org (Postfix) with ESMTP id B58E4474E42 for ; Fri, 25 Apr 2003 18:33:11 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 25 Apr 2003 15:33:14 -0700 Received: from 200.67.81.177 by lw12fd.law12.hotmail.msn.com with HTTP; Fri, 25 Apr 2003 22:33:13 GMT X-Originating-IP: [200.67.81.177] X-Originating-Email: [cecilia_ag@hotmail.com] From: "Cecilia Alvarez" To: pgsql-performance@postgresql.org Subject: Indexes with different datatypes Date: Fri, 25 Apr 2003 17:33:13 -0500 Mime-Version: 1.0 Content-Type: text/html; charset=iso-8859-1 Message-ID: X-OriginalArrivalTime: 25 Apr 2003 22:33:14.0019 (UTC) FILETIME=[A8AAD730:01C30B7A] X-Spam-Status: No, hits=-0.5 required=5.0 tests=BAYES_30,HTML_60_70,HTML_FONT_COLOR_BLUE, HTML_FONT_COLOR_GREEN,HTML_FONT_COLOR_RED version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/213 X-Sequence-Number: 1719

Hi,

I�ve already created an concatenated index in Postgres V3.0 with different datatypes:

CREATE INDEX mov_i4 ON movimiento USING btree (id_company, id_status, id_docum, id_origen_mov);

id_company int2

id_status char(1)

id_docum numeric(15,0)

id_origen_mov int4

and after several tests the query doesn�t use the index because it seems that id_company must be a char.

If a use the value for the id_company eg.   select * from movimiento where id_company = 120

                                                          and id_status = 'X' and id_docto = 10000056789 and mount = 12345.56

---- it doesn�t use the index                                                                               

If a use the value for the id_company eg.   select * from movimiento where id_company = '120' and

                                                     and id_status = 'X' and id_docto = 10000056789 and mount = 12345.56

---- it  uses the index

 

The problem is that I can�t change the datatypes in the hole application and the table has 240,000 rows and we need to use concatenated indexes, because we access the table in different ways, the table has another five concatenated indexes.

Could you suggest something to resolve this?

Thank you very much.

Regards,

Cecilia

 

 


�nete al mayor servicio mundial de correo electr�nico: Haz clic aqu� From pgsql-performance-owner@postgresql.org Fri Apr 25 18:36:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0C548475C3D for ; Fri, 25 Apr 2003 18:36:47 -0400 (EDT) Received: from hotmail.com (f28.law12.hotmail.com [64.4.19.28]) by postgresql.org (Postfix) with ESMTP id 4526C474E42 for ; Fri, 25 Apr 2003 18:36:46 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 25 Apr 2003 15:36:48 -0700 Received: from 200.67.81.177 by lw12fd.law12.hotmail.msn.com with HTTP; Fri, 25 Apr 2003 22:36:48 GMT X-Originating-IP: [200.67.81.177] X-Originating-Email: [cecilia_ag@hotmail.com] From: "Cecilia Alvarez" To: pgsql-performance@postgresql.org Subject: Indexes with different datatypes:Correction Date: Fri, 25 Apr 2003 17:36:48 -0500 Mime-Version: 1.0 Content-Type: text/html; charset=iso-8859-1 Message-ID: X-OriginalArrivalTime: 25 Apr 2003 22:36:48.0719 (UTC) FILETIME=[28A375F0:01C30B7B] X-Spam-Status: No, hits=-0.5 required=5.0 tests=BAYES_30,HTML_60_70,HTML_FONT_COLOR_BLUE, HTML_FONT_COLOR_GREEN,HTML_FONT_COLOR_RED version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/214 X-Sequence-Number: 1720



Sorry, this is the good one:

I�ve already created an concatenated index in Postgres V3.0 with different datatypes:

CREATE INDEX mov_i4 ON movimiento USING btree (id_company, id_status, id_docum, id_origen_mov);

id_company int2

id_status char(1)

id_docum numeric(15,0)

id_origen_mov int4

and after several tests the query doesn�t use the index because it seems that id_company must be a char.

If a use the value for the id_company eg.   select * from movimiento where id_company = 120

                                                          and id_status = 'X' and id_docum = 10000056789 and id_origen_mov = 12345

---- it doesn�t use the index                                                                               

If a use the value for the id_company eg.   select * from movimiento where id_company = '120' and

                                                     and id_status = 'X' and id_docum = 10000056789 and id_origen_mov = 12345

---- it  uses the index

 

The problem is that I can�t change the datatypes in the hole application and the table has 240,000 rows and we need to use concatenated indexes, because we access the table in different ways, the table has another five concatenated indexes.

Could you suggest something to resolve this?

Thank you very much.

Regards,

Cecilia

 

 


MSN. M�s �til Cada D�a Haz clic aqu� smart spam protection and 2 months FREE* From pgsql-performance-owner@postgresql.org Fri Apr 25 18:49:42 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3E35F475C3D for ; Fri, 25 Apr 2003 18:49:39 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 11B18474E42 for ; Fri, 25 Apr 2003 18:49:37 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3PMnI3W019790; Fri, 25 Apr 2003 16:49:18 -0600 (MDT) Date: Fri, 25 Apr 2003 16:40:54 -0600 (MDT) From: "scott.marlowe" To: Cecilia Alvarez Cc: Subject: Re: Indexes with different datatypes:Correction In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 X-MailScanner: Found to be clean X-MailScanner-SpamCheck: Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/215 X-Sequence-Number: 1721 On Fri, 25 Apr 2003, Cecilia Alvarez wrote: >=20 >=20 >=20 > Sorry, this is the good one: >=20 > I=B4ve already created an concatenated index in Postgres V3.0 with differ= ent datatypes: >=20 > CREATE INDEX mov_i4 ON movimiento USING btree (id_company, id_status, id_= docum, > id_origen_mov); >=20 > id_company int2 >=20 > id_status char(1) >=20 > id_docum numeric(15,0) >=20 > id_origen_mov int4 >=20 > and after several tests the query doesn=B4t use the index because it seem= s=A0that id_company must > be a char. >=20 > If a use=A0the value for the id_company eg.=A0=A0 select * from movimient= o where id_company =3D 120 >=20 > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0and id_status =3D 'X' and id_docum =3D > 10000056789 and=A0id_origen_mov =3D 12345 >=20 > ---- it doesn=B4t use the > index=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 >=20 > If a use=A0the value for the id_company eg.=A0=A0 select * from movimient= o where id_company =3D '120' > and >=20 > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0and id_status =3D 'X' and id_docum =3D > 10000056789 and=A0id_origen_mov =3D 12345 >=20 > ---- it=A0 uses the index >=20 > =A0 >=20 > The problem is that I can=B4t change the datatypes in the hole applicatio= n and the table has > 240,000 rows and=A0we need to use concatenated indexes, because we access= the table in > different ways, the table has another five concatenated indexes. >=20 > Could you suggest something to resolve this? Hi Cecilia. It looks like the problem is that Postgresql assumes that a=20 non-quoted number is generally an int4, and since the id_company is int2,= =20 it isn't automatically converted. You can either change your app to force= =20 coercion (which the '' quotes are doing) or like: where id_company =3D 120::int2=20 OR where id =3D cast(120 as int2) OR you can recreate your table with id_company being int4. If you NEED to= =20 restrict it to int2 range, then you can use a constraint to make it act=20 like an int2 without actually being one. From pgsql-performance-owner@postgresql.org Sat Apr 26 11:15:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3CFEF475A80 for ; Sat, 26 Apr 2003 11:15:38 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id D7D67474E4F for ; Sat, 26 Apr 2003 11:15:33 -0400 (EDT) Received: (qmail 71747 invoked by uid 1001); 26 Apr 2003 15:15:37 -0000 Date: Sat, 26 Apr 2003 10:15:37 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Automatic analyze on select into Message-ID: <20030426101537.F66185@flake.decibel.org> Reply-To: jim@nasby.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-13.5 required=5.0 tests=BAYES_01,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/216 X-Sequence-Number: 1722 BEGIN; SET LOCAL enable_seqscan = off; SELECT id, team_id, sum(work_units) AS work_units INTO TEMP email_contrib_summary FROM email_contrib WHERE project_id = :ProjectID GROUP by id, team_id ; COMMIT; inserts 29000 rows... UPDATE email_contrib_summary SET id = sp.retire_to FROM stats_participant sp WHERE sp.id = email_contrib_summary.id AND sp.retire_to >= 0 AND (sp.retire_date >= (SELECT ps.last_date FROM project_statsrun ps WHERE ps.project_id = :ProjectID) OR sp.retire_date IS NULL) ; Nested Loop (cost=0.00..5475.20 rows=982 width=54) (actual time=25.54..2173363.11 rows=29181 loops=1) InitPlan -> Seq Scan on project_statsrun ps (cost=0.00..1.06 rows=1 width=4) (actual time=0.06..0.07 rows=1 loops=1) Filter: (project_id = 8) -> Seq Scan on email_contrib_summary (cost=0.00..20.00 rows=1000 width=46) (actual time=25.11..1263.26 rows=29753 loops=1) -> Index Scan using stats_participant__participantretire_id on stats_participant sp (cost=0.00..5.44 rows=1 width=8) (actual time=2.16..72.93 rows=1 loops=29753) Index Cond: ((sp.retire_to >= 0) AND (sp.id = "outer".id)) Filter: ((retire_date >= $0) OR (retire_date IS NULL)) Total runtime: 2174315.61 msec GAH! 45 minutes to update 29k rows! BUT, if I do Hash Join (cost=41104.03..42410.14 rows=29166 width=38) (actual time=8391.81..10925.07 rows=29181 loops=1) Hash Cond: ("outer".id = "inner".id) InitPlan -> Seq Scan on project_statsrun ps (cost=0.00..1.06 rows=1 width=4) (actual time=0.05..0.06 rows=1 loops=1) Filter: (project_id = 8) -> Seq Scan on email_contrib_summary (cost=0.00..496.01 rows=29701 width=30) (actual time=0.20..387.95 rows=29753 loops=1) -> Hash (cost=13939.69..13939.69 rows=394217 width=8) (actual time=8390.72..8390.72 rows=0 loops=1) -> Seq Scan on stats_participant sp (cost=0.00..13939.69 rows=394217 width=8) (actual time=0.22..5325.38 rows=389115 loops=1) Filter: ((retire_to >= 0) AND ((retire_date >= $0) OR (retire_date IS NULL))) Total runtime: 11584.09 msec Ahhh... soothing relief... So, question is, would it make sense to automatically do an analyze after/during a SELECT INTO? Would it be very expensive to analyze the data as it's being inserted? I think it's pretty well understood that you want to vacuum/vacuum analyze the entire database regularly, but that obviously wouldn't help temporary tables... maybe it makes the most sense to automatically analyze temporary tables only. For that matter, since temp tables only have one operation performed on them at a time, maybe it makes sense to keep stats for them up-to-date as part of every operation? -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Sat Apr 26 12:18:58 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 50895474E4F for ; Sat, 26 Apr 2003 12:18:56 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 88C63474E42 for ; Sat, 26 Apr 2003 12:18:51 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3QGIsU6008336; Sat, 26 Apr 2003 12:18:54 -0400 (EDT) To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: Automatic analyze on select into In-reply-to: <20030426101537.F66185@flake.decibel.org> References: <20030426101537.F66185@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Sat, 26 Apr 2003 10:15:37 -0500" Date: Sat, 26 Apr 2003 12:18:54 -0400 Message-ID: <8335.1051373934@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/217 X-Sequence-Number: 1723 "Jim C. Nasby" writes: > So, question is, would it make sense to automatically do an analyze > after/during a SELECT INTO? I don't think so. Very often, temp tables are small and only used for one or two operations anyway --- so the cost of an ANALYZE wouldn't be repaid. If ANALYZE would be useful, the user can issue one. regards, tom lane From pgsql-performance-owner@postgresql.org Sat Apr 26 14:16:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 74F11475D0F for ; Sat, 26 Apr 2003 14:16:26 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 1EC5C475A80 for ; Sat, 26 Apr 2003 14:16:25 -0400 (EDT) Received: (qmail 78505 invoked by uid 1001); 26 Apr 2003 18:16:25 -0000 Date: Sat, 26 Apr 2003 13:16:25 -0500 From: "Jim C. Nasby" To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Automatic analyze on select into Message-ID: <20030426131624.G66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030426101537.F66185@flake.decibel.org> <8335.1051373934@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <8335.1051373934@sss.pgh.pa.us>; from tgl@sss.pgh.pa.us on Sat, Apr 26, 2003 at 12:18:54PM -0400 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/218 X-Sequence-Number: 1724 On Sat, Apr 26, 2003 at 12:18:54PM -0400, Tom Lane wrote: > "Jim C. Nasby" writes: > > So, question is, would it make sense to automatically do an analyze > > after/during a SELECT INTO? > > I don't think so. Very often, temp tables are small and only used for > one or two operations anyway --- so the cost of an ANALYZE wouldn't be > repaid. If ANALYZE would be useful, the user can issue one. Ok, I'll add notes to appropriate pages in the documentation. BTW, do the notes entered into the interactive docs get rolled into the formal documentation at any point? -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Sat Apr 26 14:40:13 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 38F1A474E4F for ; Sat, 26 Apr 2003 14:40:12 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 72E2F474E42 for ; Sat, 26 Apr 2003 14:40:11 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3QIe8U6014275; Sat, 26 Apr 2003 14:40:08 -0400 (EDT) To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: Automatic analyze on select into In-reply-to: <20030426131624.G66185@flake.decibel.org> References: <20030426101537.F66185@flake.decibel.org> <8335.1051373934@sss.pgh.pa.us> <20030426131624.G66185@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Sat, 26 Apr 2003 13:16:25 -0500" Date: Sat, 26 Apr 2003 14:40:08 -0400 Message-ID: <14274.1051382408@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/219 X-Sequence-Number: 1725 "Jim C. Nasby" writes: > Ok, I'll add notes to appropriate pages in the documentation. BTW, do > the notes entered into the interactive docs get rolled into the formal > documentation at any point? Usually, towards the end of a release cycle, someone will run through them looking for stuff worth incorporating into the next generation. It's pretty informal though. regards, tom lane From pgsql-performance-owner@postgresql.org Sun Apr 27 02:50:58 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B394F475AE5 for ; Sun, 27 Apr 2003 02:50:56 -0400 (EDT) Received: from fuji.krosing.net (unknown [194.204.44.118]) by postgresql.org (Postfix) with ESMTP id F25E2474E42 for ; Sun, 27 Apr 2003 02:50:54 -0400 (EDT) Received: from fuji.krosing.net (lo [127.0.0.1]) by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id h3R6oqoJ001925; Sun, 27 Apr 2003 09:50:52 +0300 Received: (from hannu@localhost) by fuji.krosing.net (8.12.8/8.12.8/Submit) id h3R6opFt001922; Sun, 27 Apr 2003 09:50:51 +0300 X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee using -f Subject: Re: More tablescanning fun From: Hannu Krosing To: jim@nasby.net Cc: Tom Lane , pgsql-performance@postgresql.org In-Reply-To: <20030425115613.E66185@flake.decibel.org> References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <1051288086.1765.95.camel@fuji.krosing.net> <20030425115613.E66185@flake.decibel.org> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Message-Id: <1051426250.1860.1.camel@fuji.krosing.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 27 Apr 2003 09:50:51 +0300 X-Spam-Status: No, hits=-32.9 required=5.0 tests=BAYES_10,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/220 X-Sequence-Number: 1726 Jim C. Nasby kirjutas R, 25.04.2003 kell 19:56: > I'm not familiar enough with pgsql's guts to know how big an impact > updates across pages are, or if they even happen often at all. If you're > not maintaining a clustered table, couldn't all updates just occur > in-place? In postgres _no_ updates happen in-place. The MVCC concurrency works by always inserting a new tuple on update . ----------- Hannu From pgsql-performance-owner@postgresql.org Sun Apr 27 22:30:24 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 55C264758C9 for ; Sun, 27 Apr 2003 22:30:23 -0400 (EDT) Received: from cable.kevindegraaf.net (12-245-24-71.client.attbi.com [12.245.24.71]) by postgresql.org (Postfix) with SMTP id 9B638474E42 for ; Sun, 27 Apr 2003 22:30:20 -0400 (EDT) Received: (qmail 1371 invoked from network); 28 Apr 2003 02:30:31 -0000 Received: from unknown (HELO ungoliant) (192.168.1.3) by cable.kevindegraaf.net with SMTP; 28 Apr 2003 02:30:31 -0000 From: Jeremy Andrus Reply-To: jeremy@jeremya.com Organization: http://www.jeremya.com/ To: pgsql-performance@postgresql.org Subject: pgsql BLOB issues Date: Sun, 27 Apr 2003 22:30:23 -0400 User-Agent: KMail/1.5 X-Rokken: Dokken MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304272230.23583@jeremy-rokks> X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/221 X-Sequence-Number: 1727 Hello, I have a database that contains a large amount of Large Objects (>500MB). I am using this database to store images for an e-commerce website, so I have a simple accessor script written in perl to dump out a blob based on a virtual 'path' stored in a table (and associated with the large object's OID). This system seemed to work wonderfully until I put more than ~500MB of binary data into the database. Now, every time I run the accessor script (via the web OR the command line), the postmaster process gobbles up my CPU resources (usually >30% for a single process - and it's a 1GHz processor with 1GB of RAM!), and the script takes a very long time to completely dump out the data. I have the same issue with an import script that reads files from the hard drive and puts them into Large Objects in the database. It takes a very long time to import whereas before, it would run extremely fast. Are there any known issues in PostgreSQL involving databases with a lot of binary data? I am using PostgreSQL v7.2.3 on a linux system. Thanks, -Jeremy -- ------------------------ Jeremy C. Andrus http://www.jeremya.com/ ------------------------ From pgsql-performance-owner@postgresql.org Mon Apr 28 01:00:22 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8DF0D474E42 for ; Mon, 28 Apr 2003 01:00:19 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 40D7C475956 for ; Mon, 28 Apr 2003 01:00:08 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3S501U6011755; Mon, 28 Apr 2003 01:00:01 -0400 (EDT) To: jeremy@jeremya.com Cc: pgsql-performance@postgresql.org Subject: Re: pgsql BLOB issues In-reply-to: <200304272230.23583@jeremy-rokks> References: <200304272230.23583@jeremy-rokks> Comments: In-reply-to Jeremy Andrus message dated "Sun, 27 Apr 2003 22:30:23 -0400" Date: Mon, 28 Apr 2003 01:00:01 -0400 Message-ID: <11754.1051506001@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/222 X-Sequence-Number: 1728 Jeremy Andrus writes: > I have a database that contains a large amount of Large Objects > (>500MB). I am using this database to store images for an e-commerce > website, so I have a simple accessor script written in perl to dump out > a blob based on a virtual 'path' stored in a table (and associated with > the large object's OID). This system seemed to work wonderfully until I > put more than ~500MB of binary data into the database. Are you talking about 500MB in one BLOB, or 500MB total? If the former, I can well imagine swap thrashing being a problem when you try to access such a large blob. If the latter, I can't think of any reason for total blob storage to cause any big performance issue. Perhaps you just haven't vacuumed pg_largeobject in a long time? regards, tom lane From pgsql-performance-owner@postgresql.org Mon Apr 28 01:33:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A8E774758C9 for ; Mon, 28 Apr 2003 01:33:44 -0400 (EDT) Received: from cable.kevindegraaf.net (12-245-24-71.client.attbi.com [12.245.24.71]) by postgresql.org (Postfix) with SMTP id CAD8B474E42 for ; Mon, 28 Apr 2003 01:33:39 -0400 (EDT) Received: (qmail 1395 invoked from network); 28 Apr 2003 05:33:46 -0000 Received: from unknown (HELO ungoliant) (192.168.1.3) by cable.kevindegraaf.net with SMTP; 28 Apr 2003 05:33:46 -0000 From: Jeremy Andrus Reply-To: jeremy@jeremya.com Organization: http://www.jeremya.com/ To: Tom Lane Subject: Re: pgsql BLOB issues Date: Mon, 28 Apr 2003 01:33:38 -0400 User-Agent: KMail/1.5 References: <200304272230.23583@jeremy-rokks> <11754.1051506001@sss.pgh.pa.us> In-Reply-To: <11754.1051506001@sss.pgh.pa.us> Cc: pgsql-performance@postgresql.org X-Rokken: Dokken MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304280133.38335@jeremy-rokks> X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/223 X-Sequence-Number: 1729 On Monday 28 April 2003 01:00 am, Tom Lane wrote: > Are you talking about 500MB in one BLOB, or 500MB total? I meant 500MB _total_. There are over 5000 separate BLOBs. I'll ask my friendly sys-admin to vacuum pg_largeobject, and I'll let you know what happens :-) In general though, how much performance is really gained through regular vacuuming? Thanks for your help, -Jeremy -- ------------------------ Jeremy C. Andrus http://www.jeremya.com/ ------------------------ From pgsql-performance-owner@postgresql.org Mon Apr 28 04:20:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 70CF54758C9 for ; Mon, 28 Apr 2003 04:20:05 -0400 (EDT) Received: from houston.familyhealth.com.au (unknown [203.59.48.253]) by postgresql.org (Postfix) with ESMTP id F3DA8475EEE for ; Mon, 28 Apr 2003 04:19:56 -0400 (EDT) Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6p2/8.11.6) id h3S8JuF56548 for pgsql-performance@postgresql.org; Mon, 28 Apr 2003 16:19:56 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6p2/8.9.3) with SMTP id h3S8JnJ56413; Mon, 28 Apr 2003 16:19:49 +0800 (WST) Message-ID: <005e01c30d5e$f0209560$6500a8c0@fhp.internal> From: "Christopher Kings-Lynne" To: , "Tom Lane" Cc: References: <200304272230.23583@jeremy-rokks> <11754.1051506001@sss.pgh.pa.us> <200304280133.38335@jeremy-rokks> Subject: Re: pgsql BLOB issues Date: Mon, 28 Apr 2003 16:19:50 +0800 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-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Spam-Status: No, hits=-12.8 required=5.0 tests=BAYES_20,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/224 X-Sequence-Number: 1730 > I'll ask my friendly sys-admin to vacuum pg_largeobject, and I'll let > you know what happens :-) In general though, how much performance is > really gained through regular vacuuming? Significant. It's essential to vacuum regularly. Chris From pgsql-performance-owner@postgresql.org Mon Apr 28 06:39:16 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 583F44758C9 for ; Mon, 28 Apr 2003 06:39:14 -0400 (EDT) Received: from dos.sipec.es (unknown [62.36.228.122]) by postgresql.org (Postfix) with ESMTP id 24866474E42 for ; Mon, 28 Apr 2003 06:39:08 -0400 (EDT) Received: from sistemests2 ([10.1.1.128]) by dos.sipec.es with Microsoft SMTPSVC(5.0.2195.5329); Mon, 28 Apr 2003 12:26:04 +0200 From: To: Subject: Diferent execution plan for similar query Date: Mon, 28 Apr 2003 12:26:03 +0200 Message-ID: <003401c30d70$92c07310$8001010a@sipec.es> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Importance: Normal X-OriginalArrivalTime: 28 Apr 2003 10:26:04.0765 (UTC) FILETIME=[92D840D0:01C30D70] Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-0.8 required=5.0 tests=BAYES_20,NO_DNS_FOR_FROM,NO_REAL_NAME version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/225 X-Sequence-Number: 1731 Somebody could explain me why this query... SELECT * FROM articulos,eans WHERE articulos.id_iinterno=3Deans.id_iinterno AND eans.id_iean=3D345 is slower than this one? (the difference is the quotes around the number....) SELECT * FROM articulos,eans WHERE articulos.id_iinterno=3Deans.id_iinterno AND eans.id_iean=3D'345' I really now why, but I don't undestand the reason. The execution plan for the first query uses Sequential scans, and the second one uses the index, as you can see here: Execution plan for the first query: Nested Loop (cost=3D0.00..8026.85 rows=3D1 width=3D133) -> Seq Scan on eans (cost=3D0.00..8023.74 rows=3D1 width=3D16) -> Index Scan using articulos_pk on articulos (cost=3D0.00..3.10 rows= =3D1 width=3D117) And this is the second: Nested Loop (cost=3D0.00..9.12 rows=3D1 width=3D133) -> Index Scan using eans_pk on eans (cost=3D0.00..6.01 rows=3D1 width= =3D16) -> Index Scan using articulos_pk on articulos (cost=3D0.00..3.10 rows= =3D1 width=3D117) The field id_iean is an 8 bytes integer. Also the same for the field id_iinterno in both tables. The definition of the 2 tables is this: CREATE TABLE "eans" ( "id_iean" int8 NOT NULL, "id_iinterno" int8, CONSTRAINT "eans_pk" PRIMARY KEY ("id_iean") ) WITH OIDS; CREATE TABLE "articulos" ( "id_iinterno" int8 NOT NULL, "vsdesc_calypso" varchar(20), "id_iseccion" int4, "iprecio" int4, "ifamilia" int8, "icod_proveedor" int4, "vsmarca" varchar(10), "vsdesc_larga" varchar(22), "bnulo" bool, "bcontrol_devolucion" bool, "itipo_pedido" int2, "isurtido" int2, "ifuera_lineal" int2, "idias_caducidad" int2, "iuni_x_caja" int2, "suni_medida" varchar(2), "suni_pedido" varchar(3), CONSTRAINT "articulos_pk" PRIMARY KEY ("id_iinterno") ) WITH OIDS; What I don't understand is why the quotes in the number result in a diferent query execution. Somebody could help me? Thank you for your help. Jordi Gim=E9nez . Analista Software Departamento Calypso. Soluciones Inform=E1ticas Para El Comercio, S.L. jgimenez(arroba)sipec.es From pgsql-performance-owner@postgresql.org Mon Apr 28 06:41:55 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3CFF74758C9 for ; Mon, 28 Apr 2003 06:41:55 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 595F3474E42 for ; Mon, 28 Apr 2003 06:41:53 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h3SAfsU09457 for ; Mon, 28 Apr 2003 16:11:54 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h3SAfsx09452 for ; Mon, 28 Apr 2003 16:11:54 +0530 From: Shridhar Daithankar To: Subject: Re: Diferent execution plan for similar query Date: Mon, 28 Apr 2003 16:11:33 +0530 User-Agent: KMail/1.5.1 References: <003401c30d70$92c07310$8001010a@sipec.es> In-Reply-To: <003401c30d70$92c07310$8001010a@sipec.es> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304281611.33669.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/226 X-Sequence-Number: 1732 On Monday 28 April 2003 15:56, jgimenez@sipec_quitaesto_.es wrote: > Somebody could explain me why this query... > > SELECT * > FROM articulos,eans > WHERE articulos.id_iinterno=eans.id_iinterno > AND eans.id_iean=345 > > is slower than this one? (the difference is the quotes around the > number....) > > SELECT * > FROM articulos,eans > WHERE articulos.id_iinterno=eans.id_iinterno > AND eans.id_iean='345' In second case, postgresql typecasted it correctly. Even eans.id_iean=345::int8 would have worked the same way. By default postgresql treats a number as int4 while comparing and integer and float8 for a real numbe. I discovered that yesterday. Until the planner/parser gets smarter, this is going to be an FAQ.. Shridhar From pgsql-performance-owner@postgresql.org Mon Apr 28 06:59:39 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 977B8474E42 for ; Mon, 28 Apr 2003 06:59:37 -0400 (EDT) Received: from mail2.fbab.net (spectre.fbab.net [195.54.134.139]) by postgresql.org (Postfix) with SMTP id 1BF33474E42 for ; Mon, 28 Apr 2003 06:59:06 -0400 (EDT) Received: (qmail 5195 invoked by uid 136); 28 Apr 2003 10:59:07 -0000 Received: from mag@fbab.net by mail2.fbab.net by uid 133 with qmail-scanner-1.10 (F-PROT: 3.11. Clear:0. Processed in 0.267225 secs); 28 Apr 2003 10:59:07 -0000 X-Qmail-Scanner-Mail-From: mag@fbab.net via mail2.fbab.net X-Qmail-Scanner: 1.10 (Clear:0. Processed in 0.267225 secs) Received: from unknown (HELO mail2.fbab.net:444) (195.54.134.228) by mail2.fbab.net with SMTP; 28 Apr 2003 10:59:07 -0000 Received: from 129.178.88.66 (SquirrelMail authenticated user magimap1) by mail2.fbab.net with HTTP; Mon, 28 Apr 2003 12:59:07 +0200 (CEST) Message-ID: <59937.129.178.88.66.1051527547.squirrel@mail2.fbab.net> In-Reply-To: <200304281611.33669.shridhar_daithankar@nospam.persistent.co.in> References: <003401c30d70$92c07310$8001010a@sipec.es> <200304281611.33669.shridhar_daithankar@nospam.persistent.co.in> Date: Mon, 28 Apr 2003 12:59:07 +0200 (CEST) Subject: Re: Diferent execution plan for similar query From: "Magnus Naeslund(w)" To: "Shridhar Daithankar" Cc: pgsql-performance@postgresql.org Reply-To: mag@fbab.net User-Agent: SquirrelMail/1.4.0 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Spam-Status: No, hits=-25.4 required=5.0 tests=BAYES_01,IN_REP_TO,PRIORITY_NO_NAME,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/227 X-Sequence-Number: 1733 Shridhar Daithankar said: > > In second case, postgresql typecasted it correctly. Even > eans.id_iean=345::int8 would have worked the same way. By default > postgresql > treats a number as int4 while comparing and integer and float8 for a real > numbe. I discovered that yesterday. > > Until the planner/parser gets smarter, this is going to be an FAQ.. > > Shridhar Is this an nontrivial change? Because if it's trivial it should be done, imho. I've been bitten indirectly of this, and it's not too easy to find out always. I think that this is one of the most unobvious performance hickups there are with postgresql. Magnus From pgsql-performance-owner@postgresql.org Mon Apr 28 07:00:19 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A6AB475E14 for ; Mon, 28 Apr 2003 07:00:15 -0400 (EDT) Received: from mail2.fbab.net (spectre.fbab.net [195.54.134.139]) by postgresql.org (Postfix) with SMTP id BF739475B47 for ; Mon, 28 Apr 2003 07:00:01 -0400 (EDT) Received: (qmail 5275 invoked by uid 136); 28 Apr 2003 11:00:04 -0000 Received: from mag@fbab.net by mail2.fbab.net by uid 133 with qmail-scanner-1.10 (F-PROT: 3.11. Clear:0. Processed in 0.265754 secs); 28 Apr 2003 11:00:04 -0000 X-Qmail-Scanner-Mail-From: mag@fbab.net via mail2.fbab.net X-Qmail-Scanner: 1.10 (Clear:0. Processed in 0.265754 secs) Received: from unknown (HELO mail2.fbab.net:444) (195.54.134.228) by mail2.fbab.net with SMTP; 28 Apr 2003 11:00:03 -0000 Received: from 129.178.88.66 (SquirrelMail authenticated user magimap1) by mail2.fbab.net with HTTP; Mon, 28 Apr 2003 13:00:03 +0200 (CEST) Message-ID: <62257.129.178.88.66.1051527603.squirrel@mail2.fbab.net> Date: Mon, 28 Apr 2003 13:00:03 +0200 (CEST) Subject: Re: Diferent execution plan for similar query From: "Magnus Naeslund(w)" To: "Shridhar Daithankar" Cc: pgsql-performance@postgresql.org Reply-To: mag@fbab.net User-Agent: SquirrelMail/1.4.0 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 Importance: Normal X-Spam-Status: No, hits=-9.2 required=5.0 tests=BAYES_01,PRIORITY_NO_NAME,QUOTED_EMAIL_TEXT,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/228 X-Sequence-Number: 1734 Shridhar Daithankar said: > > In second case, postgresql typecasted it correctly. Even > eans.id_iean=345::int8 would have worked the same way. By default > postgresql > treats a number as int4 while comparing and integer and float8 for a real > numbe. I discovered that yesterday. > > Until the planner/parser gets smarter, this is going to be an FAQ.. > > Shridhar Is this an nontrivial change? Because if it's trivial it should be done, imho. I've been bitten indirectly of this, and it's not too easy to find out always. I think that this is one of the most unobvious performance hickups there are with postgresql. Magnus From pgsql-hackers-owner@postgresql.org Mon Apr 28 07:01:20 2003 X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 35265475E14 for ; Mon, 28 Apr 2003 07:01:16 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 1B960475B99 for ; Mon, 28 Apr 2003 07:01:14 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h3SB1Fm12275 for ; Mon, 28 Apr 2003 16:31:15 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h3SB1Fx12265; Mon, 28 Apr 2003 16:31:15 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Diferent execution plan for similar query Date: Mon, 28 Apr 2003 16:30:55 +0530 User-Agent: KMail/1.5.1 References: <003401c30d70$92c07310$8001010a@sipec.es> <200304281611.33669.shridhar_daithankar@nospam.persistent.co.in> <59937.129.178.88.66.1051527547.squirrel@mail2.fbab.net> In-Reply-To: <59937.129.178.88.66.1051527547.squirrel@mail2.fbab.net> Cc: pgsql-hackers@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304281630.55041.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/953 X-Sequence-Number: 38443 On Monday 28 April 2003 16:29, Magnus Naeslund(w) wrote: > Shridhar Daithankar said: > > In second case, postgresql typecasted it correctly. Even > > eans.id_iean=345::int8 would have worked the same way. By default > > postgresql > > treats a number as int4 while comparing and integer and float8 for a real > > numbe. I discovered that yesterday. > > > > Until the planner/parser gets smarter, this is going to be an FAQ.. > > > > Shridhar > > Is this an nontrivial change? > Because if it's trivial it should be done, imho. > I've been bitten indirectly of this, and it's not too easy to find out > always. I think that this is one of the most unobvious performance hickups > there are with postgresql. I would say dig into hackers archives for the consensus(??) reached.. I don't remember.. Shridhar From pgsql-performance-owner@postgresql.org Mon Apr 28 07:12:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4A0BC4758C9 for ; Mon, 28 Apr 2003 07:12:08 -0400 (EDT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 51B1A474E42 for ; Mon, 28 Apr 2003 07:12:04 -0400 (EDT) Received: from [10.1.2.130] (helo=dba2) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 19A6YJ-0003aJ-00 for ; Mon, 28 Apr 2003 07:12:07 -0400 Received: by dba2 (Postfix, from userid 1019) id D8C42CEDF; Mon, 28 Apr 2003 07:12:06 -0400 (EDT) Date: Mon, 28 Apr 2003 07:12:06 -0400 From: Andrew Sullivan To: pgsql-performance@postgresql.org Subject: Re: Diferent execution plan for similar query Message-ID: <20030428111206.GA15801@libertyrms.info> Mail-Followup-To: Andrew Sullivan , pgsql-performance@postgresql.org References: <62257.129.178.88.66.1051527603.squirrel@mail2.fbab.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <62257.129.178.88.66.1051527603.squirrel@mail2.fbab.net> User-Agent: Mutt/1.5.3i X-Spam-Status: No, hits=-34.8 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/230 X-Sequence-Number: 1736 On Mon, Apr 28, 2003 at 01:00:03PM +0200, Magnus Naeslund(w) wrote: > Is this an nontrivial change? > Because if it's trivial it should be done, imho. It's not trivial. If it were, it would have been done already. See the TODO entries about this, and the many discussions about it on -hackers, for why it's not trivial. A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110 From pgsql-performance-owner@postgresql.org Mon Apr 28 14:21:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0D62547638F for ; Mon, 28 Apr 2003 14:21:47 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id AE642475956 for ; Mon, 28 Apr 2003 14:21:43 -0400 (EDT) Received: (qmail 95382 invoked by uid 1001); 28 Apr 2003 18:21:43 -0000 Date: Mon, 28 Apr 2003 13:21:43 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: How to get the optimizer to use an index with multiple fields Message-ID: <20030428132143.J66185@flake.decibel.org> Reply-To: jim@nasby.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-13.5 required=5.0 tests=BAYES_01,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/231 X-Sequence-Number: 1737 select id into temp NewRetires from stats_participant where retire_to>=1 AND retire_date = (SELECT last_date FROM Project_statsrun WHERE project_id = :ProjectID); results in a table with 5 values... explain analyze delete from email_rank where project_id=25 and id in (select id from NewRetires); Index Scan using email_rank__day_rank on email_rank (cost=0.00..9003741627715.16 rows=45019 width=6) (actual time=408.12..9688.37 rows=3 loops=1) Index Cond: (project_id = 25) Filter: (subplan) SubPlan -> Seq Scan on newretires (cost=100000000.00..100000020.00 rows=1000 width=4) (actual time=0.01..0.05 rows=5 loops=91834) Total runtime: 9689.86 msec But, there's already an index that would fit the bill here perfectly: Table "public.email_rank" Column | Type | Modifiers -----------------------+---------+-------------------- project_id | integer | not null id | integer | not null first_date | date | not null last_date | date | not null day_rank | integer | not null default 0 day_rank_previous | integer | not null default 0 overall_rank | integer | not null default 0 overall_rank_previous | integer | not null default 0 work_today | bigint | not null default 0 work_total | bigint | not null default 0 Indexes: email_rank_pkey primary key btree (project_id, id), email_rank__day_rank btree (project_id, day_rank), email_rank__overall_rank btree (project_id, overall_rank) Why isn't it using email_rank_pkey instead of using day_rank then a filter? The original query on sybase (see below) is essentially instant, because it's using the index of (project_id, id), so it doesn't have to read the whole table. stats=> select project_id,count(*) from email_rank group by project_id; project_id | count ------------+-------- 5 | 327856 8 | 28304 24 | 34622 25 | 91834 205 | 331464 Also, changing the WHERE IN to a WHERE EXISTS in the delete is substantially faster in this case (3.5 seconds as opposed to 9); it would be nice if the optimizer could rewrite the query on-the-fly. I started looking into this in the first place because the original query was taking 6-10 seconds, which seemed too long... Original query: DELETE FROM Email_Rank WHERE project_id = :ProjectID AND id IN (SELECT id FROM STATS_Participant sp WHERE retire_to >= 1 AND retire_date = (SELECT last_date FROM Project_statsrun WHERE project_id = :ProjectID) ) ; I tried changing this to an EXISTS and it takes over a minute. So in this case, the range of runtimes is ~4 seconds (building the temp table takes ~0.25 seconds) to over a minute. -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Mon Apr 28 14:32:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B0BC475D91 for ; Mon, 28 Apr 2003 14:32:46 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 7700E475B47 for ; Mon, 28 Apr 2003 14:32:44 -0400 (EDT) Received: (qmail 96396 invoked by uid 1001); 28 Apr 2003 18:32:44 -0000 Date: Mon, 28 Apr 2003 13:32:44 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Re: How to get the optimizer to use an index with multiple fields Message-ID: <20030428133244.K66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030428132143.J66185@flake.decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20030428132143.J66185@flake.decibel.org>; from jim@nasby.net on Mon, Apr 28, 2003 at 01:21:43PM -0500 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/232 X-Sequence-Number: 1738 On Mon, Apr 28, 2003 at 01:21:43PM -0500, Jim C. Nasby wrote: > I tried changing this to an EXISTS and it takes over a minute. So in > this case, the range of runtimes is ~4 seconds (building the temp table > takes ~0.25 seconds) to over a minute. BTW, I forgot to mention that building the temp table only takes 0.25 seconds if I first disable sequential scans. :/ -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Mon Apr 28 16:04:10 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0DBEB475B47 for ; Mon, 28 Apr 2003 16:04:09 -0400 (EDT) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by postgresql.org (Postfix) with ESMTP id 2C880474E42 for ; Mon, 28 Apr 2003 16:04:08 -0400 (EDT) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.9/8.12.9) with ESMTP id h3SK1hD2003167; Mon, 28 Apr 2003 14:01:43 -0600 (MDT) Date: Mon, 28 Apr 2003 13:52:57 -0600 (MDT) From: "scott.marlowe" To: "Jim C. Nasby" Cc: Subject: Re: How to get the optimizer to use an index with multiple In-Reply-To: <20030428132143.J66185@flake.decibel.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MailScanner: Found to be clean X-MailScanner-SpamCheck: X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/233 X-Sequence-Number: 1739 On Mon, 28 Apr 2003, Jim C. Nasby wrote: > select id into temp NewRetires from stats_participant where retire_to>=1 > AND retire_date = (SELECT last_date FROM Project_statsrun WHERE > project_id = :ProjectID); > > results in a table with 5 values... > > explain analyze delete from email_rank where project_id=25 and id in > (select id from NewRetires); > > Index Scan using email_rank__day_rank on email_rank > (cost=0.00..9003741627715.16 rows=45019 width=6) (actual time=408.12..9688.37 rows=3 loops=1) > Index Cond: (project_id = 25) > Filter: (subplan) > SubPlan > -> Seq Scan on newretires (cost=100000000.00..100000020.00 rows=1000 width=4) (actual time=0.01..0.05 rows=5 loops=91834) > Total runtime: 9689.86 msec > > But, there's already an index that would fit the bill here perfectly: > > Table "public.email_rank" > Column | Type | Modifiers > -----------------------+---------+-------------------- > project_id | integer | not null > id | integer | not null > first_date | date | not null > last_date | date | not null > day_rank | integer | not null default 0 > day_rank_previous | integer | not null default 0 > overall_rank | integer | not null default 0 > overall_rank_previous | integer | not null default 0 > work_today | bigint | not null default 0 > work_total | bigint | not null default 0 > Indexes: email_rank_pkey primary key btree (project_id, id), > email_rank__day_rank btree (project_id, day_rank), > email_rank__overall_rank btree (project_id, overall_rank) > > Why isn't it using email_rank_pkey instead of using day_rank then a > filter? The original query on sybase (see below) is essentially instant, > because it's using the index of (project_id, id), so it doesn't have to > read the whole table. It looks like the seq scan is newretires up there, from your 'id in (select id from NewRetires);' part of your query. I.e. the where in() has to be done first, and the query planner has no stats on that table, so it assumes a seq scan will be faster in case we need the whole thing anyway. Try adding an analyze newretires in there between the two queries. No clue as to why it's choosing one index over the other. I don't think that really matters a lot, it's the seq scan on the temp table that is taking your time on this. From pgsql-performance-owner@postgresql.org Mon Apr 28 18:54:45 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9DAB3475FC8 for ; Mon, 28 Apr 2003 18:54:42 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 7FEA8475F39 for ; Mon, 28 Apr 2003 18:54:36 -0400 (EDT) Received: (qmail 6715 invoked by uid 1001); 28 Apr 2003 22:54:39 -0000 Date: Mon, 28 Apr 2003 17:54:39 -0500 From: "Jim C. Nasby" To: "scott.marlowe" Cc: pgsql-performance@postgresql.org Subject: Re: How to get the optimizer to use an index with multiple Message-ID: <20030428175439.L66185@flake.decibel.org> Reply-To: jim@nasby.net References: <20030428132143.J66185@flake.decibel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from scott.marlowe@ihs.com on Mon, Apr 28, 2003 at 01:52:57PM -0600 X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-39.4 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/234 X-Sequence-Number: 1740 On Mon, Apr 28, 2003 at 01:52:57PM -0600, scott.marlowe wrote: > On Mon, 28 Apr 2003, Jim C. Nasby wrote: > > > select id into temp NewRetires from stats_participant where retire_to>=1 > > AND retire_date = (SELECT last_date FROM Project_statsrun WHERE > > project_id = :ProjectID); > > > > results in a table with 5 values... > > > > explain analyze delete from email_rank where project_id=25 and id in > > (select id from NewRetires); > > > > Index Scan using email_rank__day_rank on email_rank > > (cost=0.00..9003741627715.16 rows=45019 width=6) (actual time=408.12..9688.37 rows=3 loops=1) > > Index Cond: (project_id = 25) > > Filter: (subplan) > > SubPlan > > -> Seq Scan on newretires (cost=100000000.00..100000020.00 rows=1000 width=4) (actual time=0.01..0.05 rows=5 loops=91834) > > Total runtime: 9689.86 msec > > > > But, there's already an index that would fit the bill here perfectly: > > > > Table "public.email_rank" > > Column | Type | Modifiers > > -----------------------+---------+-------------------- > > project_id | integer | not null > > id | integer | not null > > first_date | date | not null > > last_date | date | not null > > day_rank | integer | not null default 0 > > day_rank_previous | integer | not null default 0 > > overall_rank | integer | not null default 0 > > overall_rank_previous | integer | not null default 0 > > work_today | bigint | not null default 0 > > work_total | bigint | not null default 0 > > Indexes: email_rank_pkey primary key btree (project_id, id), > > email_rank__day_rank btree (project_id, day_rank), > > email_rank__overall_rank btree (project_id, overall_rank) > > > > Why isn't it using email_rank_pkey instead of using day_rank then a > > filter? The original query on sybase (see below) is essentially instant, > > because it's using the index of (project_id, id), so it doesn't have to > > read the whole table. > > It looks like the seq scan is newretires up there, from your 'id in > (select id from NewRetires);' part of your query. I.e. the where in() has > to be done first, and the query planner has no stats on that table, so it > assumes a seq scan will be faster in case we need the whole thing anyway. > > Try adding an analyze newretires in there between the two queries. > > No clue as to why it's choosing one index over the other. I don't think > that really matters a lot, it's the seq scan on the temp table that is > taking your time on this. There's no index at all on the temporary table; I fully expect it to seqscan than. :) The issue is the choice of index on email_rank. It's only going to hit at most 5 rows in email_rank (which it should be able to figure out based on newretires and the fact that email_rank_pkey is unique. I didn't show it, but I did run analyze on the temporary table (why it doesn't have statistics I don't know...) -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-advocacy-owner@postgresql.org Tue Apr 29 00:48:41 2003 X-Original-To: pgsql-advocacy@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80A5D476022; Tue, 29 Apr 2003 00:48:38 -0400 (EDT) Received: from neuromancer.ctlno.com (unknown [208.13.35.90]) by postgresql.org (Postfix) with ESMTP id BEA5D475F26; Tue, 29 Apr 2003 00:48:02 -0400 (EDT) Received: from [192.168.1.10] (ool-4352919e.dyn.optonline.net [67.82.145.158]) by neuromancer.ctlno.com (8.12.6/8.12.6) with ESMTP id h3T5jfkN017013; Tue, 29 Apr 2003 00:45:41 -0500 Subject: Re: [HACKERS] Changing the default configuration From: "Matthew T. O'Connor" To: Tatsuo Ishii Cc: tgl@sss.pgh.pa.us, justin@postgresql.org, josh@agliodbs.com, merlin.moncure@rcsonline.com, pgsql-hackers@postgresql.org, pgsql-advocacy@postgresql.org In-Reply-To: <20030212.101000.74752335.t-ishii@sra.co.jp> References: <26582.1044984365@sss.pgh.pa.us> <3E493415.9090004@postgresql.org> <26850.1044985975@sss.pgh.pa.us> <20030212.101000.74752335.t-ishii@sra.co.jp> Content-Type: text/plain Organization: Zeut Tech Message-Id: <1051591298.7047.11.camel@zeutrh9> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 29 Apr 2003 00:41:38 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Spam-Status: No, hits=-36.7 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/177 X-Sequence-Number: 1118 On Tue, 2003-02-11 at 20:10, Tatsuo Ishii wrote: > Sigh. People always complain "pgbench does not reliably producing > repeatable numbers" or something then say "that's because pgbench's > transaction has too much contention on the branches table". So I added > -N option to pgbench which makes pgbench not to do any UPDATE to > the branches table. But still people continue to complian... What exactly does the -N option do? I see no mention of it in the README.pgbench, which might be part of reason people "continue to complain". From pgsql-performance-owner@postgresql.org Tue Apr 29 03:01:27 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A4251476375 for ; Tue, 29 Apr 2003 03:01:24 -0400 (EDT) Received: from rtlocal.trade-india.com (unknown [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 6051447632B for ; Tue, 29 Apr 2003 03:00:42 -0400 (EDT) Received: (qmail 6406 invoked from network); 29 Apr 2003 07:00:43 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 29 Apr 2003 07:00:43 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: pgsql-performance@postgresql.org Subject: Is 292 inserts/sec acceptable performance ? Date: Tue, 29 Apr 2003 12:31:09 +0530 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304291231.09842.mallah@trade-india.com> X-Spam-Status: No, hits=-5.9 required=5.0 tests=BAYES_01,NO_DNS_FOR_FROM,SIGNATURE_SHORT_SPARSE,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/235 X-Sequence-Number: 1741 Hi Can anyone tell if the case below is an acceptable performance ? I have a query that returns data and creates a table in 3 mins approx. This query is optimised and uses appropriate indexes for the NOT EXISTS part. CREATE TABLE t_a as SELECT email,country_code,city,title1,fname1,mname1,lname1,website,address,source,ifimporter, ifexporter,ifservice,ifmanu,creation_date from general.email_bank_import where not exists (select * from general.profile_master where email=general.email_bank_import.email) ; SELECT Time: 174637.31 ms (3 mins Approx) The problem is when i try to INSERT the data into another table it takes 23 mins Apprx to inser 412331 records the same query. I am providing the various details below: tradein_clients=# INSERT INTO general.profile_master (email,country_code,city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexporter, ifservice, ifmanu,creation_date) SELECT email,country_code, city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexporter,ifservice, ifmanu,creation_date from general.email_bank_import where not exists (select * from general.profile_master where email=general.email_bank_import.email) ; INSERT 0 412331 Time: 1409510.63 ms The table destination general.profile_master in which data is being inserted was already having 184424 records before the INSERT the VACUUM FULL ANALZYE VERBOSE output was: tradein_clients=# VACUUM FULL VERBOSE ANALYZE profile_master ; INFO: --Relation general.profile_master-- INFO: Pages 9161: Changed 0, reaped 8139, Empty 0, New 0; Tup 184424: Vac 72, Keep/VTL 0/0, UnUsed 118067, MinLen 154, MaxLen 2034; Re-using: Free/Avail. Space 708064/337568; EndEmpty/Avail. Pages 0/1669. CPU 0.17s/0.03u sec elapsed 0.21 sec. INFO: Index profile_master_email: Pages 8921; Tuples 184424: Deleted 72. CPU 0.15s/0.21u sec elapsed 0.37 sec. INFO: Index profile_master_profile_id_pkey: Pages 1295; Tuples 184424: Deleted 72. CPU 0.03s/0.10u sec elapsed 0.16 sec. INFO: Rel profile_master: Pages: 9161 --> 9161; Tuple(s) moved: 0. CPU 0.44s/0.98u sec elapsed 15.79 sec. INFO: --Relation pg_toast.pg_toast_163041602-- INFO: Pages 31: Changed 0, reaped 1, Empty 0, New 0; Tup 187: Vac 0, Keep/VTL 0/0, UnUsed 2, MinLen 50, MaxLen 2034; Re-using: Free/Avail. Space 24800/24788; EndEmpty/Avail. Pages 0/30. CPU 0.00s/0.00u sec elapsed 3.04 sec. INFO: Index pg_toast_163041602_index: Pages 2; Tuples 187: Deleted 0. CPU 0.00s/0.00u sec elapsed 0.49 sec. INFO: Rel pg_toast_163041602: Pages: 31 --> 31; Tuple(s) moved: 0. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: Analyzing general.profile_master VACUUM It was already vacuumed once. Index Info: Only two indexes were existing tradein_clients=# \d profile_master Table "general.profile_master" +--------------------+------------------------+------- | Column | Type | +--------------------+------------------------+------- | profile_id | integer | | userid | integer | | co_name | character varying(100) | | address | text | | pincode | character varying(20) | | city | character varying(50) | | country_code | character varying(2) | | phone_no | character varying(100) | | fax_no | character varying(100) | | email | character varying(100) | | website | character varying(100) | | title1 | character varying(15) | | fname1 | character varying(200) | | mname1 | character varying(30) | | lname1 | character varying(30) | | desg1 | character varying(100) | | mobile | character varying(20) | | title2 | character varying(15) | | fname2 | character varying(30) | | mname2 | character varying(30) | | lname2 | character varying(30) | | desg2 | character varying(100) | | mobile2 | character varying(20) | | co_branches | character varying(100) | | estd | smallint | | staff | integer | | prod_exp | text | | prod_imp | text | | prod_manu | text | | prod_serv | text | | ifexporter | boolean | not null | ifimporter | boolean | not null | ifservice | boolean | not null | ifmanu | boolean | not null | bankers | character varying(255) | | imp_exp_code | character varying(100) | | memb_affil | character varying(255) | | std_cert | character varying(255) | | branch_id | integer | | area_id | integer | | annual_turn | numeric | | annual_currency | character varying(5) | | exp_turn | numeric | | exp_currency | character varying(5) | | imp_turn | numeric | | imp_currency | character varying(5) | | creation_date | integer | not null | profile_status | character varying(10) | | source | character varying(20) | not null | company_id | integer | | eyp_list_id | integer | | iid_list_id | integer | | ip_list_id | integer | | catalog_company_id | integer | | extra_attributes | boolean | not null default false | ------------------------------------------------------------------------ Indexes: profile_master_profile_id_pkey primary key btree (profile_id), profile_master_email btree (email) -- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Tue Apr 29 03:26:18 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 95599476022 for ; Tue, 29 Apr 2003 03:26:16 -0400 (EDT) Received: from www.pspl.co.in (www.pspl.co.in [202.54.11.65]) by postgresql.org (Postfix) with ESMTP id 61F76476022 for ; Tue, 29 Apr 2003 03:25:39 -0400 (EDT) Received: (from root@localhost) by www.pspl.co.in (8.11.6/8.11.6) id h3T7PcL27972 for ; Tue, 29 Apr 2003 12:55:38 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) by www.pspl.co.in (8.11.6/8.11.0) with ESMTP id h3T7Pc427967 for ; Tue, 29 Apr 2003 12:55:38 +0530 From: Shridhar Daithankar To: pgsql-performance@postgresql.org Subject: Re: Is 292 inserts/sec acceptable performance ? Date: Tue, 29 Apr 2003 12:55:15 +0530 User-Agent: KMail/1.5.1 References: <200304291231.09842.mallah@trade-india.com> In-Reply-To: <200304291231.09842.mallah@trade-india.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304291255.15558.shridhar_daithankar@nospam.persistent.co.in> X-Spam-Status: No, hits=-37.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/236 X-Sequence-Number: 1742 On Tuesday 29 April 2003 12:31, Rajesh Kumar Mallah wrote: > Hi Can anyone tell if the case below is an acceptable > performance ? > > I have a query that returns data and creates a table > in 3 mins approx. This query is optimised and uses appropriate > indexes for the NOT EXISTS part. > > CREATE TABLE t_a as SELECT > email,country_code,city,title1,fname1,mname1,lname1,website,address,source, >ifimporter, ifexporter,ifservice,ifmanu,creation_date from > general.email_bank_import where not exists (select * from > general.profile_master where > email=general.email_bank_import.email) ; > SELECT > Time: 174637.31 ms (3 mins Approx) > > > > The problem is when i try to INSERT the data into another table > it takes 23 mins Apprx to inser 412331 records the same query. > > I am providing the various details below: > > tradein_clients=# INSERT INTO general.profile_master > (email,country_code,city,title1,fname1,mname1,lname1,website,address,source >,ifimporter,ifexporter, ifservice, ifmanu,creation_date) SELECT > email,country_code, > city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexport >er,ifservice, ifmanu,creation_date from general.email_bank_import where > not exists (select * from general.profile_master where > email=general.email_bank_import.email) ; > INSERT 0 412331 > Time: 1409510.63 ms I am not sure if this would help but why you have to use all the fields in not exists clause? How about not exists for a name or profile_id? Would it be any faster I assume if there are two records with half the info same, then not exists for 1 field with index would be significantly faster than 10 fields. HTH Shridhar From pgsql-performance-owner@postgresql.org Tue Apr 29 05:03:38 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D972D4758F1 for ; Tue, 29 Apr 2003 05:03:35 -0400 (EDT) Received: from web41213.mail.yahoo.com (web41213.mail.yahoo.com [66.218.93.46]) by postgresql.org (Postfix) with SMTP id E308447635B for ; Tue, 29 Apr 2003 05:02:59 -0400 (EDT) Message-ID: <20030429090301.13152.qmail@web41213.mail.yahoo.com> Received: from [68.4.184.46] by web41213.mail.yahoo.com via HTTP; Tue, 29 Apr 2003 02:03:01 PDT Date: Tue, 29 Apr 2003 02:03:01 -0700 (PDT) From: Rob Messer Subject: Optimizer not using index when it should To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Status: No, hits=-4.5 required=5.0 tests=BAYES_10,NO_DNS_FOR_FROM version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/237 X-Sequence-Number: 1743 Like some other recent messages, this one is about getting postgresql to use an index that it seems it should clearly use. (But this one has nothing to do with count(*)). Here is my table: Column | Type | Modifiers --------------+-----------------------------+----------- dsid | character varying(20) | not null recid | numeric(8,0) | not null trans_id | character varying(16) | not null status | character varying(1) | init_ts | timestamp without time zone | last_ts | timestamp without time zone | last_form_id | character varying(8) | secval | character varying(20) | Indexes: ds_rec1 unique btree (recid), ds_rec2 btree (dsid) Here is my version info: PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7) Currently the table ds_record has about 250,000 records in it. Of those, about 3000 have dsid = 'starz'. When I need to look up all the recids with this dsid in ds_record, I have the following simple query: select recid from ds_record where dsid = 'startz'; But it doesn't use the index ds_rec2 on dsid. Here is the explain analyze output: intellis2=> explain analyze select recid from ds_record where dsid = 'starz'; QUERY PLAN -------------------------------------------------------------------------------------------------------------- Seq Scan on ds_record (cost=0.00..6186.21 rows=3484 width=12) (actual time=10.60..408.12 rows=3484 loops=1) Filter: (dsid = 'starz'::character varying) Total runtime: 410.14 msec (3 rows) but if I turn off seqscan I get this: intellis2=> set enable_seqscan=off; SET intellis2=> explain analyze select recid from ds_record where dsid = 'starz'; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Index Scan using ds_rec2 on ds_record (cost=0.00..7185.47 rows=3484 width=12) (actual time=0.17..12.94 rows=3484 loops=1) Index Cond: (dsid = 'starz'::character varying) Total runtime: 14.97 msec (3 rows) so it is faster by more than a factor of 25 to use the index. The problem gets worse when I add a join to the table. I have tried the following: alter table ds_record alter dsid set statistics 1000; vacuum analyze ds_record; drop index ds_rec2; CREATE INDEX ds_rec2 ON ds_record USING btree (dsid); But to no avail, I get the same results. Interestingly, for queries that return fewer rows it does use the correct index. For example, dsid="mapbuy2" appears about 500 times in ds_record. Here is the explain out there (with enable_seqscan back on): intellis2=> explain analyze select recid from ds_record where dsid = 'mapbuy2'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- Index Scan using ds_rec2 on ds_record (cost=0.00..1351.17 rows=522 width=12) (actual time=0.18..4.31 rows=522 loops=1) Index Cond: (dsid = 'mapbuy2'::character varying) Total runtime: 4.68 msec To me it seems that the threshold for doing a table scan is wrong -- when the rows retrieved are about 1.25% of the table it does a scan. What can I do to fix this -- is there something I am missing about setting statistics or some configuration variable I can change? Any insights would be greatly appreciated. Thank you, Rob Messer __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com From pgsql-performance-owner@postgresql.org Tue Apr 29 07:12:36 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E02414763C2 for ; Tue, 29 Apr 2003 07:12:34 -0400 (EDT) Received: from rtlocal.trade-india.com (unknown [203.196.129.235]) by postgresql.org (Postfix) with SMTP id F3D514763C2 for ; Tue, 29 Apr 2003 07:11:53 -0400 (EDT) Received: (qmail 21477 invoked from network); 29 Apr 2003 11:11:56 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 29 Apr 2003 11:11:56 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: Shridhar Daithankar , pgsql-performance@postgresql.org Subject: Re: Is 292 inserts/sec acceptable performance ? Date: Tue, 29 Apr 2003 16:42:24 +0530 User-Agent: KMail/1.5 References: <200304291231.09842.mallah@trade-india.com> <200304291255.15558.shridhar_daithankar@nospam.persistent.co.in> In-Reply-To: <200304291255.15558.shridhar_daithankar@nospam.persistent.co.in> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304291642.24543.mallah@trade-india.com> X-Spam-Status: No, hits=-31.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, SIGNATURE_SHORT_SPARSE,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/238 X-Sequence-Number: 1744 Yeah even 1 feild can be given in the NOT EXISTS part. bUt i vaugely recally tom saying that it does not matter and internally its converted to "select * form tab" from, correct me if i am recalling wrong. in anycase the CREATE TABLE part is working fine ie in 3 mins the select and table creation is over. Is the continuously entering data slowing down the NO EXISTS part ? in any case that inserts are supposed to be invisible to the NOT EXISTS part i guess. regds mallah. On Tuesday 29 Apr 2003 12:55 pm, Shridhar Daithankar wrote: > On Tuesday 29 April 2003 12:31, Rajesh Kumar Mallah wrote: > > Hi Can anyone tell if the case below is an acceptable > > performance ? > > > > I have a query that returns data and creates a table > > in 3 mins approx. This query is optimised and uses appropriate > > indexes for the NOT EXISTS part. > > > > CREATE TABLE t_a as SELECT > > email,country_code,city,title1,fname1,mname1,lname1,website,address,sourc > >e, ifimporter, ifexporter,ifservice,ifmanu,creation_date from > > general.email_bank_import where not exists (select * from > > general.profile_master where > > email=general.email_bank_import.email) ; > > SELECT > > Time: 174637.31 ms (3 mins Approx) > > > > > > > > The problem is when i try to INSERT the data into another table > > it takes 23 mins Apprx to inser 412331 records the same query. > > > > I am providing the various details below: > > > > tradein_clients=# INSERT INTO general.profile_master > > (email,country_code,city,title1,fname1,mname1,lname1,website,address,sour > >ce ,ifimporter,ifexporter, ifservice, ifmanu,creation_date) SELECT > > email,country_code, > > city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexpo > >rt er,ifservice, ifmanu,creation_date from general.email_bank_import > > where not exists (select * from general.profile_master where > > email=general.email_bank_import.email) ; > > INSERT 0 412331 > > Time: 1409510.63 ms > > I am not sure if this would help but why you have to use all the fields in > not exists clause? How about not exists for a name or profile_id? Would it > be any faster > > I assume if there are two records with half the info same, then not exists > for 1 field with index would be significantly faster than 10 fields. > > HTH > > Shridhar > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html -- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Tue Apr 29 07:24:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E89A74763BA for ; Tue, 29 Apr 2003 07:24:32 -0400 (EDT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 2E0084763C2 for ; Tue, 29 Apr 2003 07:23:54 -0400 (EDT) Received: (qmail 21824 invoked from network); 29 Apr 2003 11:24:32 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 29 Apr 2003 11:24:32 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: pgsql-performance@postgresql.org Subject: profiling plpgsql functions.. Date: Tue, 29 Apr 2003 16:55:01 +0530 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304291655.01035.mallah@trade-india.com> X-Spam-Status: No, hits=-5.9 required=5.0 tests=BAYES_01,NO_DNS_FOR_FROM,SIGNATURE_SHORT_SPARSE,USER_AGENT version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/239 X-Sequence-Number: 1745 Is printing timeofday() at various points a good idea of profiling plpgsql functions? also is anything wrong with following fragment ? RAISE INFO '' % , message here ... '' , timeofday() ; regds mallah. -- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Tue Apr 29 09:35:29 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 064EF4763E7; Tue, 29 Apr 2003 09:35:25 -0400 (EDT) Received: from mail.deltav.hu (mail.deltav.hu [213.163.0.192]) by postgresql.org (Postfix) with ESMTP id 1DCB34763E9; Tue, 29 Apr 2003 09:34:48 -0400 (EDT) Received: from fejleszt2 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA4691; Tue, 29 Apr 2003 15:34:49 +0200 Message-ID: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: , Subject: Query Plan far worse in 7.3.2 than 7.2.1 Date: Tue, 29 Apr 2003 15:01:21 +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-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_20,NO_DNS_FOR_FROM version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/241 X-Sequence-Number: 1747 Dear Gurus, A nasty query and its EXPLAINs are here. Read on at your own risk :) ABSTRACT: Search for the strings "looping index scan" and "loops=2310" in this message. DETAILS: Yesteray, I spent two hours to optimize a view in postgresql 7.2.1. My problem was that one of the index scans executed 2358 times, which is (as far as I can consider) equal to 2x1179, where 2 is the #rows in a subquery, and 1179 is the total #rows in the table of the index scan ("arfolyam"). Finally I managed to put it as deep in the query as possible, to reduce the loops to the number of query result rows (12) However, when I tried the same query in 7.3.2, it first complained about a missing FROM clause and a missing GROUP BY for a field. I managed to eliminate both without affecting 7.2.1 performance, but in 7.3.2, there are still those 2300+ loops of the index scan. I ask your kind help, explanation or references to documented similar cases. Below is the query and the two explains. Please forgive the raw format. If you need further info (such as table defs), I'd be glad to help. Note that the two databases are not exactly the same but very similar (they where the same 2 weeks ago, but data changes occured in both, independently) and I don't think these differences should affect the planner. Yours, G. -- while (!asleep()) sheep++; ---------------------------- QUERY ----------------------------------- SELECT *, kerekit_penznem (netto_ertek*(afa_szazalek/100), penznem) AS afa_ertek, kerekit_penznem (netto_ertek*(1+afa_szazalek/100), penznem) AS brutto_ertek FROM ( SELECT szamla, kerekit_penznem( elsodl_netto_ertek*COALESCE(deka,1)/COALESCE(dekb,1), penznem) AS netto_ertek, konyvelesi_tetelcsoport, afa, afa_szazalek, penznem FROM (SELECT szt.szamla, kerekit_penznem(sum(szt.netto_egysegar * szt.mennyiseg), penznem) AS elsodl_netto_ertek, konyvelesi_tetelcsoport(szt.szamla, szt.tetelszam) AS konyvelesi_tetelcsoport, szt.afa, afa.ertek AS afa_szazalek, szamla.penznem AS sz_penznem, szamla.teljesites AS sz_teljesites, arf_a.deviza_kozeparfolyam as deka, arf_b.deviza_kozeparfolyam as dekb, foo_valuta AS penznem FROM szamla_tetele szt LEFT JOIN szamla ON (szamla = szamla.az) LEFT JOIN afa ON (afa.az = szt.afa) LEFT JOIN arfolyam arf_a ON (arf_a.ervenyes = (SELECT ervenyes FROM arfolyam WHERE ervenyes<=szamla.teljesites AND valuta = szamla.penznem ORDER BY 1 DESC LIMIT 1) AND szamla.penznem=arf_a.valuta) JOIN (SELECT az AS foo_valuta FROM valuta) AS valuta ON (true) LEFT JOIN arfolyam arf_b ON (arf_b.valuta=foo_valuta AND arf_b.ervenyes = -- this is the looping index scan -- (SELECT ervenyes FROM arfolyam WHERE ervenyes<=szamla.teljesites AND valuta = foo_valuta ORDER BY 1 DESC LIMIT 1) -- end of looping index scan -- ) WHERE (NOT szt.archiv) AND (foo_valuta = 4 or arf_b.valuta notnull ) GROUP BY szt.szamla, konyvelesi_tetelcsoport, szt.afa, sz_penznem, sz_teljesites, afa.ertek, arf_a.deviza_kozeparfolyam, arf_b.deviza_kozeparfolyam, foo_valuta, penznem ) foo ) bar WHERE szamla=2380; ---------------------------- 7.2.1 PLAN ------------------------------ Subquery Scan foo (cost=488.97..490.94 rows=8 width=104) (actual time=94.77..109.10 rows=12 loops=1) -> Aggregate (cost=488.97..490.94 rows=8 width=104) (actual time=89.29..92.05 rows=12 loops=1) -> Group (cost=488.97..490.74 rows=79 width=104) (actual time=88.13..88.59 rows=12 loops=1) -> Sort (cost=488.97..488.97 rows=79 width=104) (actual time=88.09..88.13 rows=12 loops=1) -> Nested Loop (cost=1.05..486.50 rows=79 width=104) (actual time=28.23..86.20 rows=12 loops=1) -> Nested Loop (cost=1.05..150.19 rows=79 width=84) (actual time=12.68..25.41 rows=12 loops=1) -> Nested Loop (cost=1.05..135.52 rows=13 width=80) (actual time=12.60..24.80 rows=2 loops=1) -> Hash Join (cost=1.05..79.59 rows=13 width=60) (actual time=0.55..0.80 rows=2 loops=1) -> Nested Loop (cost=0.00..78.31 rows=13 width=46) (actual time=0.23..0.42 rows=2 loops=1) -> Index Scan using szml_ttl_szml on szamla_tetele szt (cost=0.00..3.51 rows=13 width=34) (actual time=0.11..0.16 rows=2 loops=1) -> Index Scan using szamla_az_key on szamla (cost=0.00..5.70 rows=1 width=12) (actual time=0.07..0.09 rows=1 loops=2) -> Hash (cost=1.04..1.04 rows=4 width=14) (actual time=0.14..0.14 rows=0 loops=1) -> Seq Scan on afa (cost=0.00..1.04 rows=4 width=14) (actual time=0.08..0.11 rows=4 loops=1) -> Index Scan using arfolyam_ervenyes on arfolyam arf_a (cost=0.00..3.63 rows=3 width=20) (actual time=0.01..0.01 rows=0 loops=2) SubPlan -> Limit (cost=0.00..0.17 rows=1 width=4) (actual time=11.92..11.92 rows=0 loops=2) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..13.30 rows=79 width=4) (actual time=11.90..11.90 rows=0 loops=2) -> Limit (cost=0.00..0.17 rows=1 width=4) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..13.30 rows=79 width=4) -> Seq Scan on valuta (cost=0.00..1.06 rows=6 width=4) (actual time=0.02..0.11 rows=6 loops=2) -> Index Scan using arfolyam_ervenyes on arfolyam arf_b (cost=0.00..3.63 rows=3 width=20) (actual time=0.04..0.10 rows=3 loops=12) SubPlan -> Limit (cost=0.00..0.17 rows=1 width=4) (actual time=4.35..4.39 rows=1 loops=12) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..13.30 rows=79 width=4) (actual time=4.33..4.37 rows=2 loops=12) -> Limit (cost=0.00..0.17 rows=1 width=4) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..13.30 rows=79 width=4) Total runtime: 111.48 msec ---------------------------- 7.3.2 PLAN ------------------------------ Subquery Scan foo (cost=14542.01..15448.46 rows=3022 width=123) (actual time=2264.36..2282.17 rows=12 loops=1) -> Aggregate (cost=14542.01..15448.46 rows=3022 width=123) (actual time=2257.70..2261.08 rows=12 loops=1) -> Group (cost=14542.01..15372.92 rows=30215 width=123) (actual time=2256.31..2256.84 rows=12 loops=1) -> Sort (cost=14542.01..14617.55 rows=30215 width=123) (actual time=2256.27..2256.31 rows=12 loops=1) Sort Key: szt.szamla, konyvelesi_tetelcsoport(szt.szamla, szt.tetelszam), szt.afa, szamla.penznem, szamla.teljesites, afa.ertek, arf_a.deviza_kozeparfolyam, arf_b.deviza_kozeparfolyam, public.valuta.az -> Merge Join (cost=4755.50..11038.79 rows=30215 width=123) (actual time=80.88..2254.96 rows=12 loops=1) Merge Cond: ("outer".az = "inner".valuta) Join Filter: ("inner".ervenyes = (subplan)) Filter: (("outer".az = 4) OR ("inner".valuta IS NOT NULL)) -> Sort (cost=4676.19..4751.73 rows=30215 width=103) (actual time=56.41..56.44 rows=12 loops=1) Sort Key: public.valuta.az -> Nested Loop (cost=433.35..1375.92 rows=30215 width=103) (actual time=55.78..56.18 rows=12 loops=1) -> Merge Join (cost=433.35..469.47 rows=30 width=99) (actual time=55.68..55.72 rows=2 loops=1) Merge Cond: ("outer".penznem = "inner".valuta) Join Filter: ("inner".ervenyes = (subplan)) -> Sort (cost=354.05..354.12 rows=30 width=79) (actual time=32.63..32.64 rows=2 loops=1) Sort Key: szamla.penznem -> Hash Join (cost=121.67..353.30 rows=30 width=79) (actual time=32.37..32.49 rows=2 loops=1) Hash Cond: ("outer".afa = "inner".az) -> Merge Join (cost=120.62..352.09 rows=30 width=58) (actual time=32.07..32.16 rows=2 loops=1) Merge Cond: ("outer".az = "inner".szamla) -> Sort (cost=120.62..123.85 rows=1291 width=12) (actual time=25.62..27.62 rows=1285 loops=1) Sort Key: szamla.az -> Seq Scan on szamla (cost=0.00..53.91 rows=1291 width=12) (actual time=0.04..16.46 rows=1314 loops=1) -> Index Scan using szamla_tetele_pkey on szamla_tetele szt (cost=0.00..218.88 rows=30 width=46) (actual time=0.13..0.18 rows=2 loops=1) Index Cond: (szamla = 2380) Filter: (NOT archiv) -> Hash (cost=1.04..1.04 rows=4 width=21) (actual time=0.10..0.10 rows=0 loops=1) -> Seq Scan on afa (cost=0.00..1.04 rows=4 width=21) (actual time=0.04..0.07 rows=4 loops=1) -> Sort (cost=79.30..82.19 rows=1155 width=20) (actual time=22.93..22.93 rows=1 loops=1) Sort Key: arf_a.valuta -> Seq Scan on arfolyam arf_a (cost=0.00..20.55 rows=1155 width=20) (actual time=0.03..9.66 rows=1155 loops=1) SubPlan -> Limit (cost=0.00..0.16 rows=1 width=4) (never executed) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..12.17 rows=77 width=4) (never executed) Index Cond: (ervenyes <= $0) Filter: (valuta = $1) -> Seq Scan on valuta (cost=0.00..20.00 rows=1000 width=4) (actual time=0.02..0.06 rows=6 loops=2) -> Sort (cost=79.30..82.19 rows=1155 width=20) (actual time=21.98..27.54 rows=2309 loops=1) Sort Key: arf_b.valuta -> Seq Scan on arfolyam arf_b (cost=0.00..20.55 rows=1155 width=20) (actual time=0.03..9.89 rows=1155 loops=1) SubPlan -> Limit (cost=0.00..0.16 rows=1 width=4) (actual time=0.88..0.91 rows=1 loops=2310) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=0.00..12.17 rows=77 width=4) (actual time=0.87..0.90 rows=2 loops=2310) Index Cond: (ervenyes <= $0) Filter: (valuta = $2) Total runtime: 2287.30 msec From pgsql-performance-owner@postgresql.org Tue Apr 29 09:04:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A5CB475F00 for ; Tue, 29 Apr 2003 09:04:34 -0400 (EDT) Received: from nat.inquent.com (CPE00508b028d7d-CM00803785c5e0.cpe.net.cable.rogers.com [24.103.22.28]) by postgresql.org (Postfix) with ESMTP id 372CB475F00 for ; Tue, 29 Apr 2003 09:03:58 -0400 (EDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by nat.inquent.com (8.12.8p1/8.12.8) with ESMTP id h3TD49Mn077441; Tue, 29 Apr 2003 09:04:09 -0400 (EDT) (envelope-from rbt@rbt.ca) Subject: Re: Optimizer not using index when it should From: Rod Taylor To: Rob Messer Cc: Postgresql Performance In-Reply-To: <20030429090301.13152.qmail@web41213.mail.yahoo.com> References: <20030429090301.13152.qmail@web41213.mail.yahoo.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-Ovj/BN9AuBu3Q4vbTld/" Organization: Message-Id: <1051621449.76105.9.camel@jester> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 29 Apr 2003 09:04:09 -0400 X-Spam-Status: No, hits=-36.5 required=5.0 tests=BAYES_10,IN_REP_TO,NO_DNS_FOR_FROM,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_XIMIAN autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/240 X-Sequence-Number: 1746 --=-Ovj/BN9AuBu3Q4vbTld/ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable > What can I do to fix this -- is there something I am missing about > setting statistics or some configuration variable I can change? Any > insights would be greatly appreciated. Thank you, If you look at the estimates for cost, the index scan is more expensive by ~1/8th. But as you've shown, it's not. You might try adjusting the random_page_cost down to something more appropriate for your hardware and situation. Do testing... this may cause other queries to use an index scan when they should have been doing a sequential scan. Mistakenly using an index can be a much more costly error (hence the high default random_page_cost). --=20 Rod Taylor PGP Key: http://www.rbt.ca/rbtpub.asc --=-Ovj/BN9AuBu3Q4vbTld/ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+rnhI6DETLow6vwwRAoncAJ457zHHTudzl3EDklw5xiUhlWiNwwCfWRwZ hzRGx/zN3z6wKyqBDffwNmw= =pEbG -----END PGP SIGNATURE----- --=-Ovj/BN9AuBu3Q4vbTld/-- From pgsql-performance-owner@postgresql.org Tue Apr 29 09:53:54 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2E98A47632B for ; Tue, 29 Apr 2003 09:53:54 -0400 (EDT) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id 0F598475F34 for ; Tue, 29 Apr 2003 09:53:18 -0400 (EDT) Received: (qmail 5861 invoked from network); 29 Apr 2003 13:53:18 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 29 Apr 2003 13:53:18 -0000 From: "Robert John Shepherd" To: Subject: Best ODBC cursor and lock types for fastest reading? Date: Tue, 29 Apr 2003 14:53:18 +0100 Message-ID: <001701c30e56$b0964400$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_20,NO_DNS_FOR_FROM version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/242 X-Sequence-Number: 1748 I access Postgresql through the ODBC driver, and always only read small recordsets (never updating them) with forward cursors. The following options are defined in ADO with which I can create a recordset with: Cursor types: adOpenForwardOnly (what I currently use) adOpenKeyset adOpenDynamic adOpenStatic Lock types: adLockReadOnly adLockPessimistic adLockOptimistic (what I currently use) adLockBatchOptimistic Do any of these offer a performance gain over others? I used to use adLockReadOnly with MS-SQL which really sped things up but this doesn't seem to work at all under Postgresql and I've been using adLockOptimistic instead. Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-performance-owner@postgresql.org Tue Apr 29 10:01:34 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 57D8C475F1B for ; Tue, 29 Apr 2003 10:01:31 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8155B475B47 for ; Tue, 29 Apr 2003 10:00:55 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TE0xU6026232; Tue, 29 Apr 2003 10:00:59 -0400 (EDT) To: Rajesh Kumar Mallah Cc: pgsql-performance@postgresql.org Subject: Re: Is 292 inserts/sec acceptable performance ? In-reply-to: <200304291231.09842.mallah@trade-india.com> References: <200304291231.09842.mallah@trade-india.com> Comments: In-reply-to Rajesh Kumar Mallah message dated "Tue, 29 Apr 2003 12:31:09 +0530" Date: Tue, 29 Apr 2003 10:00:59 -0400 Message-ID: <26231.1051624859@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-27.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/243 X-Sequence-Number: 1749 Rajesh Kumar Mallah writes: > Hi Can anyone tell if the case below is an acceptable > performance ? Not with that info. Could we see EXPLAIN ANALYZE results for both the faster and slower cases? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 29 10:18:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2939C475F00 for ; Tue, 29 Apr 2003 10:18:51 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6D86B475ADE for ; Tue, 29 Apr 2003 10:18:15 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TEIJU6026350; Tue, 29 Apr 2003 10:18:19 -0400 (EDT) To: Rod Taylor Cc: Rob Messer , Postgresql Performance Subject: Re: Optimizer not using index when it should In-reply-to: <1051621449.76105.9.camel@jester> References: <20030429090301.13152.qmail@web41213.mail.yahoo.com> <1051621449.76105.9.camel@jester> Comments: In-reply-to Rod Taylor message dated "29 Apr 2003 09:04:09 -0400" Date: Tue, 29 Apr 2003 10:18:19 -0400 Message-ID: <26349.1051625899@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.0 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/244 X-Sequence-Number: 1750 Rod Taylor writes: >> What can I do to fix this -- is there something I am missing about >> setting statistics or some configuration variable I can change? Any >> insights would be greatly appreciated. Thank you, > You might try adjusting the random_page_cost down to something more > appropriate for your hardware and situation. Also, is the table physically ordered by dsid? If so, is that condition likely to persist? You may be looking at a test-condition artifact here --- a poor estimate for an ordered table may not mean much when you get to realistic database states. I assume you've done an ANALYZE of course --- what does the pg_stats row for column dsid contain? regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 29 10:28:28 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 555E8475F0D for ; Tue, 29 Apr 2003 10:28:27 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 7975647631F for ; Tue, 29 Apr 2003 10:27:51 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TERtU6026414; Tue, 29 Apr 2003 10:27:55 -0400 (EDT) To: Rajesh Kumar Mallah Cc: pgsql-performance@postgresql.org Subject: Re: profiling plpgsql functions.. In-reply-to: <200304291655.01035.mallah@trade-india.com> References: <200304291655.01035.mallah@trade-india.com> Comments: In-reply-to Rajesh Kumar Mallah message dated "Tue, 29 Apr 2003 16:55:01 +0530" Date: Tue, 29 Apr 2003 10:27:55 -0400 Message-ID: <26413.1051626475@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-27.8 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/245 X-Sequence-Number: 1751 Rajesh Kumar Mallah writes: > Is printing timeofday() at various points a good idea > of profiling plpgsql functions? Sure. > also is anything wrong with following fragment ? > RAISE INFO '' % , message here ... '' , timeofday() ; IIRC, RAISE is pretty slovenly implemented :-( ... it will only take plain variable references as additional arguments. So you'll have to do var := timeofday(); RAISE INFO ''... '', var; I believe timeofday() produces TEXT, so declare the var that way. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 29 10:53:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id DDE7E475F00; Tue, 29 Apr 2003 10:53:47 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id D645F476262; Tue, 29 Apr 2003 10:53:11 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TErEU6026551; Tue, 29 Apr 2003 10:53:14 -0400 (EDT) To: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" Cc: pgsql-performance@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 In-reply-to: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> References: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> Comments: In-reply-to "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" message dated "Tue, 29 Apr 2003 15:01:21 +0200" Date: Tue, 29 Apr 2003 10:53:13 -0400 Message-ID: <26550.1051627993@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-24.7 required=5.0 tests=BAYES_01,IN_REP_TO,NO_DNS_FOR_FROM,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/246 X-Sequence-Number: 1752 "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: > A nasty query and its EXPLAINs are here. Read on at your own risk :) It's pretty much unreadable because of the way your mailer folded, spindled, and mutilated the EXPLAIN output :-( Could you resend in a more legible format? Maybe append the explain output as an attachment, if you can't get the mailer to leave its formatting alone otherwise. regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 29 11:40:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 84AFC475ADE for ; Tue, 29 Apr 2003 11:40:06 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 8659B475ADE for ; Tue, 29 Apr 2003 11:39:27 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2996181; Tue, 29 Apr 2003 08:38:54 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: "Robert John Shepherd" , Subject: Re: Best ODBC cursor and lock types for fastest reading? Date: Tue, 29 Apr 2003 08:38:50 -0700 User-Agent: KMail/1.4.3 References: <001701c30e56$b0964400$f3b0313e@LAIKA> In-Reply-To: <001701c30e56$b0964400$f3b0313e@LAIKA> MIME-Version: 1.0 Message-Id: <200304290838.50503.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-31.1 required=5.0 tests=BAYES_01,IN_REP_TO,NO_DNS_FOR_FROM,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/247 X-Sequence-Number: 1753 Robert, > The following options are defined in ADO with which I can create a > recordset with: > Do any of these offer a performance gain over others? I used to use > adLockReadOnly with MS-SQL which really sped things up but this doesn't > seem to work at all under Postgresql and I've been using > adLockOptimistic instead. All of the types you list were designed around the MS SQL/MSDE server=20 architecture, and many do not apply to PostgreSQL (for example, Postgres do= es=20 not use read locks and does not support client-side keyset cursors as far a= s=20 I know). I wouldn't be surprised to find out that the pgODBC driver is=20 ignoring most of these options as irrelevant -- you should contact the pgOD= BC=20 project to find out. Certainly I wouldn't expect any setting other than adLockPessimistic to hav= e=20 an effect on the speed at which you get rows from the server (Pessimistic= =20 would presumably declare "SELECT FOR UPDATE", which would be slower).=20=20= =20 However, one or more types might be faster on the client side than the=20 others; I recommmend that you set up a test case and experiment. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Tue Apr 29 11:44:03 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CA6FE475CBC for ; Tue, 29 Apr 2003 11:44:02 -0400 (EDT) Received: from mail.reviewer.co.uk (frodo.reviewer.co.uk [213.232.121.13]) by postgresql.org (Postfix) with SMTP id AFAB247633C for ; Tue, 29 Apr 2003 11:43:22 -0400 (EDT) Received: (qmail 27486 invoked from network); 29 Apr 2003 15:43:27 -0000 Received: from unknown (HELO LAIKA) (62.49.176.243) by mail.reviewer.co.uk with SMTP; 29 Apr 2003 15:43:27 -0000 From: "Robert John Shepherd" To: Subject: Re: Best ODBC cursor and lock types for fastest reading? Date: Tue, 29 Apr 2003 16:43:26 +0100 Message-ID: <001a01c30e66$138f0920$f3b0313e@LAIKA> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <200304290838.50503.josh@agliodbs.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal X-Spam-Status: No, hits=-8.2 required=5.0 tests=BAYES_20,IN_REP_TO,NO_DNS_FOR_FROM,QUOTED_EMAIL_TEXT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/248 X-Sequence-Number: 1754 > All of the types you list were designed around the MS SQL/MSDE server > architecture, and many do not apply to PostgreSQL (for > example, Postgres does not use read locks and does not support > client-side keyset cursors as far as I know). Thanks, this backs up my feelings from some of my limited experiments with them. I guess I need to keep trying to rewrite my queries to avoid nested loops then, as this seems to be the main performance hit I get as all use indexes properly. Yours Unwhettedly, Robert John Shepherd. Editor DVD REVIEWER The UK's BIGGEST Online DVD Magazine http://www.dvd.reviewer.co.uk For a copy of my Public PGP key, email: pgp@robertsworld.org.uk From pgsql-performance-owner@postgresql.org Tue Apr 29 11:49:43 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 84978476323 for ; Tue, 29 Apr 2003 11:49:40 -0400 (EDT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 9A3C5476333 for ; Tue, 29 Apr 2003 11:49:01 -0400 (EDT) Received: (qmail 27824 invoked from network); 29 Apr 2003 15:49:42 -0000 Received: from unknown (HELO www.trade-india.com) (unknown) by unknown with SMTP; 29 Apr 2003 15:49:42 -0000 Received: (qmail 25700 invoked by uid 99); 29 Apr 2003 15:48:57 -0000 Received: from 219.65.230.214 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Tue, 29 Apr 2003 21:18:57 +0530 (IST) Message-ID: <1057.219.65.230.214.1051631337.squirrel@mail.trade-india.com> Date: Tue, 29 Apr 2003 21:18:57 +0530 (IST) Subject: Re: Is 292 inserts/sec acceptable performance ? From: To: In-Reply-To: <26231.1051624859@sss.pgh.pa.us> References: <200304291231.09842.mallah@trade-india.com> <26231.1051624859@sss.pgh.pa.us> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-13.1 required=5.0 tests=BAYES_10,IN_REP_TO,MISSING_MIMEOLE,MISSING_OUTLOOK_NAME, NO_DNS_FOR_FROM,NO_REAL_NAME,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/249 X-Sequence-Number: 1755 it really takes that long :( i can post it 2morrow only when i am office . regds mallah > Rajesh Kumar Mallah writes: >> Hi Can anyone tell if the case below is an acceptable >> performance ? > > Not with that info. Could we see EXPLAIN ANALYZE results for both the fa= ster and slower cases? > > regards, tom lane ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-performance-owner@postgresql.org Tue Apr 29 11:57:36 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 65F5A4763E6 for ; Tue, 29 Apr 2003 11:57:28 -0400 (EDT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 4DE734763B1 for ; Tue, 29 Apr 2003 11:56:12 -0400 (EDT) Received: (qmail 28031 invoked from network); 29 Apr 2003 15:56:54 -0000 Received: from unknown (HELO www.trade-india.com) (unknown) by unknown with SMTP; 29 Apr 2003 15:56:54 -0000 Received: (qmail 26117 invoked by uid 99); 29 Apr 2003 15:56:08 -0000 Received: from 219.65.230.214 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Tue, 29 Apr 2003 21:26:08 +0530 (IST) Message-ID: <1066.219.65.230.214.1051631768.squirrel@mail.trade-india.com> Date: Tue, 29 Apr 2003 21:26:08 +0530 (IST) Subject: Re: profiling plpgsql functions.. From: To: In-Reply-To: <26413.1051626475@sss.pgh.pa.us> References: <200304291655.01035.mallah@trade-india.com> <26413.1051626475@sss.pgh.pa.us> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-23.6 required=5.0 tests=BAYES_01,IN_REP_TO,MISSING_MIMEOLE,MISSING_OUTLOOK_NAME, NO_DNS_FOR_FROM,NO_REAL_NAME,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/250 X-Sequence-Number: 1756 Yep timeofday returns text , but is there anything else that equivalant that can be differenced inside plpgsql so that i can print the not of secs/millisecs connsumed? hmm shud i cast timeofday to timestamp and use timestamp arithmatic ? regds mallah. > Rajesh Kumar Mallah writes: >> Is printing timeofday() at various points a good idea >> of profiling plpgsql functions? > > Sure. > >> also is anything wrong with following fragment ? >> RAISE INFO '' % , message here ... '' , timeofday() ; > > IIRC, RAISE is pretty slovenly implemented :-( ... it will only take plai= n variable references > as additional arguments. So you'll have to do > > var :=3D timeofday(); > RAISE INFO ''... '', var; > > I believe timeofday() produces TEXT, so declare the var that way. > > regards, tom lane ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/ From pgsql-performance-owner@postgresql.org Tue Apr 29 12:02:09 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B248047635D for ; Tue, 29 Apr 2003 12:02:07 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 76AB7476372 for ; Tue, 29 Apr 2003 12:01:30 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TG1ZU6001911; Tue, 29 Apr 2003 12:01:35 -0400 (EDT) To: mallah@trade-india.com Cc: pgsql-performance@postgresql.org Subject: Re: profiling plpgsql functions.. In-reply-to: <1066.219.65.230.214.1051631768.squirrel@mail.trade-india.com> References: <200304291655.01035.mallah@trade-india.com> <26413.1051626475@sss.pgh.pa.us> <1066.219.65.230.214.1051631768.squirrel@mail.trade-india.com> Comments: In-reply-to message dated "Tue, 29 Apr 2003 21:26:08 +0530" Date: Tue, 29 Apr 2003 12:01:35 -0400 Message-ID: <1910.1051632095@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-14.8 required=5.0 tests=BAYES_00,IN_REP_TO,NO_DNS_FOR_FROM,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/251 X-Sequence-Number: 1757 writes: > hmm shud i cast timeofday to timestamp and use timestamp > arithmatic ? Yeah. It's only historical accident that it doesn't return timestamp... (or better use timestamptz) regards, tom lane From pgsql-performance-owner@postgresql.org Tue Apr 29 12:04:35 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BCCE7475F1B for ; Tue, 29 Apr 2003 12:04:34 -0400 (EDT) Received: from mail.deltav.hu (mail.deltav.hu [213.163.0.192]) by postgresql.org (Postfix) with ESMTP id 73DD4475F34 for ; Tue, 29 Apr 2003 12:03:58 -0400 (EDT) Received: from fejleszt2 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA2255 for ; Tue, 29 Apr 2003 18:03:55 +0200 Message-ID: <011101c30e68$f056bdb0$0a03a8c0@fejleszt2> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: References: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> <26550.1051627993@sss.pgh.pa.us> Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 Date: Tue, 29 Apr 2003 18:03:48 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_010E_01C30E79.AEFC2E20" 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-Spam-Status: No, hits=-11.5 required=5.0 tests=BAYES_20,NO_DNS_FOR_FROM,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/252 X-Sequence-Number: 1758 This is a multi-part message in MIME format. ------=_NextPart_000_010E_01C30E79.AEFC2E20 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit Sure, thanks for your interest :) hope these help. G. -- while (!asleep()) sheep++; ---------------------------- cut here ------------------------------ ----- Original Message ----- From: "Tom Lane" Sent: Tuesday, April 29, 2003 4:53 PM > "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: > > A nasty query and its EXPLAINs are here. Read on at your own risk :) > > It's pretty much unreadable because of the way your mailer folded, > spindled, and mutilated the EXPLAIN output :-( > > Could you resend in a more legible format? Maybe append the explain > output as an attachment, if you can't get the mailer to leave its > formatting alone otherwise. ------=_NextPart_000_010E_01C30E79.AEFC2E20 Content-Type: application/octet-stream; name="szkb" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="szkb" SELECT *, kerekit_penznem (netto_ertek*(afa_szazalek/100), penznem)=20 AS afa_ertek, kerekit_penznem (netto_ertek*(1+afa_szazalek/100), penznem)=20 AS brutto_ertek FROM ( SELECT szamla,=20 kerekit_penznem( elsodl_netto_ertek*COALESCE(deka,1)/COALESCE(dekb,1), penznem)=20 AS netto_ertek, konyvelesi_tetelcsoport, afa, afa_szazalek, penznem FROM=20 (SELECT szt.szamla,=20 kerekit_penznem(sum(szt.netto_egysegar * szt.mennyiseg), penznem)=20 AS elsodl_netto_ertek, konyvelesi_tetelcsoport(szt.szamla, szt.tetelszam)=20 AS konyvelesi_tetelcsoport, szt.afa, afa.ertek AS afa_szazalek, szamla.penznem AS sz_penznem, szamla.teljesites AS sz_teljesites, arf_a.deviza_kozeparfolyam as deka, arf_b.deviza_kozeparfolyam as dekb, foo_valuta AS penznem FROM szamla_tetele szt=20 LEFT JOIN szamla ON (szamla =3D szamla.az)=20 LEFT JOIN afa ON (afa.az =3D szt.afa) LEFT JOIN arfolyam arf_a=20 ON (arf_a.ervenyes =3D=20 (SELECT ervenyes FROM arfolyam WHERE ervenyes<=3Dszamla.teljesites AND valuta =3D szamla.penznem ORDER BY 1 DESC LIMIT 1) AND szamla.penznem=3Darf_a.valuta) JOIN=09 (SELECT az AS foo_valuta FROM valuta) AS valuta ON (true) LEFT JOIN arfolyam arf_b=20 ON (arf_b.valuta=3Dfoo_valuta AND arf_b.ervenyes =3D=20 (SELECT ervenyes FROM arfolyam=20 WHERE ervenyes<=3Dszamla.teljesites AND valuta =3D foo_valuta ORDER BY 1 DESC LIMIT 1) ) WHERE (NOT szt.archiv) AND (foo_valuta =3D 4 or arf_b.valuta notnull ) GROUP BY szt.szamla, konyvelesi_tetelcsoport, szt.afa,=20 sz_penznem, sz_teljesites, afa.ertek,=20 arf_a.deviza_kozeparfolyam, arf_b.deviza_kozeparfolyam,=20 foo_valuta, penznem ) foo=20 ) bar WHERE szamla =3D 2380; ------------------------------------------------------------------------- ---------------------------- 7.2.1 PLAN --------------------------------- ------------------------------------------------------------------------- NOTICE: QUERY PLAN: Subquery Scan foo (cost=3D488.97..490.94 rows=3D8 width=3D104) (actual tim= e=3D94.77..109.10 rows=3D12 loops=3D1) -> Aggregate (cost=3D488.97..490.94 rows=3D8 width=3D104) (actual time=3D= 89.29..92.05 rows=3D12 loops=3D1) -> Group (cost=3D488.97..490.74 rows=3D79 width=3D104) (actual time= =3D88.13..88.59 rows=3D12 loops=3D1) -> Sort (cost=3D488.97..488.97 rows=3D79 width=3D104) (actual time=3D88.= 09..88.13 rows=3D12 loops=3D1) -> Nested Loop (cost=3D1.05..486.50 rows=3D79 width=3D104) (actual t= ime=3D28.23..86.20 rows=3D12 loops=3D1) -> Nested Loop (cost=3D1.05..150.19 rows=3D79 width=3D84) (actual time= =3D12.68..25.41 rows=3D12 loops=3D1) -> Nested Loop (cost=3D1.05..135.52 rows=3D13 width=3D80) (actual t= ime=3D12.60..24.80 rows=3D2 loops=3D1) -> Hash Join (cost=3D1.05..79.59 rows=3D13 width=3D60) (actual time=3D= 0.55..0.80 rows=3D2 loops=3D1) -> Nested Loop (cost=3D0.00..78.31 rows=3D13 width=3D46) (actual t= ime=3D0.23..0.42 rows=3D2 loops=3D1) -> Index Scan using szml_ttl_szml on szamla_tetele szt (cost=3D0.00..= 3.51 rows=3D13 width=3D34) (actual time=3D0.11..0.16 rows=3D2 loops=3D1) -> Index Scan using szamla_az_key on szamla (cost=3D0.00..5.70 rows= =3D1 width=3D12) (actual time=3D0.07..0.09 rows=3D1 loops=3D2) -> Hash (cost=3D1.04..1.04 rows=3D4 width=3D14) (actual time=3D0.1= 4..0.14 rows=3D0 loops=3D1) -> Seq Scan on afa (cost=3D0.00..1.04 rows=3D4 width=3D14) (actual ti= me=3D0.08..0.11 rows=3D4 loops=3D1) -> Index Scan using arfolyam_ervenyes on arfolyam arf_a (cost=3D0.00..= 3.63 rows=3D3 width=3D20) (actual time=3D0.01..0.01 rows=3D0 loops=3D2) SubPlan -> Limit (cost=3D0.00..0.17 rows=3D1 width=3D4) (actual time=3D11.= 92..11.92 rows=3D0 loops=3D2) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=3D0.= 00..13.30 rows=3D79 width=3D4) (actual time=3D11.90..11.90 rows=3D0 loops= =3D2) -> Limit (cost=3D0.00..0.17 rows=3D1 width=3D4) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=3D0.= 00..13.30 rows=3D79 width=3D4) -> Seq Scan on valuta (cost=3D0.00..1.06 rows=3D6 width=3D4) (actua= l time=3D0.02..0.11 rows=3D6 loops=3D2) -> Index Scan using arfolyam_ervenyes on arfolyam arf_b (cost=3D0.00..3= .63 rows=3D3 width=3D20) (actual time=3D0.04..0.10 rows=3D3 loops=3D12) SubPlan -> Limit (cost=3D0.00..0.17 rows=3D1 width=3D4) (actual time=3D4.35= ..4.39 rows=3D1 loops=3D12) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=3D0.0= 0..13.30 rows=3D79 width=3D4) (actual time=3D4.33..4.37 rows=3D2 loops=3D12) -> Limit (cost=3D0.00..0.17 rows=3D1 width=3D4) -> Index Scan Backward using arfolyam_ervenyes on arfolyam (cost=3D0.0= 0..13.30 rows=3D79 width=3D4) Total runtime: 111.48 msec ------------------------------------------------------------------------- ---------------------------- 7.3.2 PLAN --------------------------------- ------------------------------------------------------------------------- = QUERY PLAN=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=20=20=20=20=20=20=20=20=20 ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------------------- Subquery Scan foo (cost=3D14542.01..15448.46 rows=3D3022 width=3D123) (ac= tual time=3D2264.36..2282.17 rows=3D12 loops=3D1) -> Aggregate (cost=3D14542.01..15448.46 rows=3D3022 width=3D123) (actu= al time=3D2257.70..2261.08 rows=3D12 loops=3D1) -> Group (cost=3D14542.01..15372.92 rows=3D30215 width=3D123) (a= ctual time=3D2256.31..2256.84 rows=3D12 loops=3D1) -> Sort (cost=3D14542.01..14617.55 rows=3D30215 width=3D12= 3) (actual time=3D2256.27..2256.31 rows=3D12 loops=3D1) Sort Key: szt.szamla, konyvelesi_tetelcsoport(szt.szam= la, szt.tetelszam), szt.afa, szamla.penznem, szamla.teljesites, afa.ertek, = arf_a.deviza_kozeparfolyam, arf_b.deviza_kozeparfolyam, public.valuta.az -> Merge Join (cost=3D4755.50..11038.79 rows=3D30215= width=3D123) (actual time=3D80.88..2254.96 rows=3D12 loops=3D1) Merge Cond: ("outer".az =3D "inner".valuta) Join Filter: ("inner".ervenyes =3D (subplan)) Filter: (("outer".az =3D 4) OR ("inner".valuta I= S NOT NULL)) -> Sort (cost=3D4676.19..4751.73 rows=3D30215 = width=3D103) (actual time=3D56.41..56.44 rows=3D12 loops=3D1) Sort Key: public.valuta.az -> Nested Loop (cost=3D433.35..1375.92 r= ows=3D30215 width=3D103) (actual time=3D55.78..56.18 rows=3D12 loops=3D1) -> Merge Join (cost=3D433.35..469.= 47 rows=3D30 width=3D99) (actual time=3D55.68..55.72 rows=3D2 loops=3D1) Merge Cond: ("outer".penznem = =3D "inner".valuta) Join Filter: ("inner".ervenyes= =3D (subplan)) -> Sort (cost=3D354.05..354.= 12 rows=3D30 width=3D79) (actual time=3D32.63..32.64 rows=3D2 loops=3D1) Sort Key: szamla.penznem -> Hash Join (cost=3D1= 21.67..353.30 rows=3D30 width=3D79) (actual time=3D32.37..32.49 rows=3D2 lo= ops=3D1) Hash Cond: ("outer= ".afa =3D "inner".az) -> Merge Join (c= ost=3D120.62..352.09 rows=3D30 width=3D58) (actual time=3D32.07..32.16 rows= =3D2 loops=3D1) Merge Cond: = ("outer".az =3D "inner".szamla) -> Sort (c= ost=3D120.62..123.85 rows=3D1291 width=3D12) (actual time=3D25.62..27.62 ro= ws=3D1285 loops=3D1) Sort K= ey: szamla.az -> Se= q Scan on szamla (cost=3D0.00..53.91 rows=3D1291 width=3D12) (actual time= =3D0.04..16.46 rows=3D1314 loops=3D1) -> Index Sc= an using szamla_tetele_pkey on szamla_tetele szt (cost=3D0.00..218.88 rows= =3D30 width=3D46) (actual time=3D0.13..0.18 rows=3D2 loops=3D1) Index = Cond: (szamla =3D 2380) Filter= : (NOT archiv) -> Hash (cost=3D= 1.04..1.04 rows=3D4 width=3D21) (actual time=3D0.10..0.10 rows=3D0 loops=3D= 1) -> Seq Scan= on afa (cost=3D0.00..1.04 rows=3D4 width=3D21) (actual time=3D0.04..0.07 = rows=3D4 loops=3D1) -> Sort (cost=3D79.30..82.19= rows=3D1155 width=3D20) (actual time=3D22.93..22.93 rows=3D1 loops=3D1) Sort Key: arf_a.valuta -> Seq Scan on arfolyam= arf_a (cost=3D0.00..20.55 rows=3D1155 width=3D20) (actual time=3D0.03..9.= 66 rows=3D1155 loops=3D1) SubPlan -> Limit (cost=3D0.00..0.1= 6 rows=3D1 width=3D4) (never executed) -> Index Scan Backwar= d using arfolyam_ervenyes on arfolyam (cost=3D0.00..12.17 rows=3D77 width= =3D4) (never executed) Index Cond: (erv= enyes <=3D $0) Filter: (valuta = =3D $1) -> Seq Scan on valuta (cost=3D0.00= ..20.00 rows=3D1000 width=3D4) (actual time=3D0.02..0.06 rows=3D6 loops=3D2) -> Sort (cost=3D79.30..82.19 rows=3D1155 width= =3D20) (actual time=3D21.98..27.54 rows=3D2309 loops=3D1) Sort Key: arf_b.valuta -> Seq Scan on arfolyam arf_b (cost=3D0.= 00..20.55 rows=3D1155 width=3D20) (actual time=3D0.03..9.89 rows=3D1155 loo= ps=3D1) SubPlan -> Limit (cost=3D0.00..0.16 rows=3D1 width= =3D4) (actual time=3D0.88..0.91 rows=3D1 loops=3D2310) -> Index Scan Backward using arfolyam_e= rvenyes on arfolyam (cost=3D0.00..12.17 rows=3D77 width=3D4) (actual time= =3D0.87..0.90 rows=3D2 loops=3D2310) Index Cond: (ervenyes <=3D $0) Filter: (valuta =3D $2) Total runtime: 2287.30 msec (47 rows) ------=_NextPart_000_010E_01C30E79.AEFC2E20-- From pgsql-performance-owner@postgresql.org Tue Apr 29 19:05:54 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C2D7475F2C for ; Tue, 29 Apr 2003 19:05:53 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id F135B475CBC for ; Tue, 29 Apr 2003 19:05:52 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3TN5rU6018325; Tue, 29 Apr 2003 19:05:53 -0400 (EDT) To: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" Cc: pgsql-performance@postgresql.org Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 In-reply-to: <011101c30e68$f056bdb0$0a03a8c0@fejleszt2> References: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> <26550.1051627993@sss.pgh.pa.us> <011101c30e68$f056bdb0$0a03a8c0@fejleszt2> Comments: In-reply-to "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" message dated "Tue, 29 Apr 2003 18:03:48 +0200" Date: Tue, 29 Apr 2003 19:05:53 -0400 Message-ID: <18324.1051657553@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-16.3 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/253 X-Sequence-Number: 1759 "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: > ---------------------------- 7.2.1 PLAN --------------------------------- > -> Seq Scan on valuta (cost=0.00..1.06 rows=6 width=4) (actual time=0.02..0.11 rows=6 loops=2) > > ---------------------------- 7.3.2 PLAN --------------------------------- > -> Seq Scan on valuta (cost=0.00..20.00 rows=1000 width=4) (actual time=0.02..0.06 rows=6 loops=2) Ah, there's the problem. You never vacuumed or analyzed "valuta", so the 7.3 planner didn't know it had only six rows, and chose a plan that was more appropriate for a larger table. The thousand-row estimate is the tipoff, because that's the default assumption when there are no stats. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 30 02:04:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EC7A8476300 for ; Wed, 30 Apr 2003 02:04:25 -0400 (EDT) Received: from flake.decibel.org (flake.decibel.org [66.93.216.19]) by postgresql.org (Postfix) with SMTP id 18C12475458 for ; Wed, 30 Apr 2003 02:04:25 -0400 (EDT) Received: (qmail 86612 invoked by uid 1001); 30 Apr 2003 06:04:25 -0000 Date: Wed, 30 Apr 2003 01:04:25 -0500 From: "Jim C. Nasby" To: pgsql-performance@postgresql.org Subject: Why LIMIT after scanning the table? Message-ID: <20030430010425.T66185@flake.decibel.org> Reply-To: jim@nasby.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Operating-System: FreeBSD 4.8-RELEASE i386 X-Distributed: Join the Effort! http://www.distributed.net X-Spam-Status: No, hits=-13.5 required=5.0 tests=BAYES_01,SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/254 X-Sequence-Number: 1760 I'm doing something where I just need to know if we have more than 100 rows in a table. Not wanting to scan the whole table, I thought I'd get cute... explain select count(*) FROM (SELECT * FROM email_rank WHERE project_id = :ProjectID LIMIT 100) AS t1; QUERY PLAN ------------------------------------------------------------------------------------- Aggregate (cost=111.32..111.32 rows=1 width=48) -> Subquery Scan t1 (cost=0.00..111.07 rows=100 width=48) -> Limit (cost=0.00..111.07 rows=100 width=48) -> Seq Scan on email_rank (cost=0.00..76017.40 rows=68439 width=48) Filter: (project_id = 24) The idea is that the inner-most query would only read the first 100 rows it finds, then stop. Instead, if explain is to be believed (and speed testing seems to indicate it's accurate), we'll read the entire table, *then* pick the first 100 rows. Why is that? FYI... Table "public.email_rank" Column | Type | Modifiers -----------------------+---------+-------------------- project_id | integer | not null id | integer | not null first_date | date | not null last_date | date | not null day_rank | integer | not null default 0 day_rank_previous | integer | not null default 0 overall_rank | integer | not null default 0 overall_rank_previous | integer | not null default 0 work_today | bigint | not null default 0 work_total | bigint | not null default 0 Indexes: email_rank_pkey primary key btree (project_id, id), email_rank__day_rank btree (project_id, day_rank), email_rank__overall_rank btree (project_id, overall_rank) -- Jim C. Nasby (aka Decibel!) jim@nasby.net Member: Triangle Fraternity, Sports Car Club of America Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" From pgsql-performance-owner@postgresql.org Wed Apr 30 03:38:44 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 20CF6475458 for ; Wed, 30 Apr 2003 03:38:42 -0400 (EDT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id BF899474E42 for ; Wed, 30 Apr 2003 03:38:32 -0400 (EDT) Received: (qmail 23007 invoked from network); 30 Apr 2003 07:39:16 -0000 Received: from unknown (HELO system67.trade-india-local.com) (unknown) by unknown with SMTP; 30 Apr 2003 07:39:16 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: Tom Lane Subject: Re: Is 292 inserts/sec acceptable performance ? Date: Wed, 30 Apr 2003 13:09:53 +0530 User-Agent: KMail/1.5 Cc: pgsql-performance@postgresql.org References: <200304291231.09842.mallah@trade-india.com> <26231.1051624859@sss.pgh.pa.us> In-Reply-To: <26231.1051624859@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200304301309.53150.mallah@trade-india.com> X-Spam-Status: No, hits=-33.1 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SIGNATURE_SHORT_SPARSE, USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/255 X-Sequence-Number: 1761 Ooops Sorry , Actually the query finished in approx 4 mins not 23 mins. That performance must have been under some crazy circumstances. So the insert Rate now is 1608 inserts/sec not 292 as stated earlier. Here is the EXPLAIN ANALYZE anyway tradein_clients=# begin work;EXPLAIN analyze INSERT INTO general.profile_master (email,country_code,city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexporter,ifservice,ifmanu,creation_date) SELECT email,country_code,city,title1,fname1,mname1,lname1,website,address,source,ifimporter,ifexporter,ifservice,ifmanu,creation_date from general.email_bank_import where not exists (select * from general.profile_master where email=general.email_bank_import.email) ; rollback; BEGIN Time: 993.07 ms +---------------------------------------------------------------------------------------------------------------------------------------------------------+ | QUERY PLAN | +---------------------------------------------------------------------------------------------------------------------------------------------------------+ | Hash Join (cost=8.07..2395887.30 rows=279296 width=129) (actual time=2.56..151083.30 rows=394646 loops=1) | | Hash Cond: ("outer".country = "inner".name) | | -> Seq Scan on email_bank a (cost=0.00..2390293.31 rows=279296 width=109) (actual time=0.36..41475.08 rows=394646 loops=1) | | Filter: (NOT (subplan)) | | SubPlan | | -> Index Scan using profile_master_email on profile_master (cost=0.00..31.66 rows=7 width=678) (actual time=0.05..0.05 rows=0 loops=558731) | | Index Cond: (email = $0) | | -> Hash (cost=7.46..7.46 rows=246 width=20) (actual time=1.11..1.11 rows=0 loops=1) | | -> Seq Scan on countries b (cost=0.00..7.46 rows=246 width=20) (actual time=0.06..0.73 rows=246 loops=1) | | Total runtime: 196874.70 msec | +---------------------------------------------------------------------------------------------------------------------------------------------------------+ (10 rows) Time: 198905.62 ms ROLLBACK Time: 1481.41 ms Regds mallah. On Tuesday 29 Apr 2003 7:30 pm, Tom Lane wrote: > Rajesh Kumar Mallah writes: > > Hi Can anyone tell if the case below is an acceptable > > performance ? > > Not with that info. Could we see EXPLAIN ANALYZE results for both > the faster and slower cases? > > regards, tom lane > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace. From pgsql-performance-owner@postgresql.org Wed Apr 30 07:00:49 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 68B18475458 for ; Wed, 30 Apr 2003 07:00:48 -0400 (EDT) Received: from mail.deltav.hu (mail.deltav.hu [213.163.0.192]) by postgresql.org (Postfix) with ESMTP id DC674474E42 for ; Wed, 30 Apr 2003 07:00:46 -0400 (EDT) Received: from fejleszt2 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA30CB for ; Wed, 30 Apr 2003 13:00:46 +0200 Message-ID: <004401c30f07$c07f45e0$0a03a8c0@fejleszt2> From: "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" To: References: <00db01c30e54$1ab272d0$0a03a8c0@fejleszt2> <26550.1051627993@sss.pgh.pa.us> <011101c30e68$f056bdb0$0a03a8c0@fejleszt2> <18324.1051657553@sss.pgh.pa.us> Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 Date: Wed, 30 Apr 2003 13:00:40 +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-Spam-Status: No, hits=-19.1 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/256 X-Sequence-Number: 1762 ----- Original Message ----- From: "Tom Lane" Sent: Wednesday, April 30, 2003 1:05 AM > "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" writes: > > ---------------------------- 7.2.1 PLAN --------------------------------- > > -> Seq Scan on valuta (cost=0.00..1.06 rows=6 width=4) (actual time=0.02..0.11 rows=6 loops=2) > > > > ---------------------------- 7.3.2 PLAN --------------------------------- > > -> Seq Scan on valuta (cost=0.00..20.00 rows=1000 width=4) (actual time=0.02..0.06 rows=6 loops=2) > > Ah, there's the problem. You never vacuumed or analyzed "valuta", so > the 7.3 planner didn't know it had only six rows, and chose a plan that > was more appropriate for a larger table. The thousand-row estimate is > the tipoff, because that's the default assumption when there are no > stats. > > regards, tom lane Thanks! VACUUM ANALYZE really worked and I learned something new. The strange part is, that I think I issued a "VACUUM ANALYZE;" (that should do all the tables, right?) a couple of weeks before because of another problem (it didn't help that time, tho) G. -- while (!asleep()) sheep++; ---------------------------- cut here ------------------------------ From pgsql-performance-owner@postgresql.org Wed Apr 30 10:17:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D1DC54758E6 for ; Wed, 30 Apr 2003 10:17:23 -0400 (EDT) Received: from email04.aon.at (WARSL401PIP5.highway.telekom.at [195.3.96.90]) by postgresql.org (Postfix) with SMTP id D1204475458 for ; Wed, 30 Apr 2003 10:17:21 -0400 (EDT) Received: (qmail 411140 invoked from network); 30 Apr 2003 14:15:16 -0000 Received: from m154p015.dipool.highway.telekom.at (HELO cantor) ([62.46.9.47]) (envelope-sender ) by qmail4rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 30 Apr 2003 14:15:16 -0000 From: Manfred Koizar To: jim@nasby.net Cc: Tom Lane , pgsql-performance@postgresql.org Subject: Re: More tablescanning fun Date: Wed, 30 Apr 2003 16:14:46 +0200 Message-ID: References: <20030424183817.A66185@flake.decibel.org> <3660.1051228710@sss.pgh.pa.us> <20030424235924.B66185@flake.decibel.org> <13549.1051248190@sss.pgh.pa.us> <20030425093800.C66185@flake.decibel.org> In-Reply-To: <20030425093800.C66185@flake.decibel.org> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-32.2 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_FORTE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/257 X-Sequence-Number: 1763 On Fri, 25 Apr 2003 09:38:01 -0500, "Jim C. Nasby" wrote: >In this case, the interpolation can't be at fault, because correlation >is 1 (unless the interpolation is backwards, but that doesn't appear to >be the case). But your index has 3 columns which causes the index correlation to be assumed as 1/3. So the interpolation uses 1/9 (correlation squared) and you get a cost estimation that almost equals the upper bound. If you want to play around with other interpolation methods, you might want to get this patch: http://www.pivot.at/pg/16-correlation-732.diff A short description of the GUC parameters introduced by this patch can be found here: http://archives.postgresql.org/pgsql-performance/2002-11/msg00256.php As a short term workaround for an unmodified Postgres installation, you can create an index on email_contrib(project_id). Servus Manfred From pgsql-performance-owner@postgresql.org Wed Apr 30 10:19:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0EA8475B85 for ; Wed, 30 Apr 2003 10:19:39 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 99F5E475A45 for ; Wed, 30 Apr 2003 10:19:37 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id D8B9ED61D; Wed, 30 Apr 2003 07:19:41 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id CE6955C0A; Wed, 30 Apr 2003 07:19:41 -0700 (PDT) Date: Wed, 30 Apr 2003 07:19:41 -0700 (PDT) From: Stephan Szabo To: "Jim C. Nasby" Cc: Subject: Re: Why LIMIT after scanning the table? In-Reply-To: <20030430010425.T66185@flake.decibel.org> Message-ID: <20030430071605.X81999-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/258 X-Sequence-Number: 1764 On Wed, 30 Apr 2003, Jim C. Nasby wrote: > I'm doing something where I just need to know if we have more than 100 > rows in a table. Not wanting to scan the whole table, I thought I'd get > cute... > > explain select count(*) > FROM (SELECT * FROM email_rank WHERE project_id = :ProjectID LIMIT 100) AS t1; > QUERY PLAN > ------------------------------------------------------------------------------------- > Aggregate (cost=111.32..111.32 rows=1 width=48) > -> Subquery Scan t1 (cost=0.00..111.07 rows=100 width=48) > -> Limit (cost=0.00..111.07 rows=100 width=48) > -> Seq Scan on email_rank (cost=0.00..76017.40 rows=68439 width=48) > Filter: (project_id = 24) > > The idea is that the inner-most query would only read the first 100 rows > it finds, then stop. Instead, if explain is to be believed (and speed > testing seems to indicate it's accurate), we'll read the entire table, > *then* pick the first 100 rows. Why is that? I'd suggest looking at explain analyze rather than explain. In most cases I've seen what it'll actually grab is limit+1 rows (I think cvs will only grab limit) in the actual rows. It shows you the full count for the sequence scan in explain, but notice that the limit cost is lower than that of the sequence scan. From pgsql-performance-owner@postgresql.org Wed Apr 30 10:22:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C265147633A for ; Wed, 30 Apr 2003 10:22:23 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id AD81E4762FB for ; Wed, 30 Apr 2003 10:22:22 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3UEMPU6021976; Wed, 30 Apr 2003 10:22:25 -0400 (EDT) To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: Why LIMIT after scanning the table? In-reply-to: <20030430010425.T66185@flake.decibel.org> References: <20030430010425.T66185@flake.decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Wed, 30 Apr 2003 01:04:25 -0500" Date: Wed, 30 Apr 2003 10:22:25 -0400 Message-ID: <21975.1051712545@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/259 X-Sequence-Number: 1765 "Jim C. Nasby" writes: > explain select count(*) > FROM (SELECT * FROM email_rank WHERE project_id = :ProjectID LIMIT 100) AS t1; > The idea is that the inner-most query would only read the first 100 rows > it finds, then stop. Instead, if explain is to be believed (and speed > testing seems to indicate it's accurate), we'll read the entire table, > *then* pick the first 100 rows. Why is that? You're misreading the EXPLAIN output. Try EXPLAIN ANALYZE to see how many rows really get fetched. regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 30 10:40:08 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C48E54758E6 for ; Wed, 30 Apr 2003 10:40:06 -0400 (EDT) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by postgresql.org (Postfix) with ESMTP id 6687C475458 for ; Wed, 30 Apr 2003 10:40:05 -0400 (EDT) Received: (qmail 20616 invoked from network); 30 Apr 2003 14:39:28 -0000 Received: from unknown (HELO pdarley) (kinesis@[216.254.16.50]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 30 Apr 2003 14:39:28 -0000 From: "Peter Darley" To: Subject: Query Plan far worse in 7.3.2 than 7.2.1 Date: Wed, 30 Apr 2003 07:39:24 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000F_01C30EEB.9F203F60" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal In-Reply-To: <18324.1051657553@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-14.7 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/260 X-Sequence-Number: 1766 This is a multi-part message in MIME format. ------=_NextPart_000_000F_01C30EEB.9F203F60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Friends, I've got a query that has stopped using an index scan between 7.2.1 or RH 7.1 and 7.3.2 or RH 8.0, and I can't figure out why. I've come up with a replacement query which is a whole lot faster, but again, I can't tell why. The original query (condensed to remove the uninteresting bits) is: SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SELECT Foreign_Key FROM Sample WHERE Foreign_Key='Quantum_' || Border_Shop_List.Assignment_ID || '_' || Assignment_Year || '_' || Evaluation_ID) This runs in 667055.79 msec The new one is: SELECT COUNT(*) FROM Border_Shop_List WHERE 'Quantum_' || Border_Shop_List.Assignment_ID || '_' || Border_Shop_List.Assignment_Year || '_' || Border_Shop_List.Evaluation_ID NOT IN (SELECT Foreign_Key FROM Sample WHERE Foreign_Key IS NOT NULL) This runs in 16500.83 msec (~1/40th the time) Again, my immediate problem is solved, but I'm trying to understand why there is such a speed difference. I've attached explains for the two querys in both versions. The schemas for the two databases are identical. If there's more info people need, just let me know. Thanks, Peter Darley ------=_NextPart_000_000F_01C30EEB.9F203F60 Content-Type: text/plain; name="NewQuery.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="NewQuery.txt" SELECT COUNT(*) FROM Border_Shop_List WHERE 'Quantum_' || Border_Shop_List= .Assignment_ID || '_' || Border_Shop_List.Assignment_Year || '_' || Border_= Shop_List.Evaluation_ID NOT IN (SELECT Foreign_Key FROM Sample WHERE Forei= gn_Key IS NOT NULL) 7.3.2 neo=3D# explain analyze SELECT COUNT(*) FROM Border_Shop_List WHERE 'Quant= um_' || Border_Shop_List.Assignment_ID || '_' || Border_Shop_List.Assignmen= t_Year || '_' || Border_Shop_List.Evaluation_ID NOT IN (SELECT Foreign_Key= FROM Sample WHERE Foreign_Key IS NOT NULL); QUERY PLAN ---------------------------------------------------------------------------= --------------------------------------------------- Aggregate (cost=3D2460448.75..2460448.75 rows=3D1 width=3D0) (actual time= =3D16500.14..16500.14 rows=3D1 loops=3D1) -> Seq Scan on border_shop_list (cost=3D0.00..2460447.50 rows=3D500 wi= dth=3D0) (actual time=3D3245.59..16500.11 rows=3D3 loops=3D1) Filter: (subplan) SubPlan -> Materialize (cost=3D2460.41..2460.41 rows=3D2741 width=3D34= ) (actual time=3D0.02..0.45 rows=3D1533 loops=3D3065) -> Seq Scan on sample (cost=3D0.00..2460.41 rows=3D2741 = width=3D34) (actual time=3D41.89..50.75 rows=3D3062 loops=3D1) Filter: (foreign_key IS NOT NULL) Total runtime: 16500.83 msec (8 rows) 7.2.1 neo=3D# explain SELECT COUNT(*) FROM Border_Shop_List WHERE 'Quantum_' || = Border_Shop_List.Assignment_ID || ' _' || Border_Shop_List.Assignment_Year || '_' || Border_Shop_List.Evaluatio= n_ID NOT IN (SELECT Foreign_Key FROM Sample WHERE Foreign_Key IS NOT NULL); NOTICE: QUERY PLAN: Aggregate (cost=3D11323743.75..11323743.75 rows=3D1 width=3D0) -> Seq Scan on border_shop_list (cost=3D0.00..11323742.50 rows=3D500 wi= dth=3D0) SubPlan -> Seq Scan on sample (cost=3D0.00..22647.41 rows=3D33457 width= =3D34) EXPLAIN ------=_NextPart_000_000F_01C30EEB.9F203F60 Content-Type: text/plain; name="OldQuery.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="OldQuery.txt" SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SELECT Foreign_Key= FROM Sample WHERE Foreign_Key=3D'Quantum_' || Border_Shop_List.Assignment_= ID || '_' || Assignment_Year || '_' || Evaluation_ID) 7.3.2 neo=3D# explain analyze SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EX= ISTS (SELECT Foreign_Key FROM Sample WHERE Foreign_Key=3D'Quantum_' || Bord= er_Shop_List.Assignment_ID || '_' || Assignment_Year || '_' || Evaluation_I= D); QUERY PL= AN ---------------------------------------------------------------------------= --------------------------------------------------------------------- Aggregate (cost=3D3959148.75..3959148.75 rows=3D1 width=3D0) (actual time= =3D667055.64..667055.64 rows=3D1 loops=3D1) -> Seq Scan on border_shop_list (cost=3D0.00..3959147.50 rows=3D500 wi= dth=3D0) (actual time=3D110283.60..667055.60 rows=3D3 loops=3D1) Filter: (NOT (subplan)) SubPlan -> Seq Scan on sample (cost=3D0.00..3959.13 rows=3D1 width=3D3= 4) (actual time=3D217.62..217.62 rows=3D1 loops=3D3065) Filter: ((foreign_key)::text =3D ((((('Quantum_'::text || = ($0)::text) || '_'::text) || ($1)::text) || '_'::text) || ($2)::text)) Total runtime: 667055.79 msec (7 rows) 7.2.1 neo=3D# explain SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SE= LECT Foreign_Key FROM Sample WHERE Foreign_Key=3D'Quantum_' || Border_Shop_= List.Assignment_ID || '_' || Assignment_Year || '_' || Evaluation_ID); NOTICE: QUERY PLAN: Aggregate (cost=3D5992.94..5992.94 rows=3D1 width=3D0) -> Seq Scan on border_shop_list (cost=3D0.00..5991.69 rows=3D500 width= =3D0) SubPlan -> Index Scan using sample_foreign_key on sample (cost=3D0.00..= 5.97 rows=3D1 width=3D34) EXPLAIN ------=_NextPart_000_000F_01C30EEB.9F203F60-- From pgsql-performance-owner@postgresql.org Wed Apr 30 10:54:56 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id AFCA74758E6 for ; Wed, 30 Apr 2003 10:54:55 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 8AB9C475458 for ; Wed, 30 Apr 2003 10:54:24 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3UEsRU6022180; Wed, 30 Apr 2003 10:54:28 -0400 (EDT) To: "Peter Darley" Cc: pgsql-performance@postgresql.org Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 In-reply-to: References: Comments: In-reply-to "Peter Darley" message dated "Wed, 30 Apr 2003 07:39:24 -0700" Date: Wed, 30 Apr 2003 10:54:27 -0400 Message-ID: <22179.1051714467@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/261 X-Sequence-Number: 1767 "Peter Darley" writes: > SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SELECT Foreign_Key= > FROM Sample WHERE Foreign_Key=3D'Quantum_' || Border_Shop_List.Assignment_= > ID || '_' || Assignment_Year || '_' || Evaluation_ID) What's the datatype of Foreign_Key? I'm betting that it's varchar(n) or char(n). The result of the || expression is text, and so the comparison can't use a varchar index unless you explicitly cast it to varchar: WHERE Foreign_Key = ('Quantum_' || ... || Evaluation_ID)::varchar I think 7.2 had some kluge in it that would allow a varchar index to be used anyway, but we took out the kluge because it was semantically wrong (it would also allow use of a char(n) index in place of a text comparison, which alters the semantics...) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 30 11:14:26 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CDD35475458 for ; Wed, 30 Apr 2003 11:14:23 -0400 (EDT) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by postgresql.org (Postfix) with ESMTP id 7F876475458 for ; Wed, 30 Apr 2003 11:13:52 -0400 (EDT) Received: (qmail 22362 invoked from network); 30 Apr 2003 15:09:16 -0000 Received: from unknown (HELO pdarley) (kinesis@[216.254.16.50]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 30 Apr 2003 15:09:16 -0000 From: "Peter Darley" To: "Tom Lane" Cc: Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 Date: Wed, 30 Apr 2003 08:09:12 -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.2416 (9.0.2910.0) Importance: Normal In-Reply-To: <22179.1051714467@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-37.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,MSGID_GOOD_EXCHANGE, ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/262 X-Sequence-Number: 1768 Tom, You hit the nail on the head, foreign_key is a varchar(250). I'll re-write the queries with explicit casts. I'm hesitant to say anything, because I'm really not in a position to contribute, but... It seems like there are getting to be lots of typing issues (this one, 2 isn't an int8, etc.) I think that people have said that things are like this to support user defined data types. I would happily get rid of user defined data types if it would help with the type conversion issues. Just my 2c, for what it's worth. Thanks, Peter Darley -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Wednesday, April 30, 2003 7:54 AM To: Peter Darley Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query Plan far worse in 7.3.2 than 7.2.1 "Peter Darley" writes: > SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SELECT Foreign_Key= > FROM Sample WHERE Foreign_Key=3D'Quantum_' || Border_Shop_List.Assignment_= > ID || '_' || Assignment_Year || '_' || Evaluation_ID) What's the datatype of Foreign_Key? I'm betting that it's varchar(n) or char(n). The result of the || expression is text, and so the comparison can't use a varchar index unless you explicitly cast it to varchar: WHERE Foreign_Key = ('Quantum_' || ... || Evaluation_ID)::varchar I think 7.2 had some kluge in it that would allow a varchar index to be used anyway, but we took out the kluge because it was semantically wrong (it would also allow use of a char(n) index in place of a text comparison, which alters the semantics...) regards, tom lane From pgsql-performance-owner@postgresql.org Wed Apr 30 12:03:51 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 67A7B475A45; Wed, 30 Apr 2003 12:03:49 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id F00654758E6; Wed, 30 Apr 2003 12:03:47 -0400 (EDT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2998610; Wed, 30 Apr 2003 09:03:52 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Achilleus Mantzios , pgsql-sql@postgresql.org Subject: Re: [SQL] 7.3 analyze & vacuum analyze problem Date: Wed, 30 Apr 2003 09:03:38 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Message-Id: <200304300902.37985.josh@agliodbs.com> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-21.9 required=5.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/263 X-Sequence-Number: 1769 Achilleus, > i think i have an issue regarding the statistics that > a) (plain) ANALYZE status and > b) VACUUM ANALYZE status > produce. It's perfectly normal for a query to run faster after a VACUUM ANALYZE than= =20 after an ANALYZE ... after all, you just vacuumed it, didn't you? If you're demonstrating some other kind of behavioural difference, then ple= ase=20 post the results of EXPLAIN ANALYZE for the two examples. Oh, and we should probably shift this discussion to the PGSQL-PERFORMANCE= =20 list. --=20 Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 30 12:22:14 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CF8BE4758E6 for ; Wed, 30 Apr 2003 12:22:13 -0400 (EDT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id EDEAB4758E6 for ; Wed, 30 Apr 2003 12:22:11 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id MAA11666; Wed, 30 Apr 2003 12:22:12 -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 xma011664; Wed, 30 Apr 03 12:22:05 -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 MAA08705; Wed, 30 Apr 2003 12:15:58 -0400 Message-ID: <3EAFF86F.910A76EF@nsd.ca> Date: Wed, 30 Apr 2003 12:23:11 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: jim@nasby.net Cc: pgsql-performance@postgresql.org Subject: Re: Why LIMIT after scanning the table? References: <20030430010425.T66185@flake.decibel.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-30.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/265 X-Sequence-Number: 1771 If you only what to know if there is more than 100 rows, why not do: if exists ( SELECT 1 FROM email_rank WHERE project_id = :ProjectID OFFSET 100 LIMIT 1 ) "Jim C. Nasby" wrote: > > I'm doing something where I just need to know if we have more than 100 > rows in a table. Not wanting to scan the whole table, I thought I'd get > cute... > > explain select count(*) > FROM () AS t1; > QUERY PLAN > ------------------------------------------------------------------------------------- > Aggregate (cost=111.32..111.32 rows=1 width=48) > -> Subquery Scan t1 (cost=0.00..111.07 rows=100 width=48) > -> Limit (cost=0.00..111.07 rows=100 width=48) > -> Seq Scan on email_rank (cost=0.00..76017.40 rows=68439 width=48) > Filter: (project_id = 24) > > The idea is that the inner-most query would only read the first 100 rows > it finds, then stop. Instead, if explain is to be believed (and speed > testing seems to indicate it's accurate), we'll read the entire table, > *then* pick the first 100 rows. Why is that? > > FYI... > > Table "public.email_rank" > Column | Type | Modifiers > -----------------------+---------+-------------------- > project_id | integer | not null > id | integer | not null > first_date | date | not null > last_date | date | not null > day_rank | integer | not null default 0 > day_rank_previous | integer | not null default 0 > overall_rank | integer | not null default 0 > overall_rank_previous | integer | not null default 0 > work_today | bigint | not null default 0 > work_total | bigint | not null default 0 > Indexes: email_rank_pkey primary key btree (project_id, id), > email_rank__day_rank btree (project_id, day_rank), > email_rank__overall_rank btree (project_id, overall_rank) > > -- > Jim C. Nasby (aka Decibel!) jim@nasby.net > Member: Triangle Fraternity, Sports Car Club of America > Give your computer some brain candy! www.distributed.net Team #1828 > > Windows: "Where do you want to go today?" > Linux: "Where do you want to go tomorrow?" > FreeBSD: "Are you guys coming, or what?" > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From pgsql-performance-owner@postgresql.org Wed Apr 30 12:34:41 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BA0D64762D7; Wed, 30 Apr 2003 12:34:40 -0400 (EDT) Received: from MM01SNLNTO.son.sandia.gov (mm01snlnto.sandia.gov [132.175.109.20]) by postgresql.org (Postfix) with ESMTP id CBC00476182; Wed, 30 Apr 2003 12:34:39 -0400 (EDT) Received: from 132.175.109.4 by MM01SNLNTO.son.sandia.gov with ESMTP ( Tumbleweed MMS SMTP Relay 01 (MMS v5.5.0)); Wed, 30 Apr 2003 10:34:41 -0600 Received: from es08snlnt.sandia.gov (smtp-in.sandia.gov [134.253.130.11] ) by mailgate2.sandia.gov (8.12.9/8.12.9) with ESMTP id h3UGYdbo013122; Wed, 30 Apr 2003 10:34:39 -0600 (MDT) Received: by es08snlnt.sandia.gov with Internet Mail Service ( 5.5.2653.19) id <2AA2RKQC>; Wed, 30 Apr 2003 10:34:40 -0600 Message-ID: From: "Diehl, Jeffrey" To: pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Like search performance. Date: Wed, 30 Apr 2003 10:34:40 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) X-WSS-ID: 12B124AB212096-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-5.8 required=5.0 tests=BAYES_10 version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/266 X-Sequence-Number: 1772 Hi all, I have a fairly large table with a char(20) field in it which I search on quite a bit. The problem is that I tend to do a lot of "...where field like '%-d%'" type searches on this field. Is there any to speed up this type of search? TIA, Mike Diehl. From pgsql-performance-owner@postgresql.org Wed Apr 30 13:26:37 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4FA05475B85 for ; Wed, 30 Apr 2003 13:26:36 -0400 (EDT) Received: from mail.deltav.hu (mail.deltav.hu [213.163.0.192]) by postgresql.org (Postfix) with ESMTP id 37B68475C15 for ; Wed, 30 Apr 2003 13:26:35 -0400 (EDT) Received: from fejleszt2 ([213.163.10.103]) by mail.deltav.hu (Netscape Messaging Server 3.6) with SMTP id AAA5BD3 for ; Wed, 30 Apr 2003 18:59:53 +0200 Message-ID: <02d601c30f39$eb1bb540$0a03a8c0@fejleszt2> From: =?iso-8859-1?Q?SZUCS_G=E1bor?= To: References: Subject: Re: Like search performance. Date: Wed, 30 Apr 2003 18:59:52 +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-Spam-Status: No, hits=-19.1 required=5.0 tests=BAYES_20,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/268 X-Sequence-Number: 1774 I'm not an expert, but AFAIK locale and collation heavily affects LIKE, and thus, IIRC there is no index search for like, maybe except the simplest locales (maybe C and/or en_US?) But if you mean it... there is a nasty trick in the archives: http://archives.postgresql.org/pgsql-general/2002-08/msg00819.php Really, really nasty, but really nice at the same time. G. -- while (!asleep()) sheep++; ---------------------------- cut here ------------------------------ ----- Original Message ----- From: "Diehl, Jeffrey" To: ; Sent: Wednesday, April 30, 2003 6:34 PM Subject: [PERFORM] Like search performance. > Hi all, > > I have a fairly large table with a char(20) field in it which I search on > quite a bit. The problem is that I tend to do a lot of > "...where field like '%-d%'" type searches on this field. > > Is there any to speed up this type of search? > > TIA, > > Mike Diehl. > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > From pgsql-performance-owner@postgresql.org Wed Apr 30 13:08:33 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 36B15475AE4 for ; Wed, 30 Apr 2003 13:08:32 -0400 (EDT) Received: from c001.snv.cp.net (h007.c001.snv.cp.net [209.228.32.121]) by postgresql.org (Postfix) with SMTP id 480C8475A45 for ; Wed, 30 Apr 2003 13:08:31 -0400 (EDT) Received: (cpmta 21129 invoked from network); 30 Apr 2003 10:08:29 -0700 Received: from 209.228.32.128 (HELO mail.dilger.cc.criticalpath.net) by smtp.register-admin.com (209.228.32.121) with SMTP; 30 Apr 2003 10:08:29 -0700 X-Sent: 30 Apr 2003 17:08:29 GMT Received: from [207.25.88.117] by mail.dilger.cc with HTTP; Wed, 30 Apr 2003 10:08:28 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 To: jdiehl@sandia.gov Cc: pgsql-sql@postgresql.org, pgsql-performance@postgresql.org From: "Nikolaus Dilger" Subject: Re: Like search performance. X-Sent-From: nikolaus@dilger.cc Date: Wed, 30 Apr 2003 10:08:28 -0700 (PDT) X-Mailer: Web Mail 5.3.1-0_sol28 Message-Id: <20030430100829.9198.h014.c001.wm@mail.dilger.cc.criticalpath.net> X-Spam-Status: No, hits=-13.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTE_TWICE_1 autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/267 X-Sequence-Number: 1773 Jeffrey, The best thing you can do is to have the wildcard % as late as possible in your search condition. So do like 'd%' instead of like '%d%' if you can. Regards, Nikolaus On Wed, 30 Apr 2003 10:34:40 -0600, "Diehl, Jeffrey" wrote: > > Hi all, > > I have a fairly large table with a char(20) field in it > which I search on > quite a bit. The problem is that I tend to do a lot of > "...where field like '%-d%'" type searches on this > field. > > Is there any to speed up this type of search? > > TIA, > > Mike Diehl. > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster From pgsql-performance-owner@postgresql.org Wed Apr 30 13:33:48 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B69BB475AE4; Wed, 30 Apr 2003 13:33:47 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id E6B79475A45; Wed, 30 Apr 2003 13:33:46 -0400 (EDT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2998830; Wed, 30 Apr 2003 10:33:45 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Diehl, Jeffrey" , pgsql-sql@postgresql.org, pgsql-performance@postgresql.org Subject: Re: Like search performance. Date: Wed, 30 Apr 2003 10:33:17 -0700 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304301033.18357.josh@agliodbs.com> X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/269 X-Sequence-Number: 1775 Mike, > I have a fairly large table with a char(20) field in it which I search on > quite a bit. The problem is that I tend to do a lot of=20 > "...where field like '%-d%'" type searches on this field. >=20 > Is there any to speed up this type of search? Yes. See the tsearch module in /contrib in your postgresql source. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-performance-owner@postgresql.org Wed Apr 30 14:48:53 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3A325475C15 for ; Wed, 30 Apr 2003 14:48:53 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id 3F38D475A45 for ; Wed, 30 Apr 2003 14:48:46 -0400 (EDT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2999138; Wed, 30 Apr 2003 11:48:45 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Achilleus Mantzios Subject: Re: [SQL] 7.3 analyze & vacuum analyze problem Date: Wed, 30 Apr 2003 11:48:18 -0700 User-Agent: KMail/1.4.3 Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304301148.18322.josh@agliodbs.com> X-Spam-Status: No, hits=-22.7 required=5.0 tests=BAYES_01,IN_REP_TO,REFERENCES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/270 X-Sequence-Number: 1776 Achilleus, > I am afraid it is not so simple. > What i (unsuccessfully) implied is that=20 > dynacom=3D# VACUUM ANALYZE status ; > VACUUM > dynacom=3D# ANALYZE status ; > ANALYZE > dynacom=3D# You're right, that is mysterious. If you don't get a response from one of= =20 the major developers on this forum, I suggest that you post those EXPLAIN= =20 results to PGSQL-BUGS. --=20 -Josh Berkus Aglio Database Solutions San Francisco From pgsql-sql-owner@postgresql.org Wed Apr 30 11:55:44 2003 X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C454E475CE5 for ; Wed, 30 Apr 2003 11:55:39 -0400 (EDT) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 6AB71475A45 for ; Wed, 30 Apr 2003 11:55:33 -0400 (EDT) Received: from matrix.gatewaynet.com (localhost [127.0.0.1]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h3UKvW1s009311 for ; Wed, 30 Apr 2003 18:57:32 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h3UKvVwK009307 for ; Wed, 30 Apr 2003 18:57:32 -0200 Date: Wed, 30 Apr 2003 18:57:31 -0200 (GMT+2) From: Achilleus Mantzios To: pgsql-sql@postgresql.org Subject: 7.3 analyze & vacuum analyze problem In-Reply-To: <3E92E3B1.7070405@eselx.ipl.pt> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="333001285-2121937442-1051736251=:8921" X-Spam-Status: No, hits=-15.5 required=5.0 tests=BAYES_01,IN_REP_TO,USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/440 X-Sequence-Number: 13141 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --333001285-2121937442-1051736251=:8921 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi, i think i have an issue regarding the statistics that a) (plain) ANALYZE status and b) VACUUM ANALYZE status produce. I have a table status: dynacom=# \d status Table "public.status" Column | Type | Modifiers -------------+--------------------------+--------------------------------------------------- id | integer | not null default nextval('"status_id_seq"'::text) checkdate | timestamp with time zone | assettable | character varying(50) | assetidval | integer | appname | character varying(100) | apptblname | character varying(50) | apptblidval | integer | colname | character varying(50) | colval | double precision | status | character varying(5) | isvalid | boolean | username | character varying(50) | Indexes: status_id_key unique btree (id), status_all btree (assettable, assetidval, appname, apptblname, status, isvalid), status_all_wo_astidval btree (assettable, appname, apptblname, status, isvalid), status_appname btree (appname), status_apptblidval btree (apptblidval), status_apptblname btree (apptblname), status_assetidval btree (assetidval), status_assettable btree (assettable), status_checkdate btree (checkdate), status_colname btree (colname), status_isvalid btree (isvalid), status_status btree (status) dynacom=# dynacom=# SELECT count(*) from status ; count ------- 33565 (1 row) dynacom=# I very often perform queries of the form: select count(*) from status where assettable='vessels' and appname='ISM PMS' and apptblname='items' and status='warn' and isvalid and assetidval=; Altho i dont understand exactly why the stats created by VACUUM ANALYZE are more accurate (meaning producing faster plans) than the ones created by plain ANALYZE, (altho for some attributes they are false for sure) the performance is much much better when VACUUM ANALYZE is run than plain ANALYZE. In the former case, some times the status_all index is used, and sometimes (when the selectivity is small) a sequential scan is performed. In the latter case, no index is ever used even for crazy statements (assetidval is always >0) like: select count(*) from status where assettable='vessels' and appname='ISM PMS' and apptblname='items' and status='warn' and isvalid and assetidval=-10000000; I attach the statistics of either case. My app just performs the above query for most of the assetidval values (And for all most popular assetidval values) So the elapsed time of the app i think is a good measure of the overall performance of these queries. In the "VACUUM ANALYZE" case it takes 1.2 - 1.5 secs, while in the "ANALYZE" case it takes >=3+ -- ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-210-8981112 fax: +30-210-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr --333001285-2121937442-1051736251=:8921 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=2see-VACUUM_ANALYZE Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=2see-VACUUM_ANALYZE ICAgYXR0bmFtZSAgIHwgbnVsbF9mcmFjIHwgYXZnX3dpZHRoIHwgbl9kaXN0 aW5jdCB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb3N0 X2NvbW1vbl92YWxzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IG1vc3RfY29tbW9uX2ZyZXFzICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaXN0b2dyYW1f Ym91bmRzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgfCBjb3JyZWxhdGlvbiANCi0tLS0t LS0tLS0tLS0rLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0t Ky0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKy0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tDQogaWQgICAgICAg ICAgfCAgICAgICAgIDAgfCAgICAgICAgIDQgfCAgICAgICAgIC0xIHwgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgfCB7MjQsNzA3OSwxMzM4OSwxNzYyNCwyMTA4NCwyNDM5MiwyNTg3 NiwyODAzMywyOTg5NSwzMjEzMiwzMzg2Nn0gICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICB8ICAgIDAuODAxNjg2DQogY2hlY2tkYXRlICAgfCAg ICAgICAgIDAgfCAgICAgICAgIDggfCAgICAgICAgIC0xIHwgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg fCB7IjIwMDItMTAtMTkgMTA6NTk6NTQuMzk5KzAzIiwiMjAwMy0wMy0wMyAw NTowMDoyNS4zNTkrMDIiLCIyMDAzLTAzLTI5IDA1OjAwOjI4LjM4MiswMiIs IjIwMDMtMDQtMDEgMDU6MDE6MDAuMDY1KzAzIiwiMjAwMy0wNC0xMSAwNTow MToyNy4yMzQrMDMiLCIyMDAzLTA0LTI5IDA1OjAwOjQxLjMxOCswMyIsIjIw MDMtMDQtMjkgMDU6MDE6MjQuMDg0KzAzIiwiMjAwMy0wNC0zMCAwNTowMDo0 MC43MTkrMDMiLCIyMDAzLTA0LTMwIDA1OjAxOjA2LjIwMyswMyIsIjIwMDMt MDQtMzAgMDU6MDE6MjUuNDM1KzAzIiwiMjAwMy0wNC0zMCAwNTowMTo0Ni42 MzYrMDMifSB8ICAgIDAuOTIzNzI2DQogYXNzZXR0YWJsZSAgfCAgICAgICAg IDAgfCAgICAgICAgMTEgfCAgICAgICAgICAxIHwge3Zlc3NlbHN9ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIHwgezF9ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgICAgICAgICAxDQogYXNzZXRpZHZhbCAgfCAgICAgICAgIDAgfCAg ICAgICAgIDQgfCAgICAgICAgIDE4IHwgezUzLDU3LDQ4LDY1fSAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIHwgezAuMTM2NjY3LDAuMTA3MzMzLDAuMTAw MzMzLDAuMDc2NjY2N30gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCB7MjAsMjYsMjks MzIsMzMsMzUsNDQsNDcsNDksNjEsNzR9ICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAg IDAuMTE3NDMxDQogYXBwbmFtZSAgICAgfCAgICAgICAgIDAgfCAgICAgICAg MTEgfCAgICAgICAgICA2IHwgeyJJU00gUE1TIixDbGFzcy5DZXJ0aWZpY2F0 ZXMsQ2xhc3MuU3VydmV5cyxSZXBhaXJzLENsYXNzLkNNUyxDbGFzcy5SZWNv bW1lbmRhdGlvbnN9IHwgezAuOTg5MzMzLDAuMDA1LDAuMDAyNjY2NjcsMC4w MDE2NjY2NywwLjAwMDY2NjY2NywwLjAwMDY2NjY2N30gICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgIDAuOTkw Mjg2DQogYXBwdGJsbmFtZSAgfCAgICAgICAgIDAgfCAgICAgICAgIDkgfCAg ICAgICAgICA1IHwge2l0ZW1zLGNlcnRpZmljYXRlcyxzdXJ2ZXlzLHJlcGRh dCxyZWNvbW1lbmRhdGlvbnN9ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIHwgezAuOTksMC4wMDUsMC4wMDI2NjY2NywwLjAwMTY2NjY3LDAu MDAwNjY2NjY3fSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgIDAuOTc1ODgzDQog YXBwdGJsaWR2YWwgfCAgICAgICAgIDAgfCAgICAgICAgIDQgfCAgICAgICA1 MDAyIHwgezcxNjEsMTEwOTksNzE2MiwxMjM5MiwyODE5LDgzNDYsMTIyNDEs MTI0NjUsMTQ5MzIsMTcwMDd9ICAgICAgICAgICAgICAgICAgICAgICAgICAg IHwgezAuMDAyLDAuMDAyLDAuMDAxNjY2NjcsMC4wMDE2NjY2NywwLjAwMTMz MzMzLDAuMDAxMzMzMzMsMC4wMDEzMzMzMywwLjAwMTMzMzMzLDAuMDAxMzMz MzMsMC4wMDEzMzMzM30gfCB7Nyw1MDE2LDgyOTYsMTI0NDMsMTQ0NDMsMTcx MTUsMjAxNjYsMjE5OTYsMjI4NjYsMjQyMDksMzI3OTZ9ICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICB8ICAgMC4wNjA0MzY3DQogY29sbmFt ZSAgICAgfCAgICAgICAgIDAgfCAgICAgICAgMTQgfCAgICAgICAgICA2IHwg e2xhc3RyZXBkYXRlLGxhc3RpbnNwZGF0ZSxyaCxOL0Esc3RhdHVzLGNsYXNz c3VydmV5fSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAu NjYwNjY3LDAuMjk4NjY3LDAuMDMsMC4wMDgzMzMzMywwLjAwMTY2NjY3LDAu MDAwNjY2NjY3fSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB8ICAgICAwLjM4MDM2DQogY29sdmFsICAgICAg fCAgICAgICAgIDAgfCAgICAgICAgIDggfCAgLTAuNDMzMDc0IHwgezAsMSwx NjI0LDM3NDIsMTQ2LDU5NCw4NjQsOTE1LDEyNSwyMjR9ICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAuMDA5LDAu MDAxNjY2NjcsMC4wMDE2NjY2NywwLjAwMTMzMzMzLDAuMDAxLDAuMDAxLDAu MDAxLDAuMDAxLDAuMDAwNjY2NjY3LDAuMDAwNjY2NjY3fSAgICAgICAgICAg ICAgfCB7MjEsMTQ0NjMuOTQ3LDE0NDk4LjY1LDE4MDMxLjc2MiwxODA0My41 OCwxODA1MS41MTcsMTgwNTkuNzEyLDE4MDY3LjY4OCwxODA3OC42NywyMTY0 Ni4zOSw4MjgxMTU5NC4xNDZ9ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICB8ICAgIDAuMjg4NjU2DQogc3RhdHVzICAgICAgfCAgICAg ICAgIDAgfCAgICAgICAgIDggfCAgICAgICAgICAyIHwge3dhcm4sYWxhcm19 ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAuNTUsMC40NX0gICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICB8ICAgIDAuNDAxMDUzDQogaXN2YWxpZCAgICAgfCAgICAgICAgIDAg fCAgICAgICAgIDEgfCAgICAgICAgICAyIHwge2YsdH0gICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIHwgezAuNjUwNjY3LDAuMzQ5MzMzfSAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8 ICAgIDAuOTQ0ODI3DQogdXNlcm5hbWUgICAgfCAgICAgICAgIDAgfCAgICAg ICAgMTIgfCAgICAgICAgICA3IHwge3BlcmlvZGljLGNrYWtsYW1hbixhbWFu dHppbyxzZWNyZXR1c2VyLG1pdHNpb3MsbGlnbm9zLGJpcnRzaWF9ICAgICAg ICAgICAgICAgICAgICAgIHwgezAuODg2MzMzLDAuMDU0NjY2NywwLjAzMzY2 NjcsMC4wMTIsMC4wMTE2NjY3LDAuMDAxLDAuMDAwNjY2NjY3fSAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgIDAu ODA1NjA4DQooMTIgcm93cykNCg0K --333001285-2121937442-1051736251=:8921 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=2see-ANALYZE Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=2see-ANALYZE ICAgYXR0bmFtZSAgIHwgbnVsbF9mcmFjIHwgYXZnX3dpZHRoIHwgbl9kaXN0 aW5jdCB8ICAgICAgICAgICAgICAgICAgICAgICAgbW9zdF9jb21tb25fdmFs cyAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9zdF9jb21tb25fZnJlcXMg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg fCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgaGlzdG9ncmFtX2JvdW5kcyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgfCBjb3JyZWxhdGlvbiANCi0tLS0tLS0tLS0tLS0rLS0tLS0tLS0t LS0rLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tDQog aWQgICAgICAgICAgfCAgICAgICAgIDAgfCAgICAgICAgIDQgfCAgICAgICAg IC0xIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8 IHs5LDYzNTIsMTIyMDEsMTY3NzIsMjAzMDMsMjQxMzAsMjU0MTgsMjc2ODgs Mjk0MjcsMzE5MzgsMzM4Njh9ICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICB8ICAgIDAuODIxNjY0DQogY2hlY2tkYXRlICAgfCAgICAgICAgIDAg fCAgICAgICAgIDggfCAgICAgICAgIC0xIHwgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICB8IHsiMjAwMi0xMC0xOSAxMTowMTo1Ni4z MjUrMDMiLCIyMDAzLTAzLTAxIDA1OjAwOjUzLjA1KzAyIiwiMjAwMy0wMy0y MCAwNTowMDozMC43NjkrMDIiLCIyMDAzLTAzLTMwIDA1OjAwOjIyLjk4MSsw MyIsIjIwMDMtMDQtMDcgMDU6MDA6NTIuMjkrMDMiLCIyMDAzLTA0LTI2IDA1 OjAyOjQwLjY3MSswMyIsIjIwMDMtMDQtMjkgMDU6MDE6MTcuMzE0KzAzIiwi MjAwMy0wNC0zMCAwNTowMDozMC4yNDgrMDMiLCIyMDAzLTA0LTMwIDA1OjAx OjAxLjk0NSswMyIsIjIwMDMtMDQtMzAgMDU6MDE6MjMuOTAzKzAzIiwiMjAw My0wNC0zMCAwNTowMTo0Ni43MzcrMDMifSB8ICAgIDAuOTIyODY4DQogYXNz ZXR0YWJsZSAgfCAgICAgICAgIDAgfCAgICAgICAgMTEgfCAgICAgICAgICAx IHwge3Zlc3NlbHN9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIHwgezF9ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB8ICAgICAgICAgICAxDQogYXNzZXRpZHZhbCAgfCAgICAgICAgIDAgfCAg ICAgICAgIDQgfCAgICAgICAgIDE5IHwgezUzLDU3LDQ4LDY1LDQ5fSAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwg ezAuMTE2LDAuMTAxLDAuMDkzMzMzMywwLjA4MjMzMzMsMC4wNjczMzMzfSAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB8IHsyMCwyNCwyOSwzMiwzMywzNSw0Myw0NCw0 Nyw2MSw3NH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICB8ICAgIDAuMTAxNjQxDQogYXBwbmFt ZSAgICAgfCAgICAgICAgIDAgfCAgICAgICAgMTEgfCAgICAgICAgICA1IHwg eyJJU00gUE1TIixDbGFzcy5DZXJ0aWZpY2F0ZXMsQ2xhc3MuU3VydmV5cyxS ZXBhaXJzLENsYXNzLkNNU30gIHwgezAuOTg0NjY3LDAuMDA2NjY2NjcsMC4w MDQzMzMzMywwLjAwMzMzMzMzLDAuMDAxfSAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8 ICAgIDAuOTgwNjM0DQogYXBwdGJsbmFtZSAgfCAgICAgICAgIDAgfCAgICAg ICAgIDkgfCAgICAgICAgICA0IHwge2l0ZW1zLGNlcnRpZmljYXRlcyxzdXJ2 ZXlzLHJlcGRhdH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAu OTg1NjY3LDAuMDA2NjY2NjcsMC4wMDQzMzMzMywwLjAwMzMzMzMzfSAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICB8ICAgIDAuOTY4OTY5DQogYXBwdGJsaWR2 YWwgfCAgICAgICAgIDAgfCAgICAgICAgIDQgfCAgICAgICA0NzY0IHwgezc0 MjgsMjAyNTcsMjMzNCw0NjU2LDkwNDAsOTg2NCwxMTA3MCwxMjk3NSwxNTM0 MiwxNTg0NX0gICAgICAgIHwgezAuMDAyLDAuMDAxNjY2NjcsMC4wMDEzMzMz MywwLjAwMTMzMzMzLDAuMDAxMzMzMzMsMC4wMDEzMzMzMywwLjAwMTMzMzMz LDAuMDAxMzMzMzMsMC4wMDEzMzMzMywwLjAwMTMzMzMzfSB8IHsxLDU4MDcs ODQ1NywxMjUwMywxNDUxMiwxNzAwNywxOTk2NywyMTgyMSwyMjkwOSwyNDIw MiwzNTI4NH0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAg MC4wNTk2MDU2DQogY29sbmFtZSAgICAgfCAgICAgICAgIDAgfCAgICAgICAg MTQgfCAgICAgICAgICA2IHwge2xhc3RyZXBkYXRlLGxhc3RpbnNwZGF0ZSxy aCxOL0Esc3RhdHVzLGNsYXNzc3VydmV5fSAgICAgICAgICAgIHwgezAuNjM3 LDAuMzE2NjY3LDAuMDMxLDAuMDExLDAuMDAzMzMzMzMsMC4wMDF9ICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB8ICAgIDAuMzY1MzIzDQogY29sdmFsICAgICAg fCAgICAgICAgIDAgfCAgICAgICAgIDggfCAgLTAuMzQ1NTU3IHwgezAsMSw1 OTQsMTIwMCw3ODQsMTYyNCwyMSwxMzYsNTI2LDEyMzF9ICAgICAgICAgICAg ICAgICAgICAgICAgIHwgezAuMDEyLDAuMDAzNjY2NjcsMC4wMDE2NjY2Nyww LjAwMTY2NjY3LDAuMDAxMzMzMzMsMC4wMDEzMzMzMywwLjAwMSwwLjAwMSww LjAwMSwwLjAwMX0gICAgICAgICAgICAgICAgICAgICB8IHsyNCwxNDQ2NC41 NDksMTQ0OTQuMDE3LDE4MDMwLjc3OCwxODA0My40MiwxODA1MS43OSwxODA2 MC4wODksMTgwNjguMTE3LDE4MDc4LjMxOSwxMjI3NDUuOTg4LDc0MjYyMDU2 LjM2N30gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgIDAu MjM5NDQ4DQogc3RhdHVzICAgICAgfCAgICAgICAgIDAgfCAgICAgICAgIDgg fCAgICAgICAgICAyIHwge3dhcm4sYWxhcm19ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgezAuNTYxNjY3 LDAuNDM4MzMzfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICB8ICAgIDAuNDM2MzAyDQogaXN2YWxpZCAgICAgfCAg ICAgICAgIDAgfCAgICAgICAgIDEgfCAgICAgICAgICAyIHwge2YsdH0gICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIHwgezAuNjc1LDAuMzI1fSAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAwLjk1 MDA4DQogdXNlcm5hbWUgICAgfCAgICAgICAgIDAgfCAgICAgICAgMTIgfCAg ICAgICAgICA3IHwge3BlcmlvZGljLGNrYWtsYW1hbixhbWFudHppbyxzZWNy ZXR1c2VyLG1pdHNpb3MsbGlnbm9zLGJpcnRzaWF9IHwgezAuODc2MzMzLDAu MDUyMzMzMywwLjA0MSwwLjAxNDMzMzMsMC4wMTIsMC4wMDI2NjY2NywwLjAw MTMzMzMzfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICB8ICAgIDAuODE3MDk2DQooMTIgcm93cykNCg0K --333001285-2121937442-1051736251=:8921-- From pgsql-performance-owner@postgresql.org Wed Apr 30 12:11:47 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E3329476083; Wed, 30 Apr 2003 12:11:45 -0400 (EDT) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id 1F2EE475F2C; Wed, 30 Apr 2003 12:11:44 -0400 (EDT) Received: from matrix.gatewaynet.com (localhost [127.0.0.1]) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h3ULDe1s009392; Wed, 30 Apr 2003 19:13:40 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h3ULDe50009388; Wed, 30 Apr 2003 19:13:40 -0200 Date: Wed, 30 Apr 2003 19:13:40 -0200 (GMT+2) From: Achilleus Mantzios To: Josh Berkus Cc: pgsql-sql@postgresql.org, Subject: Re: [SQL] 7.3 analyze & vacuum analyze problem In-Reply-To: <200304300902.37985.josh@agliodbs.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-38.6 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, QUOTE_TWICE_1,REPLY_WITH_QUOTES,SIGNATURE_LONG_DENSE, USER_AGENT_PINE autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/264 X-Sequence-Number: 1770 On Wed, 30 Apr 2003, Josh Berkus wrote: > Achilleus, > > > i think i have an issue regarding the statistics that > > a) (plain) ANALYZE status and > > b) VACUUM ANALYZE status > > produce. > > It's perfectly normal for a query to run faster after a VACUUM ANALYZE than > after an ANALYZE ... after all, you just vacuumed it, didn't you? I am afraid it is not so simple. What i (unsuccessfully) implied is that dynacom=# VACUUM ANALYZE status ; VACUUM dynacom=# ANALYZE status ; ANALYZE dynacom=# is enuf to damage the performance. > > If you're demonstrating some other kind of behavioural difference, then please > post the results of EXPLAIN ANALYZE for the two examples. > dynacom=# ANALYZE status ; ANALYZE dynacom=# EXPLAIN ANALYZE select count(*) from status where assettable='vessels' and appname='ISM PMS' and apptblname='items' and status='warn' and isvalid and assetidval=49; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=4309.53..4309.53 rows=1 width=0) (actual time=242.60..242.60 rows=1 loops=1) -> Seq Scan on status (cost=0.00..4306.08 rows=1378 width=0) (actual time=15.75..242.51 rows=50 loops=1) Filter: ((assettable = 'vessels'::character varying) AND (appname = 'ISM PMS'::character varying) AND (apptblname = 'items'::character varying) AND (status = 'warn'::character varying) AND isvalid AND (assetidval = 49)) Total runtime: 242.74 msec (4 rows) dynacom=# dynacom=# VACUUM ANALYZE status ; VACUUM dynacom=# EXPLAIN ANALYZE select count(*) from status where assettable='vessels' and appname='ISM PMS' and apptblname='items' and status='warn' and isvalid and assetidval=49; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=2274.90..2274.90 rows=1 width=0) (actual time=8.89..8.89 rows=1 loops=1) -> Index Scan using status_all on status (cost=0.00..2274.34 rows=223 width=0) (actual time=8.31..8.83 rows=50 loops=1) Index Cond: ((assettable = 'vessels'::character varying) AND (assetidval = 49) AND (appname = 'ISM PMS'::character varying) AND (apptblname = 'items'::character varying) AND (status = 'warn'::character varying)) Filter: isvalid Total runtime: 8.98 msec (5 rows) dynacom=# > Oh, and we should probably shift this discussion to the PGSQL-PERFORMANCE > list. > OK. > -- ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-210-8981112 fax: +30-210-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr From pgsql-performance-owner@postgresql.org Wed Apr 30 18:25:25 2003 X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 47083476182 for ; Wed, 30 Apr 2003 18:25:24 -0400 (EDT) Received: from torque.intervideoinc.com (mail.intervideo.com [206.112.112.151]) by postgresql.org (Postfix) with ESMTP id 69AB34760E3 for ; Wed, 30 Apr 2003 18:25:23 -0400 (EDT) Received: from ronpc [63.68.5.2] by torque.intervideoinc.com (SMTPD32-5.05) id A22C46460060; Wed, 30 Apr 2003 15:46:04 -0700 From: "Ron Mayer" To: , "Achilleus Mantzios" Cc: Subject: Re: [SQL] 7.3 analyze & vacuum analyze problem Date: Wed, 30 Apr 2003 15:16:58 -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.2416 (9.0.2911.0) Importance: Normal In-Reply-To: <200304301148.18322.josh@agliodbs.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 X-Spam-Status: No, hits=-14.3 required=5.0 tests=BAYES_10,IN_REP_TO,MSGID_GOOD_EXCHANGE,SMTPD_IN_RCVD autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/271 X-Sequence-Number: 1777 Josh wrote... > Achilleus, > > > I am afraid it is not so simple. > > What i (unsuccessfully) implied is that > > dynacom=# VACUUM ANALYZE status ; > > VACUUM > > dynacom=# ANALYZE status ; > > ANALYZE > > dynacom=# > > > > [is enuf to damage the performance.] > > You're right, that is mysterious. If you don't get a response from one of > the major developers on this forum, I suggest that you post those EXPLAIN > results to PGSQL-BUGS. I had the same problem a while back. http://archives.postgresql.org/pgsql-bugs/2002-08/msg00015.php http://archives.postgresql.org/pgsql-bugs/2002-08/msg00018.php http://archives.postgresql.org/pgsql-bugs/2002-08/msg00018.php Short summary: Later in the thread Tom explained my problem as free space not being evenly distributed across the table so ANALYZE's sampling gave skewed results. In my case, "pgstatuple" was a good tool for diagnosing the problem, "vacuum full" fixed my table and a much larger fsm_* would have probably prevented it.